コード例 #1
0
    def test_read_sample_data(self):
        schema = self.__get_example_schema("vcf_example.vcf")
        sample_schema = [key for key, _ in schema.iter_sample_data()]

        sample_data = SampleData(sample_schema, ['sample1'])

        sample_data.add_sample_data("sample1", "GT", GenotypeCall("1|0"))
        sample_data.add_sample_data("sample1", "PL", [3000, 0, 3000])
        sample_data.add_sample_data("sample1", "GQ", [1000])
        sample_data.add_sample_data("sample1", "PQ", [2000])
        sample_data.add_sample_data("sample1", "PS", [60000])
        sample_data.add_sample_data("sample1", "AD", [140, 110])
        sample_data.add_sample_data("sample1", "DP", [250])
        sample_data.add_sample_data("sample1", "VAF", [0.4])

        self.assertTrue(sample_data.has_sample("sample1"))
        self.assertEqual(sample_data.genotypes(),
                         {"sample1": GenotypeCall("1|0")})
        self.assertEqual(sample_data.get_field("sample1", 'GT'),
                         GenotypeCall("1|0"))
        self.assertEqual(sample_data.get_field("sample1", 'PL'),
                         [3000, 0, 3000])

        genotype_data = sample_data.get_genotype_data("sample1")
        self.assertEqual(genotype_data.genotype(), GenotypeCall("1|0"))
        self.assertEqual(genotype_data['GT'], GenotypeCall("1|0"))
        self.assertEqual(genotype_data['PL'], [3000, 0, 3000])
コード例 #2
0
    def test_should_return_default_diploid_genotype(self):
        sample_data = SampleData(['GT', 'GL'], ["NA12878"])

        self.assertEqual(GenotypeCall("./."), GenotypeCall("./."))

        self.assertTrue(sample_data.has_sample("NA12878"))
        self.assertEqual(sample_data.genotypes(),
                         {"NA12878": GenotypeCall("./.")})
        self.assertEqual(sample_data.get_field("NA12878", 'GT'),
                         GenotypeCall("./."))
        self.assertEqual(sample_data.get_field("NA12878", 'GL'), [])

        genotype_data = sample_data.get_genotype_data("NA12878")
        self.assertEqual(genotype_data.genotype(), GenotypeCall("./."))
        self.assertEqual(genotype_data['GT'], GenotypeCall("./."))
        self.assertEqual(genotype_data['GL'], [])
コード例 #3
0
 def test_has_sample_reports_expected_value(self):
     sample_data = SampleData(['key1'], ['sample_name'])
     self.assertTrue(sample_data.has_sample('sample_name'))
     self.assertFalse(sample_data.has_sample('missing_sample_name'))