Skip to content

Instantly share code, notes, and snippets.

@mdshw5
Created October 13, 2018 20:47
Show Gist options
  • Save mdshw5/979636122347fe3f90434346c70e883e to your computer and use it in GitHub Desktop.
Save mdshw5/979636122347fe3f90434346c70e883e to your computer and use it in GitHub Desktop.
gencove to DNA.land
import vcf
file = ''
with open('outfile.txt', 'w') as out:
for variant in vcf.Reader(open(file)):
if len(variant.FILTER) == 0:
if variant.is_snp:
for sample in variant.samples:
ref, alt = sample.gt_bases.replace('|', '/').split('/')
print(variant.CHROM, str(variant.POS), ref, alt, sep='\t', file=out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment