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 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 test_unsupported_allele_indices_for_genotype_likelihood_index( self, ploidy): with self.assertRaisesRegexp(NotImplementedError, 'only supported for haploid and diploid'): variant_utils.allele_indices_for_genotype_likelihood_index(0, ploidy)
def most_likely_allele_indices(self): """Returns allele indices for the genotype with the largest likelihood.""" ix = np.argmax(self.scaled_likelihoods()) return variant_utils.allele_indices_for_genotype_likelihood_index( ix, ploidy=2)
def test_unsupported_allele_indices_for_genotype_likelihood_index( self, ploidy): with self.assertRaisesRegexp(NotImplementedError, 'only supported for haploid and diploid'): variant_utils.allele_indices_for_genotype_likelihood_index(0, ploidy)