Mercurial > repos > jpayne > snp_pipeline
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/snp-filter.py Wed Jan 24 14:18:21 2018 -0500 @@ -0,0 +1,27 @@ +from Bio import SeqIO +import vcf + + +import argparse +import os +import sys + +def passes(vcf_feature, contigs, edge_length=500, window_size=1000, max_snps=3): + return True + +def main(input_vcf, input_reference, output_included, output_excluded=os.devnull, *args, **kwargs) + contigs = list(SeqIO.parse(input_reference, 'fasta')) + included = vcf.Writer(output_included) + excluded = vcf.Writer(output_excluded) + for feature in vcf.Reader(input_vcf): + if passes(feature, contigs, *args, **kwargs): + included.write(feature) + else: + excluded.write(feature) + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('input_vcf', type=argparse.FileType()) + parser.add_argument('input_reference', type=argparse.FileType()) + parser.add_argument('output_included', type=argparse.FileType('w')) + parser.add_argument('--excluded', '-x', dest='output_excluded', type=argparse.FileType('w'), default=os.devnull) \ No newline at end of file