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


Python VcfInputMutationCreator.VcfInputMutationCreator類代碼示例

本文整理匯總了Python中oncotator.input.VcfInputMutationCreator.VcfInputMutationCreator的典型用法代碼示例。如果您正苦於以下問題:Python VcfInputMutationCreator類的具體用法?Python VcfInputMutationCreator怎麽用?Python VcfInputMutationCreator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了VcfInputMutationCreator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testSNPsAndIndelStartAndEndPos

    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,代碼行數:27,代碼來源:VcfInputMutationCreatorTest.py

示例2: testDuplicateAnnotation

    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,代碼行數:26,代碼來源:VcfInputMutationCreatorTest.py

示例3: testFailureWithSpanningDeletion

    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,代碼行數:9,代碼來源:VcfInputMutationCreatorTest.py

示例4: testSampleNameSelectorWithVCF

 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,代碼行數:9,代碼來源:SampleNameSelectorTest.py

示例5: testNumberGRenderingOfRandomVcf

    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,代碼行數:11,代碼來源:VcfInputMutationCreatorTest.py

示例6: testDuplicateAnnotationMetaData

    def testDuplicateAnnotationMetaData(self):
        """
        Tests that the metadata is populated correctly in cases where duplicate annotations are present in the input VCF
        file.
        """
        inputFilename = os.path.join(*["testdata", "vcf", "example.duplicate_annotation.vcf"])

        creator = VcfInputMutationCreator(inputFilename)
        md = creator.getMetadata()

        self.assertTrue("variant_status" in md, "variant_status field is missing in metadata.")
        self.assertTrue("sample_variant_status" in md, "sample_variant_status is missing in metadata.")
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:12,代碼來源:VcfInputMutationCreatorTest.py

示例7: testSwitchedFieldsWithExampleVcf

    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,代碼行數:13,代碼來源:VcfInputMutationCreatorTest.py

示例8: testSuccesseWithSpanningDeletion

    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,代碼行數:13,代碼來源:VcfInputMutationCreatorTest.py

示例9: testAnnotationWithDuplicateValuesInVcf

    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,代碼行數:14,代碼來源:VcfInputMutationCreatorTest.py

示例10: testGetMetaDataWithNoSampleNameExampleVcf

    def testGetMetaDataWithNoSampleNameExampleVcf(self):
        """
        Tests to ensure that the metadata can be retrieved even before createMutations has been called.
        """
        inputFilename = os.path.join(*["testdata", "vcf", "example.sampleName.removed.vcf"])

        creator = VcfInputMutationCreator(inputFilename)
        gtKeys = {'genotype', 'read_depth', 'genotype_quality', 'haplotype_quality', 'q10', 's50', 'samples_number',
                  'depth_across_samples', 'allele_frequency', 'ancestral_allele', 'dbSNP_membership', 'id', 'qual',
                  'hapmap2_membership'}
        md = creator.getMetadata()
        ks = set(md.keys())
        diff = gtKeys.symmetric_difference(ks)
        self.assertTrue(len(diff) == 0, "Missing keys that should have been seen in the metadata: " + str(diff))
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:14,代碼來源:VcfInputMutationCreatorTest.py

示例11: testSimpleAnnotationWithAComplexVcf

    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,代碼行數:14,代碼來源:VcfInputMutationCreatorTest.py

示例12: testSimpleAnnotationWithExampleVcf

    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,代碼行數:15,代碼來源:VcfInputMutationCreatorTest.py

示例13: testGenotypeFieldIsHonored

    def testGenotypeFieldIsHonored(self):
        """
        Tests that no issues arise with genotype values >1 when multiple variants appear on one line.
        """
        inputFilename = os.path.join(*["testdata", "vcf", "example.severalGTs.vcf"])
        creator = VcfInputMutationCreator(inputFilename)
        muts = creator.createMutations()
        ctr = 0
        for mut in muts:

            if MutUtils.str2bool(mut["alt_allele_seen"]):
                self.assertTrue(mut['sample_name'] != "NA 00001")
                ctr += 1
        self.assertTrue(ctr == 7,
                        str(ctr) + " mutations with alt seen, but expected 7.  './.' should not show as a variant.")
開發者ID:broadinstitute,項目名稱:oncotator,代碼行數:15,代碼來源:VcfInputMutationCreatorTest.py

示例14: testOverwriteAnnotationsSupported

    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,代碼行數:15,代碼來源:VcfInputMutationCreatorTest.py

示例15: testTCGAMAFRendering

    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,代碼行數:20,代碼來源:VcfInputMutationCreatorTest.py


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