Exemplo n.º 1
0
    def test_SomaticTagSS_metaheaders(self):
        vcf_reader = MockVcfReader(
            metaheaders=["##foo", "##MuTect=123", '##FORMAT=<ID=FA,...>'])
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        metaheaders = mutect_vcf_reader.metaheaders

        self.assertIn(mutect._SomaticTagSS().metaheader, metaheaders)
Exemplo n.º 2
0
    def test_vcf_records_newTagsPresent(self):
        record1 = vcf.VcfRecord(chrom="chr1",
                                pos="21",
                                ref="A",
                                alt="G",
                                sample_tag_values={"sampleA": {"DP": "45"},
                                                   "sampleB": {"DP": "67"}})
        record2 = vcf.VcfRecord(chrom="chr1",
                                pos="22",
                                ref="A",
                                alt="G",
                                sample_tag_values={"sampleA": {"FA": "0.54"},
                                                   "sampleB": {"FA": "0.76"}})
        vcf_reader = MockVcfReader(records=[record1, record2])

        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        vcf_records = [record for record in mutect_vcf_reader.vcf_records()]

        self.assertEquals(2, len(vcf_records))

        self.assertIn("DP", vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "DP", vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "HC_SOM", vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_REPORTED", vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_PASSED", vcf_records[0].format_tags)

        self.assertIn("FA", vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "AF", vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "HC_SOM", vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_REPORTED", vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_PASSED", vcf_records[1].format_tags)
Exemplo n.º 3
0
    def test_open_and_close(self):
        vcf_reader = MockVcfReader(metaheaders=["##foo", "##MuTect=123"])
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        mutect_vcf_reader.open()
        mutect_vcf_reader.close()

        self.assertTrue(mutect_vcf_reader.open)
        self.assertTrue(mutect_vcf_reader.close)
Exemplo n.º 4
0
    def test_open_and_close(self):
        vcf_reader = MockVcfReader(
            metaheaders=["##foo", "##MuTect=123", '##FORMAT=<ID=FA,...>'])
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        mutect_vcf_reader.open()
        mutect_vcf_reader.close()

        self.assertTrue(mutect_vcf_reader.open)
        self.assertTrue(mutect_vcf_reader.close)
Exemplo n.º 5
0
    def test_SomaticTagFilterMutectCalls_metaheaders(self):
        vcf_reader = MockVcfReader(metaheaders=[
            "##foo", "##MuTect=123", '##FORMAT=<ID=FA,...>',
            "##source=FilterMutectCalls"
        ])
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        metaheaders = mutect_vcf_reader.metaheaders

        self.assertIn(mutect._SomaticTagFilterMutectCalls().metaheader,
                      metaheaders)
Exemplo n.º 6
0
    def test_column_header_mangleSampleNameMutect2IgnoresHelpFlag(self):
        column_header = self.entab("#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|25714|25715")
        meta_header = '##GATKCommandLine=<ID=Mutect2,CommandLine="Mutect2  --tumor-sample 25715 --normal-sample 25714 --help false",Date="recent">'
        vcf_reader = MockVcfReader(metaheaders=[meta_header],
                                   column_header=column_header)
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)

        expected_column_header = self.entab("#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|NORMAL|TUMOR")

        self.assertEquals(expected_column_header, mutect_vcf_reader.column_header)
Exemplo n.º 7
0
    def test_column_header_mangleSampleNameMutect1(self):
        column_header = self.entab("#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|25714|25715")
        meta_header = '##MuTect="123 tumor_sample_name=25715 normal_sample_name=25714"'
        vcf_reader = MockVcfReader(metaheaders=[meta_header],
                                   column_header=column_header)
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)

        expected_column_header = self.entab("#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|NORMAL|TUMOR")

        self.assertEquals(expected_column_header, mutect_vcf_reader.column_header)
Exemplo n.º 8
0
    def test_metaheaders(self):
        vcf_reader = MockVcfReader(metaheaders=["##foo", "##MuTect=123"])
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        metaheaders = mutect_vcf_reader.metaheaders

        self.assertIn(mutect._AlleleFreqTag().metaheader, metaheaders)
        self.assertIn(mutect._DepthTag().metaheader, metaheaders)
        self.assertIn(mutect._SomaticTag().metaheader, metaheaders)
        self.assertIn("##foo", metaheaders)
        self.assertIn("##MuTect=123", metaheaders)
        self.assertIn("##jacquard.translate.caller=MuTect", metaheaders)
Exemplo n.º 9
0
    def test_common_metaheaders(self):
        vcf_reader = MockVcfReader(
            metaheaders=["##foo", "##MuTect=123", '##FORMAT=<ID=FA,...>'])
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        metaheaders = mutect_vcf_reader.metaheaders

        self.assertIn(
            mutect._AlleleFreqTag(vcf_reader.metaheaders).metaheader,
            metaheaders)
        self.assertIn(mutect._DepthTag().metaheader, metaheaders)
        self.assertIn("##foo", metaheaders)
        self.assertIn("##MuTect=123", metaheaders)
        self.assertIn("##jacquard.translate.caller=MuTect", metaheaders)
Exemplo n.º 10
0
    def test_vcf_records_newTagsPresent(self):
        record1 = vcf.VcfRecord(chrom="chr1",
                                pos="21",
                                ref="A",
                                alt="G",
                                sample_tag_values={
                                    "sampleA": {
                                        "DP": "45"
                                    },
                                    "sampleB": {
                                        "DP": "67"
                                    }
                                })
        record2 = vcf.VcfRecord(chrom="chr1",
                                pos="22",
                                ref="A",
                                alt="G",
                                sample_tag_values={
                                    "sampleA": {
                                        "FA": "0.54"
                                    },
                                    "sampleB": {
                                        "FA": "0.76"
                                    }
                                })
        vcf_reader = MockVcfReader(metaheaders=['##FORMAT=<ID=FA,...>'],
                                   records=[record1, record2])

        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)
        vcf_records = [record for record in mutect_vcf_reader.vcf_records()]

        self.assertEquals(2, len(vcf_records))

        self.assertIn("DP", vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "DP", vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "HC_SOM",
                      vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_REPORTED",
                      vcf_records[0].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_PASSED",
                      vcf_records[0].format_tags)

        self.assertIn("FA", vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "AF", vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "HC_SOM",
                      vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_REPORTED",
                      vcf_records[1].format_tags)
        self.assertIn(mutect.JQ_MUTECT_TAG + "CALLER_PASSED",
                      vcf_records[1].format_tags)
Exemplo n.º 11
0
    def test_column_header_mangleSampleNameMutect2UsesSampleMetalinesIfAvailable(self):
        column_header = self.entab("#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|25714|25715")
        meta_header = '''
##GATKCommandLine=<ID=Mutect2,CommandLine="Mutect2  --tumor-sample A --normal-sample B",Date="recent">'
##foo=42
##SAMPLE=<ID=NORMAL,SampleName=25714,File=foo.bam>
##SAMPLE=<ID=TUMOR,SampleName=25715,File=bar.bam>
##baz=42
'''
        vcf_reader = MockVcfReader(metaheaders=meta_header.strip().split('\n'),
                                   column_header=column_header)
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)

        expected_column_header = self.entab("#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|NORMAL|TUMOR")

        self.assertEquals(expected_column_header, mutect_vcf_reader.column_header)
Exemplo n.º 12
0
    def test_column_header_mangleSampleNameMutect2IgnoresHelpFlag(self):
        column_header = self.entab(
            "#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|25714|25715")
        metaheaders = [
            '##GATKCommandLine=<ID=Mutect2,CommandLine="Mutect2  --tumor-sample 25715 --normal-sample 25714 --help false",Date="recent">',
            '##FORMAT=<ID=FA,...>',
        ]
        vcf_reader = MockVcfReader(metaheaders=metaheaders,
                                   column_header=column_header)

        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)

        expected_column_header = self.entab(
            "#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|NORMAL|TUMOR")

        self.assertEquals(expected_column_header,
                          mutect_vcf_reader.column_header)
Exemplo n.º 13
0
    def test_column_header_mangleSampleNameMutect1(self):
        column_header = self.entab(
            "#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|25714|25715")
        metaheaders = [
            '##MuTect="123 tumor_sample_name=25715 normal_sample_name=25714"',
            '##FORMAT=<ID=FA,...>',
        ]
        vcf_reader = MockVcfReader(metaheaders=metaheaders,
                                   column_header=column_header)

        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)

        expected_column_header = self.entab(
            "#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|NORMAL|TUMOR")

        self.assertEquals(expected_column_header,
                          mutect_vcf_reader.column_header)
Exemplo n.º 14
0
    def test_column_header_mangleSampleNameMutect2UsesSampleMetalinesIfAvailable(
            self):
        column_header = self.entab(
            "#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|25714|25715")
        meta_header = '''
##GATKCommandLine=<ID=Mutect2,CommandLine="Mutect2  --tumor-sample A --normal-sample B",Date="recent">'
##FORMAT=<ID=FA,...>
##foo=42
##SAMPLE=<ID=NORMAL,SampleName=25714,File=foo.bam>
##SAMPLE=<ID=TUMOR,SampleName=25715,File=bar.bam>
##baz=42
'''
        vcf_reader = MockVcfReader(metaheaders=meta_header.strip().split('\n'),
                                   column_header=column_header)
        mutect_vcf_reader = mutect._MutectVcfReader(vcf_reader)

        expected_column_header = self.entab(
            "#CHROM|POS|ID|REF|ALT|QUAL|FILTER|INFO|FORMAT|NORMAL|TUMOR")

        self.assertEquals(expected_column_header,
                          mutect_vcf_reader.column_header)