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)
def test_filterPassSomeSamplesPhasedVariants(self): tag = mutect._SomaticTagFilterMutectCalls() line = 'CHROM^POS^ID^REF^ALT^QUAL^PASS^INFO^F1:F2:F3:GT^SA.1:SA.2:SA.3:0|0^SB.1:SB.2:SB.3:0|1\n'.replace( '^', '\t') expected = 'CHROM^POS^ID^REF^ALT^QUAL^PASS^INFO^F1:F2:F3:GT:{0}HC_SOM^SA.1:SA.2:SA.3:0|0:0^SB.1:SB.2:SB.3:0|1:1\n'\ .replace('^', '\t')\ .format(mutect.JQ_MUTECT_TAG) processedVcfRecord = vcf.VcfRecord.parse_record(line, ["SA", "SB"]) tag.add_tag_values(processedVcfRecord) self.assertEquals(expected, processedVcfRecord.text())
def test_filterPassSomeSamplesVariants(self): tag = mutect._SomaticTagFilterMutectCalls() line = self.entab(\ 'CHROM|POS|ID|REF|ALT|QUAL|PASS|INFO|F1:F2:F3:GT|SA.1:SA.2:SA.3:0/0|SB.1:SB.2:SB.3:0/1\n') expected = self.entab(\ 'CHROM|POS|ID|REF|ALT|QUAL|PASS|INFO|F1:F2:F3:GT:{0}HC_SOM|SA.1:SA.2:SA.3:0/0:0|SB.1:SB.2:SB.3:0/1:1\n'\ ).format(mutect.JQ_MUTECT_TAG) processedVcfRecord = vcf.VcfRecord.parse_record(line, ["SA", "SB"]) tag.add_tag_values(processedVcfRecord) self.assertEquals(expected, processedVcfRecord.text())
def test_filterFailNotSomatic(self): tag = mutect._SomaticTagFilterMutectCalls() line = self.entab(\ 'CHROM|POS|ID|REF|ALT|QUAL|filter_failed|INFO|F1:F2:F3|SA.1:SA.2:SA.3|SB.1:SB.2:SB.3\n') expected = self.entab(\ 'CHROM|POS|ID|REF|ALT|QUAL|filter_failed|INFO|F1:F2:F3:{0}HC_SOM|SA.1:SA.2:SA.3:0|SB.1:SB.2:SB.3:0\n'\ ).format(mutect.JQ_MUTECT_TAG) processedVcfRecord = vcf.VcfRecord.parse_record(line, ["SA", "SB"]) tag.add_tag_values(processedVcfRecord) self.assertEquals(expected, processedVcfRecord.text())
def test_filterPassMissingGenotype(self): tag = mutect._SomaticTagFilterMutectCalls() line = self.entab(\ 'chrQ|42|ID|A|G|QUAL|PASS|INFO|F1:F2:F3|SA.1:SA.2:SA.3|SB.1:SB.2:SB.3\n') expected = self.entab(\ 'chrQ|42|ID|A|G|QUAL|PASS|INFO|F1:F2:F3:{0}HC_SOM|SA.1:SA.2:SA.3:0|SB.1:SB.2:SB.3:0\n'\ ).format(mutect.JQ_MUTECT_TAG) processedVcfRecord = vcf.VcfRecord.parse_record(line, ["SA", "SB"]) self.assertRaisesRegexp( utils.JQException, r'Cannot assign somatic status using FilterMutectCalls.*chrQ:42:A:G', tag.add_tag_values, processedVcfRecord)
def test_metaheader(self): self.assertEqual(\ '''##FORMAT=<ID={0}HC_SOM,Number=1,Type=Integer,Description="Jacquard somatic status for MuTect: 0=non-somatic,1=somatic (based on FilterMutectCalls setting filter to PASS)">'''.replace('\n', '').format(mutect.JQ_MUTECT_TAG), mutect._SomaticTagFilterMutectCalls().metaheader)