Last active
July 25, 2016 15:42
-
-
Save mdshw5/98a1c51e0c5f76683a63f770f48f91cb to your computer and use it in GitHub Desktop.
biostars 203117
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyfaidx import FastaVariant | |
import vcf | |
samples = vcf.Reader(open('calls.vcf.gz', 'r')).samples | |
for sample in samples: | |
with FastaVariant('reference.fasta', 'calls.vcf.gz', sample=sample, het=True, hom=True) as consensus: | |
with open(sample + '.fasta', 'w') as sample_fasta: | |
for record in consensus: | |
sample_fasta.write('>' + record.long_name) | |
sample_fasta.write(str(record)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment