本文整理汇总了Python中oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator类的典型用法代码示例。如果您正苦于以下问题:Python VcfInputMutationCreator类的具体用法?Python VcfInputMutationCreator怎么用?Python VcfInputMutationCreator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VcfInputMutationCreator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSNPsAndIndelStartAndEndPos
def testSNPsAndIndelStartAndEndPos(self):
"""
Tests that the start and end positions of SNPs and Indels are parsed as defined by the NCI's MAF specification
(https://wiki.nci.nih.gov/display/TCGA/Mutation+Annotation+Format+(MAF)+Specification).
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.snps.indels.vcf"])
outputFilename = os.path.join("out", "example.snps.indels.out.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename)
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
tsvReader = GenericTsvReader(outputFilename)
for row in tsvReader:
if row['start'] == "16890445":
self.assertEqual(row["end"], "16890445", "The value should be %s but it was %s." % ("16890445",
row["end"]))
elif row["start"] == "154524458":
self.assertEqual(row["end"], "154524459", "The value should be %s but it was %s." % ("154524459",
row["end"]))
elif row["start"] == "114189432":
self.assertEqual(row["end"], "114189433", "The value should be %s but it was %s." % ("114189433",
row["end"]))
示例2: testDuplicateAnnotation
def testDuplicateAnnotation(self):
"""
Tests that the duplicate annotations are parsed correctly.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.duplicate_annotation.vcf"])
outputFilename = os.path.join("out", "example.duplicate_annotation.out.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename)
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
tsvReader = GenericTsvReader(outputFilename)
fieldnames = tsvReader.getFieldNames()
self.assertTrue("variant_status" in fieldnames, "variant_status field is missing in the header.")
self.assertTrue("sample_variant_status" in fieldnames, "sample_variant_status is missing in the header.")
row = tsvReader.next()
self.assertTrue("variant_status" in row, "variant_status field is missing in the row.")
self.assertTrue("sample_variant_status" in row, "sample_variant_status is missing in the row.")
self.assertEqual("2", row["variant_status"], "Incorrect value of variant_status.")
self.assertEqual("0", row["sample_variant_status"], "Incorrect value of sample_variant_status")
示例3: testFailureWithSpanningDeletion
def testFailureWithSpanningDeletion(self):
"""Fail with a spanning deletion unless alternates are being ignored."""
inputFilename = os.path.join(*["testdata", "simple_vcf_spanning_deletion.vcf"])
vcf_input = VcfInputMutationCreator(inputFilename, MutationDataFactory(allow_overwriting=True))
muts = vcf_input.createMutations()
ctr = 0
for m in muts:
ctr += 1
示例4: testSampleNameSelectorWithVCF
def testSampleNameSelectorWithVCF(self):
input = VcfInputMutationCreator("testdata/vcf/example.1row.vcf")
first_mut = next(input.createMutations())
s = SampleNameSelector(first_mut)
expected = ["NA 00001", "NA 00002", "NA 00003"]
for mut in input.createMutations():
self.assertIn(s.getSampleName(mut), expected)
self.assertEqual(s.getAnnotationSource(), "INPUT")
self.assertEquals(s.getOutputAnnotationName(), "sample_name")
示例5: testNumberGRenderingOfRandomVcf
def testNumberGRenderingOfRandomVcf(self):
inputFilename = os.path.join(*["testdata", "vcf", "number_g.random.vcf"])
outputFilename = os.path.join("out", "number_g.random.out.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename)
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
示例6: testDuplicateAnnotationMetaData
def testDuplicateAnnotationMetaData(self):
"""
Tests that the metadata is populated correctly in cases where duplicate annotations are present in the input VCF
file.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.duplicate_annotation.vcf"])
creator = VcfInputMutationCreator(inputFilename)
md = creator.getMetadata()
self.assertTrue("variant_status" in md, "variant_status field is missing in metadata.")
self.assertTrue("sample_variant_status" in md, "sample_variant_status is missing in metadata.")
示例7: testSwitchedFieldsWithExampleVcf
def testSwitchedFieldsWithExampleVcf(self):
"""
Tests whether the switched tags are ignored.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.bad.switched.fields.vcf"])
outputFilename = os.path.join("out", "example.switched.out.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename, [])
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
示例8: testSuccesseWithSpanningDeletion
def testSuccesseWithSpanningDeletion(self):
"""Succeed with a spanning deletion since alternates are being ignored."""
inputFilename = os.path.join(*["testdata", "simple_vcf_spanning_deletion.vcf"])
other_options = {InputMutationCreatorOptions.IS_SKIP_ALTS: True}
vcf_input = VcfInputMutationCreator(inputFilename, MutationDataFactory(allow_overwriting=True),
other_options=other_options)
muts = vcf_input.createMutations()
ctr = 0
for m in muts:
ctr += 1
self.assertTrue(ctr == 1, "There should only have been one mutation seen, instead saw: " + str(ctr))
示例9: testAnnotationWithDuplicateValuesInVcf
def testAnnotationWithDuplicateValuesInVcf(self):
"""
Tests the ability to parse a VCF that contains an INFO, FILTER, and INFO field with the same name.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.duplicate_fields.vcf"])
outputFilename = os.path.join("out", "example.duplicate_fields2.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename, [])
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
示例10: testGetMetaDataWithNoSampleNameExampleVcf
def testGetMetaDataWithNoSampleNameExampleVcf(self):
"""
Tests to ensure that the metadata can be retrieved even before createMutations has been called.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.sampleName.removed.vcf"])
creator = VcfInputMutationCreator(inputFilename)
gtKeys = {'genotype', 'read_depth', 'genotype_quality', 'haplotype_quality', 'q10', 's50', 'samples_number',
'depth_across_samples', 'allele_frequency', 'ancestral_allele', 'dbSNP_membership', 'id', 'qual',
'hapmap2_membership'}
md = creator.getMetadata()
ks = set(md.keys())
diff = gtKeys.symmetric_difference(ks)
self.assertTrue(len(diff) == 0, "Missing keys that should have been seen in the metadata: " + str(diff))
示例11: testSimpleAnnotationWithAComplexVcf
def testSimpleAnnotationWithAComplexVcf(self):
"""
Tests the ability to parse a rather complex VCF file without any errors.
"""
inputFilename = os.path.join(*["testdata", "vcf", "random.vcf"])
outputFilename = os.path.join("out", "random.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename, [])
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
示例12: testSimpleAnnotationWithExampleVcf
def testSimpleAnnotationWithExampleVcf(self):
"""
Tests the ability to do a simple Gaf 3.0 annotation.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.vcf"])
outputFilename = os.path.join("out", "simpleVCF.Gaf.annotated.out.tsv")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename, [])
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.addDatasource(TestUtils.createTranscriptProviderDatasource(self.config))
annotator.annotate()
示例13: testGenotypeFieldIsHonored
def testGenotypeFieldIsHonored(self):
"""
Tests that no issues arise with genotype values >1 when multiple variants appear on one line.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.severalGTs.vcf"])
creator = VcfInputMutationCreator(inputFilename)
muts = creator.createMutations()
ctr = 0
for mut in muts:
if MutUtils.str2bool(mut["alt_allele_seen"]):
self.assertTrue(mut['sample_name'] != "NA 00001")
ctr += 1
self.assertTrue(ctr == 7,
str(ctr) + " mutations with alt seen, but expected 7. './.' should not show as a variant.")
示例14: testOverwriteAnnotationsSupported
def testOverwriteAnnotationsSupported(self):
"""Test that mutations support overwrite annotation in the VCFInputMutationCreator. (white box testing)"""
inputFilename = os.path.join(*["testdata", "vcf", "example.trailing_whitespace_in_alleles.vcf"])
vcf_overwriting_disallowed = VcfInputMutationCreator(inputFilename, MutationDataFactory())
vcf_overwriting_allowed = VcfInputMutationCreator(inputFilename, MutationDataFactory(allow_overwriting=True))
mutations = vcf_overwriting_disallowed.createMutations()
for m in mutations:
self.assertTrue(m._new_required)
mutations = vcf_overwriting_allowed.createMutations()
for m in mutations:
self.assertFalse(m._new_required)
示例15: testTCGAMAFRendering
def testTCGAMAFRendering(self):
"""
Tests the ability to render a germline VCF file as a TCGA MAF file.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.vcf"])
outputFilename = os.path.join("out", "example.vcf.maf.annotated")
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = TcgaMafOutputRenderer(outputFilename)
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.setManualAnnotations(self._createTCGAMAFOverridesForVCF())
datasources = self._createDatasourceCorpus()
for ds in datasources:
annotator.addDatasource(ds)
filename = annotator.annotate()
self._validateTcgaMafContents(filename)