Mercurial > repos > jpayne > snp_pipeline
comparison snp-filter.py @ 0:eefdd97a6749
planemo upload commit b'7f6183b769772449fbcee903686b8d5ec5b7439f\n'-dirty
author | jpayne |
---|---|
date | Wed, 24 Jan 2018 14:18:21 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:eefdd97a6749 |
---|---|
1 from Bio import SeqIO | |
2 import vcf | |
3 | |
4 | |
5 import argparse | |
6 import os | |
7 import sys | |
8 | |
9 def passes(vcf_feature, contigs, edge_length=500, window_size=1000, max_snps=3): | |
10 return True | |
11 | |
12 def main(input_vcf, input_reference, output_included, output_excluded=os.devnull, *args, **kwargs) | |
13 contigs = list(SeqIO.parse(input_reference, 'fasta')) | |
14 included = vcf.Writer(output_included) | |
15 excluded = vcf.Writer(output_excluded) | |
16 for feature in vcf.Reader(input_vcf): | |
17 if passes(feature, contigs, *args, **kwargs): | |
18 included.write(feature) | |
19 else: | |
20 excluded.write(feature) | |
21 | |
22 if __name__ == '__main__': | |
23 parser = argparse.ArgumentParser() | |
24 parser.add_argument('input_vcf', type=argparse.FileType()) | |
25 parser.add_argument('input_reference', type=argparse.FileType()) | |
26 parser.add_argument('output_included', type=argparse.FileType('w')) | |
27 parser.add_argument('--excluded', '-x', dest='output_excluded', type=argparse.FileType('w'), default=os.devnull) |