예제 #1
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)
예제 #2
0
    def test_draw_genes(self):

        x = genomic.Gene('1', 1000, 2000, strand=STRAND.POS)
        y = genomic.Gene('1', 5000, 7000, strand=STRAND.NEG)
        z = genomic.Gene('1', 1500, 2500, strand=STRAND.POS)

        d = DiagramSettings()
        breakpoints = [Breakpoint('1', 1100, 1200, orient=ORIENT.RIGHT)]
        g = draw_genes(d, self.canvas, [x, y, z], 500, breakpoints, {
            x: d.gene1_color,
            y: d.gene2_color_selected,
            z: d.gene2_color
        })

        # test the class structure
        self.assertEqual(6, len(g.elements))
        self.assertEqual('scaffold', g.elements[0].attribs.get('class', ''))
        for i in range(1, 4):
            self.assertEqual('gene', g.elements[i].attribs.get('class', ''))
        self.assertEqual('mask', g.elements[4].attribs.get('class', ''))
        self.assertEqual('breakpoint', g.elements[5].attribs.get('class', ''))
        self.assertEqual(
            d.track_height * 2 + d.padding + d.breakpoint_bottom_margin +
            d.breakpoint_top_margin, g.height)
        self.canvas.add(g)
        self.assertEqual(len(g.labels), 4)
        self.assertEqual(x, g.labels['G1'])
        self.assertEqual(z, g.labels['G2'])
        self.assertEqual(y, g.labels['G3'])
        self.assertEqual(breakpoints[0], g.labels['B1'])
예제 #3
0
    def test_draw_genes(self, canvas):

        x = genomic.Gene('1', 1000, 2000, strand=STRAND.POS)
        y = genomic.Gene('1', 5000, 7000, strand=STRAND.NEG)
        z = genomic.Gene('1', 1500, 2500, strand=STRAND.POS)

        d = DiagramSettings(domain_name_regex_filter=r'.*')
        breakpoints = [Breakpoint('1', 1100, 1200, orient=ORIENT.RIGHT)]
        g = draw_genes(
            d,
            canvas,
            [x, y, z],
            500,
            breakpoints,
            {
                x: d.gene1_color,
                y: d.gene2_color_selected,
                z: d.gene2_color
            },
        )

        # test the class structure
        assert len(g.elements) == 6
        assert g.elements[0].attribs.get('class', '') == 'scaffold'
        for i in range(1, 4):
            assert g.elements[i].attribs.get('class', '') == 'gene'
        assert g.elements[4].attribs.get('class', '') == 'mask'
        assert g.elements[5].attribs.get('class', '') == 'breakpoint'
        assert (g.height == d.track_height * 2 + d.padding +
                d.breakpoint_bottom_margin + d.breakpoint_top_margin)
        canvas.add(g)
        assert 4 == len(g.labels)
        assert g.labels['G1'] == x
        assert g.labels['G2'] == z
        assert g.labels['G3'] == y
        assert g.labels['B1'] == breakpoints[0]