[med-svn] [Git][med-team/cyvcf2][upstream] New upstream version 0.20.7
Nilesh Patra
gitlab at salsa.debian.org
Mon Sep 28 18:18:51 BST 2020
Nilesh Patra pushed to branch upstream at Debian Med / cyvcf2
Commits:
eba05721 by Nilesh Patra at 2020-09-28T22:44:39+05:30
New upstream version 0.20.7
- - - - -
3 changed files:
- cyvcf2/__init__.py
- cyvcf2/cyvcf2.pyx
- cyvcf2/tests/test_reader.py
Changes:
=====================================
cyvcf2/__init__.py
=====================================
@@ -2,4 +2,4 @@ from .cyvcf2 import (VCF, Variant, Writer, r_ as r_unphased, par_relatedness,
par_het)
Reader = VCFReader = VCF
-__version__ = "0.20.6"
+__version__ = "0.20.7"
=====================================
cyvcf2/cyvcf2.pyx
=====================================
@@ -1029,17 +1029,24 @@ cdef class Genotypes(object):
array returns an int16 numpy array of shape n_samples, (ploidy + 1).
The last column indicates phased (1 is phased, 0 is unphased).
The other columns indicate the alleles, e.g. [0, 1, 1] is 0|1.
+ Unknown alleles are represented by -1 and mixed-ploidy arrays
+ are padded with -2 to indicate non-alleles.
"""
cdef np.ndarray[np.int16_t, ndim=2] to_return = np.zeros((self.n_samples, self.ploidy + 1),
dtype=np.int16)
+ cdef int raw
cdef int ind
cdef int allele
cdef int p = self.ploidy + 1
for ind in range(self.n_samples):
for allele in range(self.ploidy):
- to_return[ind, allele] = (self._raw[ind * self.ploidy + allele] >> 1) - 1
+ raw = self._raw[ind * self.ploidy + allele]
+ if raw == bcf_int32_vector_end:
+ to_return[ind, allele] = -2
+ else:
+ to_return[ind, allele] = (raw >> 1) - 1
to_return[ind, self.ploidy] = (self._raw[ind * self.ploidy + 1] & 1) == 1
return to_return
=====================================
cyvcf2/tests/test_reader.py
=====================================
@@ -808,6 +808,38 @@ def test_access_genotype():
v.genotype = gts
assert "1/0:6728,1:F 0/1:22,1:G" in str(v)
+def test_access_genotype_array():
+ vcf = VCF('{}/test-format-string.vcf'.format(HERE))
+ """
+7 55086956 . C G 0 . . GT:ADP_ALL:RULE 0/0:6728,1:F 1|1:22,1:G
+7 55086957 . T A,C,G 0 . . GT:ADP_ALL:RULE 1/2:6768,2,2,1:F2,F3,F4 2|3:1,2,3,4:G2,G3,G4
+7 55086958 . T G 0 . . GT:ADP_ALL:RULE 0/1/.:6768,2,2,1:F2,F3,F4 0:1,2,3,4:G2,G3,G4
+7 55086959 . T G,T 0 . . GT:ADP_ALL:RULE . 0|2:1,2,3,4:G2,G3,G4
+ """
+
+ v = next(vcf)
+ np.testing.assert_array_equal(
+ v.genotype.array(),
+ np.array([[0, 0, 0], [1, 1, 1]], dtype=np.int16)
+ )
+
+ v = next(vcf)
+ np.testing.assert_array_equal(
+ v.genotype.array(),
+ np.array([[1, 2, 0], [2, 3, 1]], dtype=np.int16)
+ )
+
+ v = next(vcf)
+ np.testing.assert_array_equal(
+ v.genotype.array(),
+ np.array([[0, 1, -1, 0], [0, -2, -2, 1]], dtype=np.int16)
+ )
+
+ v = next(vcf)
+ np.testing.assert_array_equal(
+ v.genotype.array(),
+ np.array([[-1, -2, 1], [0, 2, 1]], dtype=np.int16)
+ )
def test_alt_homozygous_gt():
vcf = VCF(os.path.join(HERE, "test-multiallelic-homozygous-alt.vcf.gz"))
View it on GitLab: https://salsa.debian.org/med-team/cyvcf2/-/commit/eba05721427c97ef0d5184f6ef356bd599351c0d
--
View it on GitLab: https://salsa.debian.org/med-team/cyvcf2/-/commit/eba05721427c97ef0d5184f6ef356bd599351c0d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200928/63d9898b/attachment-0001.html>
More information about the debian-med-commit
mailing list