Skip to content

Commit

Permalink
closes #236
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Mar 15, 2022
1 parent 2073457 commit 5a3d046
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 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.15
+ fix num_unknown when gts012=True (#236)

# v0.30.14
+ use warnings instead of sys.stderr (#229 from @grahamgower)
+ use libdeflate in wheel build (#231 from @grahamgower)
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.14"
__version__ = "0.30.15"
4 changes: 2 additions & 2 deletions cyvcf2/cyvcf2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,9 @@ cdef class Variant(object):
if self._gt_types == NULL:
self.gt_types
cdef int n = 0, i = 0
cdef int unknown = 3 if self.vcf.gts012 else 2
for i in range(self.vcf.n_samples):
if self._gt_types[i] == 2:
n+=1
n += (self._gt_types[i] == unknown)
return n

property FORMAT:
Expand Down
14 changes: 14 additions & 0 deletions cyvcf2/tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,3 +1302,17 @@ def test_genotypes():
a = v.genotype.array()[0] # only 0'th item
print("i:", i, " a:", v.genotype.array()[0], " exp:", exp_array[i])
assert (a == exp_array[i]).all(), " error with array"

def test_issue236():


for strict_gt in (False, True):
res = [[], []]

for gts in (False, True):
vcf = VCF(os.path.join(HERE, "test-genotypes.vcf"), gts012=gts, strict_gt=strict_gt)
for v in vcf:
res[int(gts)].append(v.num_unknown)

assert res[0] == res[1]
assert len(res[0]) > 0

0 comments on commit 5a3d046

Please sign in to comment.