annotate filter_vcf.py @ 5:33669ce539f6 draft

Uploaded
author ulfschaefer
date Fri, 18 Dec 2015 05:11:42 -0500
parents 834a312c0114
children cd59be4a7fe3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
1 #!/usr/bin/env python
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
2 '''Simple VCF parser using custom filters.
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
3
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
4 Created on 6 Oct 2015
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
5
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
6 @author: alex
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
7 '''
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
8 import argparse
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
9
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
10 from phe.variant import VariantSet
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
11
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
12
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
13 def get_args():
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
14
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
15 args = argparse.ArgumentParser()
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
16
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
17 args.add_argument("--vcf", "-v", required=True, help="VCF file to (re)filter.")
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
18 args.add_argument("--filters", "-f", required=True, help="Filter(s) to apply as key:threshold pairs, separated by comma.")
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
19 args.add_argument("--output", "-o", required=True, help="Location for filtered VCF to be written.")
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
20
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
21 return args.parse_args()
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
22
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
23
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
24 def main():
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
25 args = get_args()
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
26
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
27 var_set = VariantSet(args.vcf, filters=args.filters)
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
28
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
29 var_set.filter_variants()
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
30
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
31 var_set.serialise(args.output)
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
32
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
33 if __name__ == '__main__':
834a312c0114 Uploaded
ulfschaefer
parents:
diff changeset
34 exit(main())