Skip to content

Instantly share code, notes, and snippets.

@clintval
Created August 6, 2018 21:13
Show Gist options
  • Select an option

  • Save clintval/44f023bc6f090f43f39a49bf4a1b75ae to your computer and use it in GitHub Desktop.

Select an option

Save clintval/44f023bc6f090f43f39a49bf4a1b75ae to your computer and use it in GitHub Desktop.
from cyvcf2 import VCFReader
from snv_spectrum import Snv
reader = VCFReader(str(root / 'all.ann.vcf'))
samples = reader.samples
for variant in reader:
for sample, depth, alt_depth, gt_base in zip(
samples,
variant.gt_depths,
variant.gt_alt_depths,
variant.gt_bases
):
ref, alt = gt_base.split('/')
if alt == ref == '.': continue
snv = Snv(ref, alt)
snv.set_context_from_fasta_locus(reference, variant.CHROM, variant.POS)
snv = snv.with_pyrimidine_reference()
print(snv.context)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment