예제 #1
0
    def test_draw_overlay(self):
        gene = genomic.Gene('12',
                            25357723,
                            25403870,
                            strand=STRAND.NEG,
                            name='KRAS')
        marker = BioInterval('12', 25403865, name='splice site mutation')
        t = build_transcript(cds_start=193,
                             cds_end=759,
                             exons=[(25403685, 25403865), (25398208, 25398329),
                                    (25380168, 25380346), (25378548, 25378707),
                                    (25357723, 25362845)],
                             gene=gene,
                             domains=[])
        build_transcript(cds_start=198,
                         cds_end=425,
                         exons=[(25403685, 25403870), (25398208, 25398329),
                                (25362102, 25362845)],
                         gene=gene,
                         domains=[])
        build_transcript(cds_start=65,
                         cds_end=634,
                         exons=[(25403685, 25403737), (25398208, 25398329),
                                (25380168, 25380346), (25378548, 25378707),
                                (25368371, 25368494), (25362365, 25362845)],
                         gene=gene,
                         domains=[
                             protein.Domain('domain1', [(1, 10)]),
                             protein.Domain('domain1', [(4, 10)])
                         ],
                         is_best_transcript=True)
        build_transcript(cds_start=65,
                         cds_end=634,
                         exons=[(25403698, 25403863), (25398208, 25398329),
                                (25386753, 25388160)],
                         gene=gene,
                         domains=[])
        d = DiagramSettings()
        for i, t in enumerate(gene.transcripts):
            t.name = 'transcript {}'.format(i + 1)
        scatterx = [x + 100 for x in range(gene.start, gene.end + 1, 400)]
        scattery = [random.uniform(-0.2, 0.2) for x in scatterx]
        s = ScatterPlot(list(zip(scatterx, scattery)),
                        'cna',
                        ymin=-1,
                        ymax=1,
                        yticks=[-1, 0, 1])

        d.gene_min_buffer = 0
        canvas = draw_multi_transcript_overlay(d,
                                               gene,
                                               vmarkers=[marker],
                                               plots=[s, s])
        self.assertEqual(2, len(canvas.elements))  # defs counts as element
        if OUTPUT_SVG:
            canvas.saveas('test_draw_overlay.svg')
예제 #2
0
    def test_generate_gene_mapping_err(self):
        #  _generate_interval_mapping [genomic.IntergenicRegion(11:77361962_77361962+)] 1181.39453125 5 30 None 77356962 77366962)
        ir = genomic.IntergenicRegion('11', 5000, 5000, STRAND.POS)
        tgt_width = 1000
        d = DiagramSettings()
        d.gene_min_buffer = 10
        # (self, canvas, gene, width, height, fill, label='', reference_genome=None)
        draw_genes(d, self.canvas, [ir], tgt_width, [])

        # _generate_interval_mapping ['Interval(29684391, 29684391)', 'Interval(29663998, 29696515)'] 1181.39453125 5 60 None 29662998 29697515
        # def generate_interval_mapping(cls, input_intervals, target_width, ratio, min_width, buffer_length=None, start=None, end=None, min_inter_width=None)
        itvls = [Interval(29684391, 29684391), Interval(29663998, 29696515)]
        generate_interval_mapping(itvls, 1181.39, 5, 60, None, 29662998,
                                  29697515)