本文整理汇总了Python中oncotator.MutationDataFactory.MutationDataFactory类的典型用法代码示例。如果您正苦于以下问题:Python MutationDataFactory类的具体用法?Python MutationDataFactory怎么用?Python MutationDataFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MutationDataFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_collapse
def test_simple_collapse(self):
"""Ensure simple rules for numeric collapsing are honored"""
m1 = MutationDataFactory.default_create(chr="1", start="10000", end="10000")
m1.createAnnotation('ALT_F2R1', "34|36")
m1.createAnnotation('i_t_Foxog', ".509|.511")
m1.createAnnotation('i_tumor_f', ".200|.210")
m1.createAnnotation('hamilcar', "0|0")
m1.createAnnotation('donotcollapse', "1|45")
m2 = MutationDataFactory.default_create(chr="1", start="10000", end="10000")
m2.createAnnotation('ALT_F2R1', "36|38")
m2.createAnnotation('i_t_Foxog', ".500|.510")
m2.createAnnotation('i_tumor_f', ".100|.110")
m2.createAnnotation('hamilcar', "0.01|0")
m2.createAnnotation('barca', "0.02|0")
m2.createAnnotation('donotcollapse', "100|4500")
cc = ColumnCollapser()
cc.update_mutation(m1)
self.assertEqual(m1['ALT_F2R1'], "34")
self.assertEqual(float(m1['i_t_Foxog']), float(".510"))
self.assertEqual(float(m1['i_tumor_f']), float(".205"))
self.assertEqual(float(m1['hamilcar']), float("0"))
self.assertEqual(m1['donotcollapse'], "1|45")
cc.update_mutation(m2)
self.assertEqual(m2['ALT_F2R1'], "36")
self.assertEqual(float(m2['i_t_Foxog']), float(".505"))
self.assertEqual(float(m2['i_tumor_f']), float(".105"))
self.assertEqual(float(m2['hamilcar']), float("0.005"))
self.assertEqual(float(m2['barca']), float("0.01"))
self.assertEqual(m2['donotcollapse'], "100|4500")
示例2: initializeMutFromAttributes
def initializeMutFromAttributes(chr, start, end, ref_allele, alt_allele, build, mutation_data_factory=None):
mutation_data_factory = MutationDataFactory() if mutation_data_factory is None else mutation_data_factory
mut = mutation_data_factory.create(str(chr), str(start), str(end), ref_allele, alt_allele, str(build))
varType = TranscriptProviderUtils.infer_variant_type(mut.ref_allele, mut.alt_allele)
if TranscriptProviderUtils.is_xnp(varType): # Snps and other xNPs
mut.createAnnotation(annotationName=MutUtils.PRECEDING_BASES_ANNOTATION_NAME, annotationValue="")
if varType == VariantClassification.VT_DEL: # deletion
preceding_bases, updated_ref_allele, updated_start, updated_end =\
MutUtils.retrievePrecedingBasesForDeletions(mut)
mut.ref_allele = updated_ref_allele
mut["ref_allele"] = updated_ref_allele
mut.alt_allele = "-"
mut["alt_allele"] = "-"
mut.start = updated_start
mut["start"] = updated_start
mut.end = updated_end
mut["end"] = updated_end
mut.createAnnotation(annotationName=MutUtils.PRECEDING_BASES_ANNOTATION_NAME,
annotationValue=preceding_bases)
elif varType == VariantClassification.VT_INS: # insertion
preceding_bases, updated_alt_allele, updated_start, updated_end = \
MutUtils.retrievePrecedingBasesForInsertions(mut)
mut.ref_allele = "-"
mut["ref_allele"] = "-"
mut.alt_allele = updated_alt_allele
mut["alt_allele"] = updated_alt_allele
mut.start = updated_start
mut["start"] = updated_start
mut.end = updated_end
mut["end"] = updated_end
mut.createAnnotation(annotationName=MutUtils.PRECEDING_BASES_ANNOTATION_NAME,
annotationValue=preceding_bases)
return mut
示例3: test_continuous_exons_in_segments
def test_continuous_exons_in_segments(self):
"""Test that all exons are accounted when annotating adjacent segments that skip an exon. """
# SPECC1L 10+ 22 24734447 SPECC1L 10+ 41783674 TEF 1- 1215.0 -0.04975556624325125 hg19 CESC.TCGA.BI.A0VR.Tumor.SM.1RACM
# SPECC1L 8- 22 16282318 POTEH 2- 24730543 SPECC1L 8- 433.0 -0.00781166374668759 hg19 CESC.TCGA.BI.A0VR.Tumor.SM.1RACM
# SPECC1L-ADORA2A 22 24734447 SPECC1L 10+ 41783674 TEF 1- 1215.0 -0.04975556624325125 hg19 CESC.TCGA.BI.A0VR.Tumor.SM.1RACM
seg1 = MutationDataFactory.default_create()
seg1.chr = "22"
seg1.start = "24734447" # Just passed the exon 9 (0-based)
seg1.end = "41783674"
seg2 = MutationDataFactory.default_create()
seg2.chr = "22"
seg2.start = "16282318"
seg2.end = "24730543" # Just passed the exon 8 (0-based)
segs = [seg1, seg2]
# 'ENST00000314328.9' for GENCODE v19
chosen_tx, transcript_ds = self._get_chosen_tx_and_transcript_ds(seg1.chr, seg1.start)
result_tuple = transcript_ds._determine_exons_affected_by_start(seg1.start, chosen_tx)
self.assertTrue(result_tuple == (10, '+'))
result_tuple = transcript_ds._determine_exons_affected_by_end(seg2.end, chosen_tx)
self.assertTrue(result_tuple == (8, '-'))
示例4: testRealWorld
def testRealWorld(self):
"""Test that the full COSMIC datasource can retrieve entries by both gp and gpp."""
gafDS = TestUtils.createTranscriptProviderDatasource(self.config)
cosmicDS = TestUtils.createCosmicDatasource(self.config)
# These values are not taken from a real world scenario, but are cooked for this test.
m = MutationDataFactory.default_create()
m.chr = '1'
m.start = '12941796'
m.end = '12941796'
m.ref_allele = "G"
m.alt_allele = "T"
m = gafDS.annotate_mutation(m)
m = cosmicDS.annotate_mutation(m)
self.assertTrue(m['COSMIC_n_overlapping_mutations'] == '0')
#1 150483621 150483621
m = MutationDataFactory.default_create()
m.chr = '1'
m.start = '150483621'
m.end = '150483621'
m.ref_allele = "G"
m.alt_allele = "T"
m = gafDS.annotate_mutation(m)
m = cosmicDS.annotate_mutation(m)
示例5: test_denovo
def test_denovo(self):
"""GAF de novo test """
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
m = MutationDataFactory.default_create()
m.start = str(22221735)
m.end = str(22221737)
m.chr="22"
m.ref_allele = ''
m.alt_allele = 'CAT'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == 'De_novo_Start_OutOfFrame')
m = MutationDataFactory.default_create()
m.start = str(22221735)
m.end = str(22221740)
m.chr="22"
m.ref_allele = ''
m.alt_allele = 'AACATAA'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == 'De_novo_Start_OutOfFrame')
m = MutationDataFactory.default_create()
m.start = str(22221735)
m.end = str(22221739)
m.chr="22"
m.ref_allele = ''
m.alt_allele = 'ACATAA'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['variant_classification'] == 'De_novo_Start_InFrame')
示例6: _simple_annotate
def _simple_annotate(self, is_skip_no_alts):
runSpec = RunSpecification()
runSpec.initialize(None, None, datasources=[], is_skip_no_alts=is_skip_no_alts)
# Initialize the annotator with the runspec
annotator = Annotator()
annotator.initialize(runSpec)
m = MutationDataFactory.default_create()
m.chr = "1"
m.start = "12941796"
m.end = "12941796"
m.alt_allele = "G"
m.ref_allele = "T"
m.createAnnotation("alt_allele_seen", "False")
m2 = MutationDataFactory.default_create()
m2.chr = "1"
m2.start = "12941796"
m2.end = "12941796"
m2.alt_allele = "G"
m2.ref_allele = "T"
muts = [m, m2]
muts = annotator.annotate_mutations(muts)
ctr = 0
for m in muts:
ctr += 1
return ctr
示例7: testMulticoreAnnotate
def testMulticoreAnnotate(self):
"""Test a (too) simple annotating exercise from GAF on 2 cores"""
gafDatasource = TestUtils.createGafDatasourceProxy(self.config)
# Test pickling
dump(gafDatasource, file('out/testGAFPickle.pkl','w'))
m1 = MutationDataFactory.default_create()
m1.chr = '3'
m1.start = '178866811'
m1.end = '178866811'
m1.ref_allele = "A"
m1.alt_allele = "C"
m1.build = "hg19"
m2 = MutationDataFactory.default_create()
m2.chr = '3'
m2.start = '178866812'
m2.end = '178866812'
m2.ref_allele = "A"
m2.alt_allele = "C"
m2.build = "hg19"
p = LoggingPool(processes=2)
result = p.map(annotate_mutation_global, [(gafDatasource, m1), (gafDatasource, m2)])
p.close()
p.join()
for r in result:
self.assertTrue("transcript_id" in r.keys())
self.assertTrue("gene" in r.keys())
self.assertTrue(r["gene"] == "PIK3CA")
self.assertTrue(result[0].start != result[1].start)
示例8: test_effect_tx_mode
def test_effect_tx_mode(self):
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
gafDatasource.set_tx_mode(TranscriptProvider.TX_MODE_BEST_EFFECT)
# Canonical mutation was Intron
m = MutationDataFactory.default_create()
m.chr = '2'
m.start = '219137340'
m.end = '219137340'
m.ref_allele = 'G'
m.alt_allele = 'T'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['gene'] == "PNKD")
self.assertTrue(m['variant_classification'] == "Missense_Mutation")
gafDatasource.set_tx_mode(TranscriptProvider.TX_MODE_CANONICAL)
m = MutationDataFactory.default_create()
m.chr = '2'
m.start = '219137340'
m.end = '219137340'
m.ref_allele = 'G'
m.alt_allele = 'T'
m = gafDatasource.annotate_mutation(m)
self.assertTrue(m['gene'] == "PNKD")
self.assertTrue(m['variant_classification'] == "Intron", "Canonical no longer is Intron. This test is no longer valid. This failure can come up when changing the GAF datasource.")
示例9: test_annotation_overwriting_on
def test_annotation_overwriting_on(self):
"""Test that the factory can produce a mutation that allows overwriting. Just need to make sure no exception thrown."""
mdf = MutationDataFactory(allow_overwriting=True)
mut = mdf.create()
mut.createAnnotation("blah", "123")
self.assertTrue(mut['blah'] == "123")
mut.createAnnotation("blah", "456")
self.assertTrue(mut['blah'] == "456")
示例10: test_annotation_overwriting_off
def test_annotation_overwriting_off(self):
"""Test that the factory can produce a mutation that does not allow overwriting. Make sure DuplicateAnnotationException is thrown."""
mdf = MutationDataFactory(allow_overwriting=False)
mut = mdf.create()
mut.createAnnotation("blah", "123")
self.assertTrue(mut['blah'] == "123")
is_exception_raised = False
try:
mut.createAnnotation("blah", "456")
except DuplicateAnnotationException as dae:
is_exception_raised = True
self.assertTrue(is_exception_raised, "DuplicateAnnotationException should have been seen, but wasn't")
示例11: test_mutation_combiner
def test_mutation_combiner(self):
"""Test that attributes and annotations are set properly with combine mutations"""
mut1 = MutationDataFactory.default_create(chr=1,start=100, end=100, ref_allele="G", alt_allele="A")
mut1.createAnnotation("SomeValue", "value1", "INPUT", "STRING", "a value")
mut2 = MutationDataFactory.default_create(chr=1,start=101, end=101, ref_allele="C", alt_allele="T")
mut2.createAnnotation("SomeValue", "value2", tags=["IT"])
mut2.createAnnotation("AnotherValue","5")
mdf = MutationDataFactory()
result = OnpQueue._combine_mutations([mut1, mut2], mdf)
expected = MutationDataFactory.default_create(chr=1, start=100, end=101, ref_allele="GC", alt_allele="AT")
expected.createAnnotation("SomeValue", "value1|value2", "INPUT", "STRING", "a value", tags=["IT"])
expected.createAnnotation("AnotherValue", "5")
self.assertTrue(result.attributesEqual(expected))
self.assertEqual(result, expected)
示例12: test_mutation_combiner_identical_annotation
def test_mutation_combiner_identical_annotation(self):
"""Test that annotations with all identical values are not repeated with | between them"""
mut1 = MutationDataFactory.default_create(chr=1,start=100, end=100, ref_allele="G", alt_allele="A")
mut1.createAnnotation("SampleName", "John Doe")
mut2 = MutationDataFactory.default_create(chr=1,start=101, end=101, ref_allele="C", alt_allele="T")
mut2.createAnnotation("SampleName", "John Doe" )
mdf = MutationDataFactory()
result = OnpQueue._combine_mutations([mut1, mut2], mdf)
expected = MutationDataFactory.default_create(chr=1, start=100, end=101, ref_allele="GC", alt_allele="AT")
expected.createAnnotation("SampleName", "John Doe")
self.assertTrue(result.attributesEqual(expected))
self.assertEqual(result, expected)
示例13: testFlank
def testFlank(self):
"""Test that we can see a Flank mutation."""
#chr1:28,233,780-28,233,805 Junction is at chr1:28,233,793 & 94
#
refs = "TGGGCTCGGGCTCTCTGAAAAGAAAA"
alts = "TGGGCTCAGGCTCTCTGAAAAGAAAA"
vcs = []
gafDatasource = TestUtils.createTranscriptProviderDatasource(self.config)
numSpliceSites = 0
numSilent = 0
startWindow = 11042200
for s in range(startWindow, startWindow+len(refs)):
m = MutationDataFactory.default_create()
m.start = str(s)
m.end = str(s)
m.chr="1"
m.ref_allele = refs[s-startWindow]
m.alt_allele = alts[s-startWindow]
m = gafDatasource.annotate_mutation(m)
vc = m['variant_classification']
vcs.append(vc)
print vc + " " + m.start
pass
示例14: testAnnotateListOfMutations
def testAnnotateListOfMutations(self):
"""Test that we can initialize an Annotator, without an input or output and then feed mutations,
one at a time... using a runspec"""
# Locate the datasource directory and create a runspec
dbDir = self.config.get("DEFAULT", "dbDir")
ds = DatasourceFactory.createDatasources(dbDir)
runSpec = RunSpecification()
runSpec.initialize(None, None, datasources=ds)
# Initialize the annotator with the runspec
annotator = Annotator()
annotator.initialize(runSpec)
m = MutationDataFactory.default_create()
m.chr = "1"
m.start = "12941796"
m.end = "12941796"
m.alt_allele = "G"
m.ref_allele = "T"
muts = [m]
muts = annotator.annotate_mutations(muts)
m2 = muts.next()
self.assertTrue(m2.get("gene", None) is not None)
示例15: testdbNSFPNoRefAltAnnotationWithExactMatch
def testdbNSFPNoRefAltAnnotationWithExactMatch(self):
"""
"""
self.logger.info("Initializing dbNSFP")
tabixIndexedTsvDirName = os.path.join(*["testdata", "dbNSFP_chr1_chr3_100vars_exact_no_ref_alt_ds", "hg19"])
tabixIndexedTsvDatasource = DatasourceFactory.createDatasource(
os.path.join(tabixIndexedTsvDirName, "dbNSFP_chr1_chr3_100vars_exact_no_ref_alt_ds.config"),
tabixIndexedTsvDirName)
m1 = MutationDataFactory.default_create()
m1.chr = "1"
m1.start = "35140"
m1.end = "35140"
m1_annotated = tabixIndexedTsvDatasource.annotate_mutation(m1)
m1_annotation = m1_annotated.getAnnotation("dbNSFP_codonpos")
cur_annotation = Annotation(value="1|1|1", datasourceName="dbNSFP", dataType="String",
description="", tags=[TagConstants.INFO, TagConstants.NOT_SPLIT], number=None)
self.assertTrue(m1_annotation.isEqual(cur_annotation), "Annotations do not match.")
m1_annotation = m1_annotated.getAnnotation("dbNSFP_refcodon")
cur_annotation = Annotation(value="TAA|TAA|TAA", datasourceName="dbNSFP", dataType="String",
description="", tags=[TagConstants.INFO, TagConstants.NOT_SPLIT], number=None)
self.assertTrue(m1_annotation.isEqual(cur_annotation), "Annotations do not match.")
m1_annotation = m1_annotated.getAnnotation("dbNSFP_cds_strand")
cur_annotation = Annotation(value="-|-|-", datasourceName="dbNSFP", dataType="String",
description="", tags=[TagConstants.INFO, TagConstants.NOT_SPLIT], number=None)
self.assertTrue(m1_annotation.isEqual(cur_annotation), "Annotations do not match.")