[Biopython-dev] [Bug 2671] Including GenomeDiagram in the main Biopython distribution

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Wed Dec 10 17:55:31 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2671





------- Comment #27 from biopython-bugzilla at maubp.freeserve.co.uk  2008-12-10 12:55 EST -------
This might be better off as a new enhancement bug, but here is a possible
"arc-box" drawing function to go in the AbstractDrawer.py file, based on the
existing draw_box function.

def draw_arcbox(xcentre, ycentre, inner_radius, outer_radius,
                startangle, endangle,
                colour=colors.lightgreen, border=None, color=None) :
    """Returns a closed path object describing an arced box.

    Expects the angles to be in radians."""
    if color is None:
        color = colour
    if color == colors.white and border is None:   # Force black border on 
        strokecolor = colors.black                 # white boxes with
    elif border is None:                           # undefined border, else
        strokecolor = color                        # use fill colour
    elif border is not None:
        strokecolor = border

    p = ArcPath(strokeColor=strokecolor,
                fillColor=color,
                strokewidth=0)
    p.addArc(xcentre, ycentre, outer_radius,
             startangle * 180 / pi, endangle * 180 / pi,
             moveTo=True)
    p.addArc(xcentre, ycentre, inner_radius,
             startangle * 180 / pi, endangle * 180 / pi,
             reverse=True)
    p.closePath()
    return p

This takes advantage of reportlab's build in arc approximation code meaning we
can simplify the CircularDrawer.py method to just something like this:

    def draw_arc(self, inner_radius, outer_radius,
                 startangle, endangle,
                 color, border=None, colour=None):
        #Docstring here
        return draw_arcbox(self.xcentre, self.ycentre,
                           inner_radius, outer_radius,
                           startangle, endangle,
                           colour, border, color)

Alternately, the code could just go in CircularDrawer.py directly.

As far as I can tell from looking at their source code, even ReportLab_1_21_2
has ArcPath defined in reportlab.graphics.shapes so there shouldn't be any
issue here with backwards compatibility.


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the Biopython-dev mailing list