当前位置: 首页>>代码示例>>Python>>正文


Python Annotator.initialize方法代码示例

本文整理汇总了Python中oncotator.Annotator.Annotator.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python Annotator.initialize方法的具体用法?Python Annotator.initialize怎么用?Python Annotator.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oncotator.Annotator.Annotator的用法示例。


在下文中一共展示了Annotator.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_overwriting_muts

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def test_overwriting_muts(self):
        """Ensure that (given correct configuration) we can annotate from a datasource, even if the datasource will overwrite an existing mutation."""
        # We will have an input with a "Who" annotation that this datasource will try to write.
        gene_ds = DatasourceFactory.createDatasource(
            "testdata/thaga_janakari_gene_ds/hg19/tj_data.config", "testdata/thaga_janakari_gene_ds/hg19/"
        )
        input_filename = "testdata/maflite/who_alt1_vs_alt2.maflite"
        output_filename = "out/who_alt1_vs_alt2.maf.annotated"
        input_format = "MAFLITE"
        output_format = "TCGAMAF"

        other_opts = {OptionConstants.ALLOW_ANNOTATION_OVERWRITING: True, OptionConstants.NO_PREPEND: True}

        run_spec = RunSpecificationFactory.create_run_spec_given_datasources(
            input_format,
            output_format,
            input_filename,
            output_filename,
            datasource_list=[gene_ds],
            other_opts=other_opts,
        )
        annotator = Annotator()
        annotator.initialize(run_spec)

        annotator.annotate()

        tsv_reader = GenericTsvReader(output_filename)

        for i, line_dict in enumerate(tsv_reader):
            self.assertTrue(line_dict.get("TJ_Data_Who", "") != "Tromokratis")
开发者ID:Yixf-Self,项目名称:oncotator,代码行数:32,代码来源:AnnotatorTest.py

示例2: test_full_seg_file_annotations

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def test_full_seg_file_annotations(self):
        """Test that we can read in a seg file, do a proper full annotation, and output as SIMPLE_TSV"""
        inputFilename = "testdata/seg/Patient0.seg.txt"
        output_filename = "out/test_full_seg_file_annotations.tsv"
        db_dir = self.config.get('DEFAULT',"dbDir")
        if os.path.exists(output_filename):
            os.remove(output_filename)

        annotator = Annotator()
        run_spec = RunSpecificationFactory.create_run_spec("SEG_FILE", "SIMPLE_TSV", inputFilename, output_filename,
                                                           datasourceDir=db_dir, annotating_type=RunSpecification.ANNOTATE_SEGMENTS)
        annotator.initialize(run_spec)
        annotator.annotate()

        # Now check the output
        output_reader = GenericTsvReader(output_filename)

        required_cols = ["Sample", "Num_Probes", "Segment_Mean"]
        headers = output_reader.getFieldNames()
        for rcol in required_cols:
            self.assertTrue(rcol in headers)

        for line_dict in output_reader:
            self.assertTrue(line_dict['start'] is not None)
            self.assertTrue(line_dict['start'].strip() != "")
            self.assertTrue(line_dict['end'] is not None)
            self.assertTrue(line_dict['end'].strip() != "")
            self.assertTrue("genes" in line_dict.keys())
            self.assertTrue(len(line_dict["genes"].split(",")) > 0)
开发者ID:alexramos,项目名称:oncotator,代码行数:31,代码来源:MafliteInputMutationCreatorTest.py

示例3: testAnnotateListOfMutations

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    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 = MutationData()
        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)
开发者ID:alexramos,项目名称:oncotator,代码行数:28,代码来源:AnnotatorTest.py

示例4: test_basic_rendering

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def test_basic_rendering(self):
        """Test that we can render a basic seg file as a gene list"""
        inputFilename = "testdata/seg/Patient0.seg.txt"
        output_filename = "out/test_basic_rendering.gene_list.tsv"
        db_dir = self.config.get('DEFAULT',"dbDir")
        if os.path.exists(output_filename):
            os.remove(output_filename)

        annotator = Annotator()
        run_spec = RunSpecificationFactory.create_run_spec("SEG_FILE", "GENE_LIST", inputFilename, output_filename,
                                                           datasourceDir=db_dir, annotating_type=RunSpecification.ANNOTATE_SEGMENTS)
        annotator.initialize(run_spec)
        annotator.annotate()

        # Now check the output
        output_reader = GenericTsvReader(output_filename)

        headers = output_reader.getFieldNames()

        for line_dict in output_reader:
            self.assertTrue(line_dict['segment_start'] is not None)
            self.assertTrue(line_dict['segment_start'].strip() != "")
            self.assertTrue(line_dict['segment_end'] is not None)
            self.assertTrue(line_dict['segment_end'].strip() != "")
            self.assertTrue("gene" in line_dict.keys())
            self.assertTrue(len(line_dict["gene"]) > 0)
            self.assertTrue(float(line_dict["segment_num_probes"]))
            self.assertTrue(line_dict['sample'] == "Patient0")
开发者ID:alexramos,项目名称:oncotator,代码行数:30,代码来源:GeneListOutputRendererTest.py

示例5: test_no_overwriting_muts

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def test_no_overwriting_muts(self):
        """Ensure that (given configuration that disallows) we cannot annotate from a datasource when a value was specified in the input."""
        # We will have an input with a "Who" annotation that this datasource will try to write.
        gene_ds = DatasourceFactory.createDatasource(
            "testdata/thaga_janakari_gene_ds/hg19/tj_data.config", "testdata/thaga_janakari_gene_ds/hg19/"
        )
        input_filename = "testdata/maflite/who_alt1_vs_alt2.maflite"
        output_filename = "out/who_alt1_vs_alt2.maf.annotated"
        input_format = "MAFLITE"
        output_format = "TCGAMAF"

        other_opts = {OptionConstants.ALLOW_ANNOTATION_OVERWRITING: False, OptionConstants.NO_PREPEND: True}

        run_spec = RunSpecificationFactory.create_run_spec_given_datasources(
            input_format,
            output_format,
            input_filename,
            output_filename,
            datasource_list=[gene_ds],
            other_opts=other_opts,
        )
        annotator = Annotator()
        annotator.initialize(run_spec)

        self.assertRaises(DuplicateAnnotationException, annotator.annotate)
开发者ID:Yixf-Self,项目名称:oncotator,代码行数:27,代码来源:AnnotatorTest.py

示例6: _simple_annotate

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
 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 = MutationData()
     m.chr = "1"
     m.start = "12941796"
     m.end = "12941796"
     m.alt_allele = "G"
     m.ref_allele = "T"
     m.createAnnotation("alt_allele_seen", "False")
     m2 = MutationData()
     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
开发者ID:alexramos,项目名称:oncotator,代码行数:27,代码来源:AnnotatorTest.py

示例7: test_rendering_combined_to_tsv

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
 def test_rendering_combined_to_tsv(self):
     """Test that we produce a merged ONP simple tsv file without crashing """
     input_filename = os.path.join(*["testdata", "maflite", "onp_combination.maf.txt"])
     output_filename = os.path.join("out", "onp_combination.tsv")
     spec = RunSpecificationFactory.create_run_spec("MAFLITE","SIMPLE_TSV",input_filename, output_filename,
                                             other_opts={OptionConstants.INFER_ONPS: True})
     annotator = Annotator()
     annotator.initialize(spec)
     annotator.annotate()
开发者ID:Tmacme,项目名称:oncotator,代码行数:11,代码来源:OnpCombinerTest.py

示例8: _annotateTest

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def _annotateTest(self, inputFilename, outputFilename, datasource_dir, inputFormat="MAFLITE", outputFormat="TCGAMAF", default_annotations=TCGA_MAF_DEFAULTS, override_annotations=None, is_skip_no_alts=False):
        self.logger.info("Initializing Annotator...")

        if override_annotations is None:
            override_annotations = dict()

        annotator = Annotator()
        runSpec = RunSpecificationFactory.create_run_spec(inputFormat, outputFormat, inputFilename, outputFilename, defaultAnnotations=default_annotations, datasourceDir=datasource_dir, globalAnnotations=override_annotations, is_skip_no_alts=is_skip_no_alts)
        annotator.initialize(runSpec)
        self.logger.info("Annotation starting...")
        return annotator.annotate()
开发者ID:alexramos,项目名称:oncotator,代码行数:13,代码来源:TcgaMafOutputRendererTest.py

示例9: test_single_sample_onp_combiner

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
 def test_single_sample_onp_combiner(self):
     """test that we can create an onp combined TCGA maf without crashing"""
     input_filename = 'testdata/maflite/onp.singlesample.maf.txt'
     output_filename = 'out/testSingleSampleOnpCombiner.maf'
     config = TestUtils.createUnitTestConfig()
     defaultdb = config.get('DEFAULT',"dbDir")
     spec = RunSpecificationFactory.create_run_spec("MAFLITE","TCGAMAF", input_filename, output_filename,
                                                    datasource_dir=defaultdb,
                                             other_opts={OptionConstants.INFER_ONPS: True})
     annotator = Annotator()
     annotator.initialize(spec)
     annotator.annotate()
开发者ID:Tmacme,项目名称:oncotator,代码行数:14,代码来源:OnpCombinerTest.py

示例10: _annotate_m2_vcf

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
 def _annotate_m2_vcf(self, input_vcf_file, output_tcgamaf_file):
     # For this conversion, you must specify the barcodes manually
     override_annotations = dict()
     override_annotations.update({'tumor_barcode': 'Patient0-Tumor', 'normal_barcode': 'Patient0-Normal'})
     other_opts = {OptionConstants.COLLAPSE_FILTER_COLS: True, OptionConstants.NO_PREPEND: True,
                   OptionConstants.SPLIT_ALLELIC_DEPTH: False, OptionConstants.INFER_ONPS: True}
     # Use an empty datasource dir in order to speed this up.
     annotator = Annotator()
     runSpec = RunSpecificationFactory.create_run_spec("VCF", "TCGAMAF", input_vcf_file, output_tcgamaf_file,
                                                       datasource_dir=".", global_annotations=override_annotations,
                                                       is_skip_no_alts=True, other_opts=other_opts)
     annotator.initialize(runSpec)
     annotator.annotate()
开发者ID:Tmacme,项目名称:oncotator,代码行数:15,代码来源:OnpCombinerTest.py

示例11: testAnnotationWithMafliteWithTrailingSpaces

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def testAnnotationWithMafliteWithTrailingSpaces(self):
        """
        Tests the ability to annotate a maflite file that contains trailing spaces in ref and alt alleles.
        """
        db_dir = self.config.get('DEFAULT',"dbDir")
        inputFilename = os.path.join(*["testdata", "maflite", "example.trailing_whitespace_in_alleles.maflite"])
        outputFilename = os.path.join("out", "example.trailing_whitespace_in_alleles.maf.txt")

        annotator = Annotator()
        run_spec = RunSpecificationFactory.create_run_spec("MAFLITE", "TCGAMAF", inputFilename, outputFilename,
                                                           datasource_dir=db_dir, annotating_type=RunSpecification.ANNOTATE_MUTATIONS)
        annotator.initialize(run_spec)
        annotator.annotate()
开发者ID:Tmacme,项目名称:oncotator,代码行数:15,代码来源:MafliteInputMutationCreatorTest.py

示例12: test_annotating_uniprot_test_file

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def test_annotating_uniprot_test_file(self):
        """Test variants with known issues with older version of UniProt datasource. This test will fail if using older version of uniprot datasource (pre-2014) """
        db_dir = TestUtils.createUnitTestConfig().get('DEFAULT',"dbDir")
        annotator = Annotator()
        out_file_name = "out/uniprot_recovery.maf.annotated"
        runSpec = RunSpecificationFactory.create_run_spec("MAFLITE", "TCGAMAF", "testdata/maflite/uniprot_recovery.maflite",
                                                          out_file_name, datasource_dir=db_dir, tx_mode=TranscriptProvider.TX_MODE_BEST_EFFECT)
        annotator.initialize(runSpec)
        annotator.annotate()

        out_file_reader = GenericTsvReader(out_file_name)
        for i,line_dict in enumerate(out_file_reader):
            self.assertTrue(line_dict['UniProt_AApos'] != "0")

            #TODO: The fourth entry is currently not picking up the uniprot entry for this.  Remove the "if" statement once issue #253 is addressed
            if i != 4:
                self.assertTrue(line_dict['SwissProt_entry_Id'].endswith("HUMAN"))
开发者ID:Tmacme,项目名称:oncotator,代码行数:19,代码来源:TranscriptToUniProtProteinPositionTransformingDatasourceTest.py

示例13: test_proper_conversion_vcf_to_maf_with_collapse_filter_cols

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def test_proper_conversion_vcf_to_maf_with_collapse_filter_cols(self):
        """Test FILTER col is properly rendered when using the collapse-filter-cols option."""

        input_fname = 'testdata/vcf/example.vcf'
        output_fname = 'out/example.one_filter_col.maf.txt'
        annotator = Annotator()
        other_opts = {'collapse_filter_cols': True}

        from oncotator.utils.RunSpecification import RunSpecification
        run_spec = RunSpecificationFactory.create_run_spec('VCF', 'TCGAMAF', input_fname, output_fname, other_opts=other_opts)
        annotator.initialize(run_spec)
        annotator.annotate()

        tsv_reader = GenericTsvReader(output_fname)
        for line_dict in tsv_reader:
            self.assertIn('i_filter', line_dict)
            self.assertTrue(line_dict['i_filter'] in ['PASS', 'q10'])
开发者ID:Tmacme,项目名称:oncotator,代码行数:19,代码来源:TcgaMafOutputRendererTest.py

示例14: testSkippingAltsForSingleMut

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def testSkippingAltsForSingleMut(self):
        """Test a simple case where a single mutation with alt_allele_seen of False is not produced."""

        runSpec = RunSpecification()
        runSpec.initialize(None, None, datasources=[], is_skip_no_alts=True)

        # Initialize the annotator with the runspec
        annotator = Annotator()
        annotator.initialize(runSpec)

        m = MutationData()
        m.chr = "1"
        m.start = "12941796"
        m.end = "12941796"
        m.alt_allele = "G"
        m.ref_allele = "T"
        m.createAnnotation("alt_allele_seen", "False")

        muts = [m]

        muts = annotator.annotate_mutations(muts)
        self.assertRaises(StopIteration, muts.next)
开发者ID:alexramos,项目名称:oncotator,代码行数:24,代码来源:AnnotatorTest.py

示例15: testAnnotationWithMafliteWithTrailingSpaces

# 需要导入模块: from oncotator.Annotator import Annotator [as 别名]
# 或者: from oncotator.Annotator.Annotator import initialize [as 别名]
    def testAnnotationWithMafliteWithTrailingSpaces(self):
        """
        Tests the ability to annotate a VCF file that contains trailing spaces in ref and alt alleles.
        """
        db_dir = self.config.get('DEFAULT',"dbDir")
        inputFilename = os.path.join(*["testdata", "vcf", "example.trailing_whitespace_in_alleles.vcf"])
        outputFilename = os.path.join("out", "example.trailing_whitespace_in_alleles.vcf")

        annotator = Annotator()
        from oncotator.utils.RunSpecification import RunSpecification
        run_spec = RunSpecificationFactory.create_run_spec("VCF", "VCF", inputFilename, outputFilename,
                                                           datasource_dir=db_dir, annotating_type=RunSpecification.ANNOTATE_MUTATIONS,
                                                           other_opts={'vcf_out_infer_genotypes': False})
        annotator.initialize(run_spec)
        annotator.annotate()

        #check output
        vcf_data = open(outputFilename).read()
        self.assertIn('\n1\t14907\t.\tA\tG\t', vcf_data)
        self.assertIn('\n1\t14930\trs150145850\tA\tG\t', vcf_data)
        self.assertIn('\n1\t14933\trs138566748\tG\tA\t', vcf_data)
        self.assertIn('\n1\t14948\trs148911281\tG\tA\t', vcf_data)
开发者ID:broadinstitute,项目名称:oncotator,代码行数:24,代码来源:VcfInputMutationCreatorTest.py


注:本文中的oncotator.Annotator.Annotator.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。