本文整理汇总了Python中oncotator.MutationDataFactory.MutationDataFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python MutationDataFactory.create方法的具体用法?Python MutationDataFactory.create怎么用?Python MutationDataFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oncotator.MutationDataFactory.MutationDataFactory
的用法示例。
在下文中一共展示了MutationDataFactory.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initializeMutFromAttributes
# 需要导入模块: from oncotator.MutationDataFactory import MutationDataFactory [as 别名]
# 或者: from oncotator.MutationDataFactory.MutationDataFactory import create [as 别名]
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
示例2: test_annotation_overwriting_on
# 需要导入模块: from oncotator.MutationDataFactory import MutationDataFactory [as 别名]
# 或者: from oncotator.MutationDataFactory.MutationDataFactory import create [as 别名]
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")
示例3: test_annotation_overwriting_off
# 需要导入模块: from oncotator.MutationDataFactory import MutationDataFactory [as 别名]
# 或者: from oncotator.MutationDataFactory.MutationDataFactory import create [as 别名]
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")