jpayne@0: from Bio import SeqIO jpayne@0: import vcf jpayne@0: jpayne@0: jpayne@0: import argparse jpayne@0: import os jpayne@0: import sys jpayne@0: jpayne@0: def passes(vcf_feature, contigs, edge_length=500, window_size=1000, max_snps=3): jpayne@0: return True jpayne@0: jpayne@0: def main(input_vcf, input_reference, output_included, output_excluded=os.devnull, *args, **kwargs) jpayne@0: contigs = list(SeqIO.parse(input_reference, 'fasta')) jpayne@0: included = vcf.Writer(output_included) jpayne@0: excluded = vcf.Writer(output_excluded) jpayne@0: for feature in vcf.Reader(input_vcf): jpayne@0: if passes(feature, contigs, *args, **kwargs): jpayne@0: included.write(feature) jpayne@0: else: jpayne@0: excluded.write(feature) jpayne@0: jpayne@0: if __name__ == '__main__': jpayne@0: parser = argparse.ArgumentParser() jpayne@0: parser.add_argument('input_vcf', type=argparse.FileType()) jpayne@0: parser.add_argument('input_reference', type=argparse.FileType()) jpayne@0: parser.add_argument('output_included', type=argparse.FileType('w')) jpayne@0: parser.add_argument('--excluded', '-x', dest='output_excluded', type=argparse.FileType('w'), default=os.devnull)