Skip to content

Instantly share code, notes, and snippets.

@ryanlayer
Created April 6, 2016 19:26
Show Gist options
  • Select an option

  • Save ryanlayer/bcf15bc96d465cb1e445a32387b2716c to your computer and use it in GitHub Desktop.

Select an option

Save ryanlayer/bcf15bc96d465cb1e445a32387b2716c to your computer and use it in GitHub Desktop.
Filtering SVTyped lumpy
from cyvcf2 import VCF
import numpy as np
my_vcf = VCF('-')
#print my_vcf.raw_header,
samples = np.array(my_vcf.samples)
for variant in my_vcf:
gts = variant.gt_types
non_ref = samples[(gts != 0) & (gts != 2)]
if ((1 in variant.gt_types) or (3 in variant.gt_types)) \
and (2 not in variant.gt_types) \
and variant.QUAL > 100 \
and np.median(variant.format('GQ', float)) > 100:
#print str(variant),
print variant.CHROM + "\t" + variant.ID +"\t" + str(variant.QUAL) + "\t" + str(variant.INFO['SU']) + "\t" + str(variant.format('AO', int).max()) + "\t" + str(len(non_ref)) + "\t" + "\t".join(non_ref)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment