當前位置: 首頁>>代碼示例>>Python>>正文


Python VcfInputMutationCreator.createMutations方法代碼示例

本文整理匯總了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")
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:28,代碼來源:VcfInputMutationCreatorTest.py

示例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"]))
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:29,代碼來源:VcfInputMutationCreatorTest.py

示例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")
開發者ID:Tmacme,項目名稱:oncotator,代碼行數:11,代碼來源:SampleNameSelectorTest.py

示例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()
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:13,代碼來源:VcfInputMutationCreatorTest.py

示例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)
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:15,代碼來源:VcfInputMutationCreatorTest.py

示例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()
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:16,代碼來源:VcfInputMutationCreatorTest.py

示例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()
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:16,代碼來源:VcfInputMutationCreatorTest.py

示例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()
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:17,代碼來源:VcfInputMutationCreatorTest.py

示例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)
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:17,代碼來源:VcfInputMutationCreatorTest.py

示例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
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:11,代碼來源:VcfInputMutationCreatorTest.py

示例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)
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:22,代碼來源:VcfInputMutationCreatorTest.py

示例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))
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:15,代碼來源:VcfInputMutationCreatorTest.py

示例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]))
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:40,代碼來源:VcfInputMutationCreatorTest.py

示例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))
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:25,代碼來源:VcfInputMutationCreatorTest.py

示例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)
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:39,代碼來源:VcfInputMutationCreatorTest.py


注:本文中的oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator.createMutations方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。