Created
May 11, 2015 17:24
-
-
Save mdshw5/15e415f1cadbcdd9e034 to your computer and use it in GitHub Desktop.
biostars 141739
This file contains hidden or 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 | |
consensus = FastaVariant('reference.fasta', 'sample1.vcf.gz', het=True, hom=True) | |
chrom = 'chr1' | |
seq = consensus[chrom][0:8] | |
print(seq) # AGTGCG | |
# if you don't want to invariant sites masked, you're good to go. otherwise: | |
masked = [] | |
for base in seq: | |
if base.start in consensus.variant_sites: | |
masked.append(base.seq) | |
else: | |
masked.append('N') | |
print(''.join(masked)) # ANTGCN | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment