本文整理汇总了Python中oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator.createMutations方法的典型用法代码示例。如果您正苦于以下问题:Python VcfInputMutationCreator.createMutations方法的具体用法?Python VcfInputMutationCreator.createMutations怎么用?Python VcfInputMutationCreator.createMutations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator
的用法示例。
在下文中一共展示了VcfInputMutationCreator.createMutations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDuplicateAnnotation
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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")
示例2: testSNPsAndIndelStartAndEndPos
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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"]))
示例3: testSampleNameSelectorWithVCF
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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")
示例4: testNumberGRenderingOfRandomVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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()
示例5: testSwitchedFieldsWithExampleVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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)
示例6: testAnnotationWithDuplicateValuesInVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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()
示例7: testSimpleAnnotationWithAComplexVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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()
示例8: testSimpleAnnotationWithExampleVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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()
示例9: testOverwriteAnnotationsSupported
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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)
示例10: testFailureWithSpanningDeletion
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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
示例11: testTCGAMAFRendering
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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)
示例12: testSuccesseWithSpanningDeletion
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
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))
示例13: testAnnotationWithExampleVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
def testAnnotationWithExampleVcf(self):
"""
Tests whether parsed annotations match the actual annotations in a simple TSV. Missing format fields yield -->"" ".,." --> ","
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.vcf"])
outputFilename = os.path.join("out", "example.out.tsv")
expectedOutputFilename = os.path.join(*["testdata", "vcf", "example.expected.out.tsv"])
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename)
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
tsvReader = GenericTsvReader(outputFilename)
current = pandas.read_csv(outputFilename, sep='\t', header=len(tsvReader.getCommentsAsList()))
expected = pandas.read_csv(expectedOutputFilename, sep='\t')
currentColNames = set()
for i in range(len(current.columns)):
currentColNames.add(current.columns[i])
expectedColNames = set()
for i in range(len(expected.columns)):
expectedColNames.add(expected.columns[i])
self.assertTrue(len(currentColNames.symmetric_difference(expectedColNames)) is 0,
"Should have the same columns")
self.assertTrue(len(current.index) == len(expected.index), "Should have the same number of rows")
for colName in currentColNames:
self.assertTrue(sum((current[colName] == expected[colName]) | (pandas.isnull(current[colName]) &
pandas.isnull(expected[colName]))) ==
len(current.index), "Should have the same values in column " + colName + ": \n" +
str(current[colName]) + "\nvs\n" + str(expected[colName]))
示例14: testBasicCreationWithExampleVcf
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
def testBasicCreationWithExampleVcf(self):
"""
Tests the ability to parse an input VCF file can be parsed without any errors.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.vcf"])
creator = VcfInputMutationCreator(inputFilename)
muts = creator.createMutations()
# You cannot use len(muts), since muts is a generator.
ctr = 0
for m in muts:
ctr += 1
self.assertTrue(ctr == 27, "Should have seen 27 (# REF alleles x # samples) mutations, but saw: " + str(ctr))
self.assertTrue((m.chr == "21") and (m.start == 1234569), "Last mutation was not correct: " + str(m))
# Reminder: muts is a generator, so it has to be reset
creator.reset()
muts = creator.createMutations()
ctr = 0
for m in muts:
ctr += 1
self.assertTrue(ctr == 27, "Should have seen 27 called mutations, but saw: " + str(ctr))
示例15: testMissingFilter
# 需要导入模块: from oncotator.input.VcfInputMutationCreator import VcfInputMutationCreator [as 别名]
# 或者: from oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator import createMutations [as 别名]
def testMissingFilter(self):
"""
Tests that the missing FILTER fields are parsed correctly.
"""
inputFilename = os.path.join(*["testdata", "vcf", "example.missing_filters.vcf"])
outputFilename = os.path.join("out", "example.missing_filters.out.tsv")
expectedOutputFilename = os.path.join(*["testdata", "vcf", "example.expected.missing_filters.out.tsv"])
creator = VcfInputMutationCreator(inputFilename)
creator.createMutations()
renderer = SimpleOutputRenderer(outputFilename)
annotator = Annotator()
annotator.setInputCreator(creator)
annotator.setOutputRenderer(renderer)
annotator.annotate()
tsvReader = GenericTsvReader(outputFilename)
current = pandas.read_csv(outputFilename, sep='\t', header=len(tsvReader.getCommentsAsList()))
expected = pandas.read_csv(expectedOutputFilename, sep='\t')
currentColNames = set()
for i in range(len(current.columns)):
currentColNames.add(current.columns[i])
expectedColNames = set()
for i in range(len(expected.columns)):
expectedColNames.add(expected.columns[i])
self.assertTrue(len(currentColNames.symmetric_difference(expectedColNames)) is 0,
"Should have the same columns")
self.assertTrue(len(current.index) == len(expected.index), "Should have the same number of rows")
for colName in currentColNames:
self.assertTrue(sum((current[colName] == expected[colName]) | (pandas.isnull(current[colName]) &
pandas.isnull(expected[colName]))) ==
len(current.index), "Should have the same values in column " + colName)