def test_merge_predictions_simplifies_alleles(self): """Checks that merge_predictions simplifies alleles.""" ref, alts = 'CCA', ['CA', 'C'] inputs = [ _create_call_variants_output(ref=ref, indices=[0], probabilities=[0.0, 1.0, 0.0], alts=alts), _create_call_variants_output(ref=ref, indices=[1], probabilities=[1.0, 0.0, 0.0], alts=alts), _create_call_variants_output(ref=ref, indices=[0, 1], probabilities=[0.0, 1.0, 0.0], alts=alts), ] for permuted_inputs in itertools.permutations(inputs): # qual_filter=2 is needed so we remove our middle 'C' allele. variant, probs = postprocess_variants.merge_predictions( permuted_inputs, qual_filter=2) np.testing.assert_almost_equal(probs, [0.0, 1.0, 0.0]) self.assertEqual(variant.reference_bases, 'CC') self.assertEqual(variant.alternate_bases, ['C'])
def test_merge_predictions(self, inputs, expected_unnormalized_probs): denominator = sum(expected_unnormalized_probs) for permuted_inputs in itertools.permutations(inputs): _, predictions = postprocess_variants.merge_predictions( permuted_inputs) np.testing.assert_almost_equal( predictions, [x / denominator for x in expected_unnormalized_probs])
def test_merge_predictions_simplifies_alleles(self): """Checks that merge_predictions simplifies alleles.""" ref, alts = 'CCA', ['CA', 'C'] inputs = [ _create_call_variants_output( ref=ref, indices=[0], probabilities=[0.0, 1.0, 0.0], alts=alts), _create_call_variants_output( ref=ref, indices=[1], probabilities=[1.0, 0.0, 0.0], alts=alts), _create_call_variants_output( ref=ref, indices=[0, 1], probabilities=[0.0, 1.0, 0.0], alts=alts), ] for permuted_inputs in itertools.permutations(inputs): # qual_filter=2 is needed so we remove our middle 'C' allele. variant, probs = postprocess_variants.merge_predictions( permuted_inputs, qual_filter=2) np.testing.assert_almost_equal(probs, [0.0, 1.0, 0.0]) self.assertEqual(variant.reference_bases, 'CC') self.assertEqual(variant.alternate_bases, ['C'])
def test_exception_merge_predictions(self, inputs, text): with self.assertRaisesRegexp(ValueError, text): postprocess_variants.merge_predictions(inputs)
def test_exception_merge_predictions(self, inputs, text): with self.assertRaisesRegexp(ValueError, text): postprocess_variants.merge_predictions(inputs)
def test_merge_predictions(self, inputs, expected_unnormalized_probs): denominator = sum(expected_unnormalized_probs) for permuted_inputs in itertools.permutations(inputs): _, predictions = postprocess_variants.merge_predictions(permuted_inputs) np.testing.assert_almost_equal( predictions, [x / denominator for x in expected_unnormalized_probs])