[med-svn] [Git][med-team/cyvcf2][upstream] New upstream version 0.20.9
Nilesh Patra
gitlab at salsa.debian.org
Mon Oct 12 06:50:59 BST 2020
Nilesh Patra pushed to branch upstream at Debian Med / cyvcf2
Commits:
aa57799f by Nilesh Patra at 2020-10-12T11:07:07+05:30
New upstream version 0.20.9
- - - - -
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.8"
+__version__ = "0.20.9"
=====================================
cyvcf2/cyvcf2.pyx
=====================================
@@ -1024,13 +1024,14 @@ cdef class Genotypes(object):
result.append((v >> 1) - 1)
return result
- def array(Genotypes self):
+ def array(Genotypes self, int fill=-2):
"""
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.
+ Unknown alleles are represented by -1.
+ If a mixture of ploidy levels are present then the array is padded
+ with the `fill` value (default = -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)
@@ -1044,7 +1045,7 @@ cdef class Genotypes(object):
for allele in range(self.ploidy):
raw = self._raw[ind * self.ploidy + allele]
if raw == bcf_int32_vector_end:
- to_return[ind, allele] = -2
+ to_return[ind, allele] = fill
else:
to_return[ind, allele] = (raw >> 1) - 1
to_return[ind, self.ploidy] = (self._raw[ind * self.ploidy + 1] & 1) == 1
=====================================
cyvcf2/tests/test_reader.py
=====================================
@@ -841,6 +841,12 @@ def test_access_genotype_array():
np.array([[-1, -2, 1], [0, 2, 1]], dtype=np.int16)
)
+ # test fill value
+ np.testing.assert_array_equal(
+ v.genotype.array(fill=-9),
+ np.array([[-1, -9, 1], [0, 2, 1]], dtype=np.int16)
+ )
+
def test_alt_homozygous_gt():
vcf = VCF(os.path.join(HERE, "test-multiallelic-homozygous-alt.vcf.gz"))
assert vcf is not None
View it on GitLab: https://salsa.debian.org/med-team/cyvcf2/-/commit/aa57799f1ca7f9ceae1a0ff584c43a81515b5048
--
View it on GitLab: https://salsa.debian.org/med-team/cyvcf2/-/commit/aa57799f1ca7f9ceae1a0ff584c43a81515b5048
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/20201012/353f01a8/attachment-0001.html>
More information about the debian-med-commit
mailing list