view filter_vcf.py @ 6:0ea6829e6998 draft

Uploaded
author ulfschaefer
date Fri, 18 Dec 2015 05:12:27 -0500
parents 834a312c0114
children cd59be4a7fe3
line wrap: on
line source

#!/usr/bin/env python
'''Simple VCF parser using custom filters.

Created on 6 Oct 2015

@author: alex
'''
import argparse

from phe.variant import VariantSet


def get_args():

    args = argparse.ArgumentParser()

    args.add_argument("--vcf", "-v", required=True, help="VCF file to (re)filter.")
    args.add_argument("--filters", "-f", required=True, help="Filter(s) to apply as key:threshold pairs, separated by comma.")
    args.add_argument("--output", "-o", required=True, help="Location for filtered VCF to be written.")

    return args.parse_args()


def main():
    args = get_args()

    var_set = VariantSet(args.vcf, filters=args.filters)

    var_set.filter_variants()

    var_set.serialise(args.output)

if __name__ == '__main__':
    exit(main())