def test_haploid_allele_indices_for_genotype_likelihood_index(self): for aix in six.moves.xrange(20): allele_indices = (aix,) ix = variant_utils.genotype_likelihood_index(allele_indices) actual = variant_utils.allele_indices_for_genotype_likelihood_index( ix, ploidy=1) self.assertEqual(actual, aix)
def test_haploid_allele_indices_for_genotype_likelihood_index(self): for aix in xrange(20): allele_indices = (aix,) ix = variant_utils.genotype_likelihood_index(allele_indices) actual = variant_utils.allele_indices_for_genotype_likelihood_index( ix, ploidy=1) self.assertEqual(actual, aix)
def test_diploid_allele_indices_for_genotype_likelihood_index(self): for aix in range(20): for bix in range(20): allele_indices = (aix, bix) expected = tuple(sorted(allele_indices)) ix = variant_utils.genotype_likelihood_index(allele_indices) actual = variant_utils.allele_indices_for_genotype_likelihood_index( ix, ploidy=2) self.assertEqual(actual, expected)
def add(self, allele_indices, likelihood): """Add some likelihood to a particular allele configuration. Args: allele_indices: Pair of (g1, g2) ints representing the genotype. likelihood: float. log10(probability of this genotype configuration). """ ix = variant_utils.genotype_likelihood_index(allele_indices) self._genotype_likelihood_containers[ix].append(likelihood)
def test_diploid_allele_indices_for_genotype_likelihood_index(self): for aix in xrange(20): for bix in xrange(20): allele_indices = (aix, bix) expected = tuple(sorted(allele_indices)) ix = variant_utils.genotype_likelihood_index(allele_indices) actual = variant_utils.allele_indices_for_genotype_likelihood_index( ix, ploidy=2) self.assertEqual(actual, expected)
def __init__(self, num_alts): """Constructor. Args: num_alts: int. The number of alternate alleles in the variant. """ self._num_likelihoods = variant_utils.genotype_likelihood_index( (num_alts, num_alts)) + 1 # At each GL index, we keep a list that will include the joint GL across all # variants that include that particular set of allele indices for this # variant. self._genotype_likelihood_containers = [] for _ in xrange(self._num_likelihoods): self._genotype_likelihood_containers.append([])