Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
v.alt = 'asd'
# non-fixed arguments
v.id = 'asd'
v.qual = 10
v.filter = 'asd'
v.source = 2
assert isinstance(Variant("chr1", '10', 'C', 'T').pos, int)
# from cyvcf2
vcf = cyvcf2.VCF('tests/data/test.vcf.gz')
cv = list(vcf)[0]
v2 = Variant.from_cyvcf(cv)
assert isinstance(v2.source, cyvcf2.Variant)
# Get variant ref, alt.
var_ref, var_alt = _get_var_ref_and_alt(var)
# no alternative alleles, return the original region_only hits
if not var_alt or len(var_alt) == 0:
return hits
var_alt = set(var_alt)
# Warn for multiple alleles.
chrom, start, end = coords
multiallele_warning(chrom, start, ','.join(var_alt), False)
# Filter hits to those that match ref and alt.
matched_hits = []
for h in hits:
if isinstance(h, (cyvcf2.Variant, pysam.VariantRecord)):
start = h.start
elif isinstance(h, basestring):
start = int(h.split('\t', 2)[1]) - 1
else:
start = h.pos
if start != coords[1]: continue
anno_ref, anno_alt = _get_var_ref_and_alt(h)
anno_alt = set(anno_alt)
multiallele_warning(chrom, start, anno_alt, True)
# Match via ref and set intersection of alternates.
# the mappability uses "." as the alt for all rows. so
if var_ref == anno_ref and (len(var_alt & anno_alt) >= 1 \
or anno_alt == set(".")):
def _get_var_coords(var, naming):
"""Retrieve variant coordinates from multiple input objects.
"""
if isinstance(var, cyvcf2.Variant):
chrom, start, end = var.CHROM, var.start, var.end
else:
try:
# todo: check isinstance resultproxy?
chrom = var["chrom"]
start = int(var["start"])
end = int(var["end"])
except TypeError:
chrom = var.CHROM
start = var.start
end = var.end
if naming == "ucsc":
chrom = _get_chr_as_ucsc(chrom)
elif naming == "grch37":
chrom = _get_chr_as_grch37(chrom)
return chrom, start, end