Skip to content

Commit

Permalink
partial fix for #217
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Jul 27, 2021
1 parent 99e44a1 commit 59d5b03
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v0.30.10
+ fix is_indel for <NON_REF> (see #217)

# 0.3.8
+ just bumping for CI+wheels

Expand Down
2 changes: 1 addition & 1 deletion cyvcf2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
par_het)
Reader = VCFReader = VCF

__version__ = "0.30.9"
__version__ = "0.30.10"
12 changes: 6 additions & 6 deletions cyvcf2/cyvcf2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1830,18 +1830,18 @@ cdef class Variant(object):
"boolean indicating if the variant is an indel."
def __get__(self):
cdef int i
is_sv = self.is_sv
if len(self.b.d.allele[0]) > 1 and not is_sv: return True
if self.is_sv: return False
if len(self.b.d.allele[0]) > 1 and self.b.d.allele[0] != '<': return True

if len(self.REF) > 1 and not is_sv: return True
if len(self.REF) > 1: return True

for i in range(1, self.b.n_allele):
alt = self.b.d.allele[i]
if alt[0] == '<': continue
if alt == b".":
return True
if len(alt) != len(self.REF):
if not is_sv:
return True
if len(alt) > 1:
return True
return False

property is_transition:
Expand Down
10 changes: 10 additions & 0 deletions cyvcf2/tests/test.isa.vcf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##fileformat=VCFv4.2
##fileDate=20200122
##contig=<ID=chr1,length=1348724>
##INFO=<ID=AC,Number=A,Type=Integer,Description="Total number of alternate alleles in called genotypes">
#CHROM POS ID REF ALT QUAL FILTER INFO
chr1 146999 . TCGGT <NON_REF> 0 . AC=0
chr1 146999 . TCGGT TGGGG 0 . AC=0
chr1 146999 . T TG 0 . AC=0
chr1 146999 . TG T 0 . AC=0
chr1 146999 . T G 0 . AC=0
12 changes: 12 additions & 0 deletions cyvcf2/tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ def test_writer_from_string():
w.write_record(v)
w.close()

def test_isa():

vcf = VCF(os.path.join(HERE, "test.isa.vcf"))
for i, v in enumerate(vcf):
if i in {0, 1, 2, 3}:
assert v.is_indel
assert not v.is_snp
if i in {4}:
assert v.is_snp




def run_writer(writer, filename, rec):
rec.INFO["AC"] = "3"
Expand Down

0 comments on commit 59d5b03

Please sign in to comment.