[Biopython-dev] [Bug 2711] New: GenomeDiagram.py: write() and write_to_string() are inefficient and don't check inputs

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Dec 12 17:43:49 UTC 2008


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

           Summary: GenomeDiagram.py: write() and write_to_string() are
                    inefficient and don't check inputs
           Product: Biopython
           Version: Not Applicable
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main Distribution
        AssignedTo: biopython-dev at biopython.org
        ReportedBy: bsouthey at gmail.com


While looking at GenomeDiagram.py I noticed some things that should be fixed. I
do note that some of this stems from reportlab. In particlular, reportlab
doesn't appear to have a generic interface for different image formats.

1) Why are there two functions to output a diagram than just one generic
function? In particular, why not just pass a filename or not? Yes, I know that
reportlab uses different functions but this just duplicates code. So this is
more a comment than anything else. 

2) I find the functions write() and write_to_string() just plain ugly. 
You define a local dictionary of modules every time these functions are called.
But there is only one valid key so you then go back to find the input that you
already knew. A nested list would be better and allow catching invalid inputs
(see next point).

3) Neither write() and write_to_string() check that the output option is valid.
These functions do not accept lowercase. Thus, output='ps' will crash with a
key error as well any invalid key.

4) I do not know the policy on module imports, but this line is only required
for write() and write_to_string():
from reportlab.graphics import renderPS, renderPDF, renderSVG, renderPM
Also renderPM is an addon.


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



More information about the Biopython-dev mailing list