コード例 #1
0
 def test_genotype_confidence_setter(self):
     dummy_vcfgenotypeinfo = ns_test.VCFGenotypeInfo('')
     dummy_vcfgenotypeinfo.genotype_confidence = "89"
     self.assertEqual(89.0, dummy_vcfgenotypeinfo.genotype_confidence)
     dummy_vcfgenotypeinfo.genotype_confidence = 89
     self.assertEqual(89.0, dummy_vcfgenotypeinfo.genotype_confidence)
     dummy_vcfgenotypeinfo.genotype_confidence = "-89.10"
     self.assertEqual(-89.1, dummy_vcfgenotypeinfo.genotype_confidence)
コード例 #2
0
 def test_fill_unfiltered_reads_counts(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     ns_test._fill_unfiltered_reads_counts('0,64,12', genotype_to_fill)
     self.assertEqual(3, len(genotype_to_fill.alleles))
     self.assertEqual(0, genotype_to_fill.alleles[0].unfiltered_read_counts)
     self.assertEqual(64,
                      genotype_to_fill.alleles[1].unfiltered_read_counts)
     self.assertEqual(12,
                      genotype_to_fill.alleles[2].unfiltered_read_counts)
コード例 #3
0
 def test_filter_passing_reads_count_setter(self):
     dummy_vcfgenotypeinfo = ns_test.VCFGenotypeInfo('')
     dummy_vcfgenotypeinfo.filter_passing_reads_count = "42"
     self.assertEqual(42, dummy_vcfgenotypeinfo.filter_passing_reads_count)
     dummy_vcfgenotypeinfo.filter_passing_reads_count = 0
     self.assertEqual(0, dummy_vcfgenotypeinfo.filter_passing_reads_count)
     dummy_vcfgenotypeinfo.filter_passing_reads_count = "."
     self.assertEqual(None,
                      dummy_vcfgenotypeinfo.filter_passing_reads_count)
コード例 #4
0
 def test_fill_unfiltered_reads_counts_warn(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     with warnings.catch_warnings(record=True) as w:
         genotype_to_fill = ns_test._fill_unfiltered_reads_counts(
             '0;64', genotype_to_fill)
         self.assertEqual(
             "The AD tag value 0;64 does not split into at least two values so unfiltered allele depth"
             " information could not be captured for the current variant.",
             _help_get_warn_msg(w))
         self.assertEqual(0, len(genotype_to_fill.alleles)
                          )  # no alleles created if AD tag splits wrong
コード例 #5
0
 def test_fill_genotype_warn(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     with warnings.catch_warnings(record=True) as w:
         genotype_to_fill = ns_test._fill_genotype('1/0/2',
                                                   genotype_to_fill)
         self.assertEqual(
             "The GT tag value 1/0/2 does not split into exactly two values so genotype information "
             "could not be captured for the current variant.",
             _help_get_warn_msg(w))
         self.assertIsNone(genotype_to_fill.genotype
                           )  # no genotype created if GT tag splits wrong
コード例 #6
0
 def test_fill_genotype_likelihoods_warn_too_many_alleles_implied(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     genotype_to_fill.alleles = [
         ns_test.Allele(10),
         ns_test.Allele(11),
         ns_test.Allele(12)
     ]
     with warnings.catch_warnings(record=True) as w:
         genotype_to_fill = ns_test._fill_genotype_likelihoods(
             '495,162,123,213,129,175,67,0,46,28.1', genotype_to_fill)
         self.assertEqual(
             "The PL tag value 495,162,123,213,129,175,67,0,46,28.1 appears to contain information for "
             "more alleles than expected so 'normalized' Phred-scaled likelihoods of possible genotypes"
             " information could not be captured for the current variant.",
             _help_get_warn_msg(w))
         self.assertEqual(0, len(genotype_to_fill.genotype_likelihoods)
                          )  # no likelihoods made if PL splits wrong
コード例 #7
0
 def test_fill_genotype_likelihoods_no_alleles(self):
     expected_values = [(0, 0, 495), (0, 1, 162), (1, 1, 123)]
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     self.assertEqual(0, len(genotype_to_fill.alleles))
     ns_test._fill_genotype_likelihoods('495,162,123', genotype_to_fill)
     self.assertEqual(2, len(
         genotype_to_fill.alleles))  # should have added two
     self.assertEqual(len(expected_values),
                      len(genotype_to_fill.genotype_likelihoods))
     for index in range(0, len(expected_values)):
         curr_expected_values = expected_values[index]
         real_values = genotype_to_fill.genotype_likelihoods[index]
         self.assertEqual(curr_expected_values[0],
                          real_values.allele1_number)
         self.assertEqual(curr_expected_values[1],
                          real_values.allele2_number)
         self.assertEqual(curr_expected_values[2],
                          real_values.likelihood_neg_exponent)
コード例 #8
0
 def test_fill_genotype_likelihoods_three_alleles(self):
     expected_values = [(0, 0, 495), (0, 1, 162), (1, 1, 123), (0, 2, 213),
                        (1, 2, 129), (2, 2, 175), (0, 3, 67), (1, 3, 0),
                        (2, 3, 46), (3, 3, 28.1)]
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     genotype_to_fill.alleles = [
         ns_test.Allele(10),
         ns_test.Allele(11),
         ns_test.Allele(12),
         ns_test.Allele(13)
     ]
     ns_test._fill_genotype_likelihoods(
         '495,162,123,213,129,175,67,0,46,28.1', genotype_to_fill)
     self.assertEqual(len(expected_values),
                      len(genotype_to_fill.genotype_likelihoods))
     for index in range(0, len(expected_values)):
         curr_expected_values = expected_values[index]
         real_values = genotype_to_fill.genotype_likelihoods[index]
         self.assertEqual(curr_expected_values[0],
                          real_values.allele1_number)
         self.assertEqual(curr_expected_values[1],
                          real_values.allele2_number)
         self.assertEqual(curr_expected_values[2],
                          real_values.likelihood_neg_exponent)
コード例 #9
0
 def test_fill_genotype_confidence(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     ns_test._fill_genotype_confidence('44.1', genotype_to_fill)
     self.assertEqual(44.1, genotype_to_fill.genotype_confidence)
コード例 #10
0
 def test_fill_filtered_reads_count(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     ns_test._fill_filtered_reads_count('44', genotype_to_fill)
     self.assertEqual(44, genotype_to_fill.filter_passing_reads_count)
コード例 #11
0
 def test_filter_passing_reads_count_setter_error(self):
     dummy_vcfgenotypeinfo = ns_test.VCFGenotypeInfo('')
     with self.assertRaises(ValueError):
         dummy_vcfgenotypeinfo.filter_passing_reads_count = -1
     with self.assertRaises(ValueError):
         dummy_vcfgenotypeinfo.filter_passing_reads_count = 48.5
コード例 #12
0
 def test_genotype_confidence_setter_error(self):
     dummy_vcfgenotypeinfo = ns_test.VCFGenotypeInfo('')
     with self.assertRaises(ValueError):
         dummy_vcfgenotypeinfo.genotype_confidence = "blue"
コード例 #13
0
 def test_fill_genotype(self):
     genotype_to_fill = ns_test.VCFGenotypeInfo('')
     ns_test._fill_genotype('0/2', genotype_to_fill)
     self.assertEqual('0/2', genotype_to_fill.genotype)