[Biopython] meddling with GeneDiagram

A M Torres, Hugo mnemonico at posthocergopropterhoc.net
Wed Mar 7 16:18:37 UTC 2012


Fellow biopythoneers,

I've been playing around with GenomeDiagram trying to draw a gene's
features. My impressions are this is a very nifty tool indeed.

However I see a problem in the way I would can draw a gene though it might
be just my inexperience with as a user: The sigil don't

automatically distinguish between a FeatureLocation with fuzzy
position(i.e. BeforePosition(0)) and a feature with an exact position (i.e.
ExactPosition(6475)).

As example suppose I would like to draw the genes from a SeqRecord object
built from the TP53 genbank file:

def
draw_gene(seqrec):
    diagram = GenomeDiagram.Diagram(seqrec.id)

    gene_track = diagram.new_track(1, name='Genes:
')
    gene_set =
gene_track.new_set()
····

    genes = ( i for i in seqrec.features if i.type ==
'gene')


    color =
colors.green
    for gene in
genes:
        if gene.strand ==
1:
            angle = 0
#

else:
            angle =
180

gene_set.add_feature(gene,·

sigil='ARROW',·

color=color,·

arrowshaft_height=1,

arrowhead_length=0.2,

label=True,

label_size=14,·

label_angle=angle,

)

diagram.draw(format='linear',·

pagesize='A4',·

fragments=1,·

start=0,·

end=len(seqrec)

)
    diagram.write('gene_diagram.svg', 'SVG')


The resulting image looks like gene_diagram.svg. There seems to be a WRAP53
gene on the minus strand and the sigil represents it as awhole gene. but
its only a portion of it. Maybe we could represent its just a piece by
drawing the arrowhead pointing inwards instead of outwards as in
gene_arrow.png.

Is that possible to implement?

-- 
 .''`.      Hugo A. M. Torres
: :' :
`. `'   “Talk is cheap,
  `-    show me the code. ”  -- L. Torvalds.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gene_arrow.png
Type: image/png
Size: 8525 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/biopython/attachments/20120307/a81ee9ab/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gene_diagram.svg
Type: image/svg+xml
Size: 2316 bytes
Desc: not available
URL: <http://lists.open-bio.org/pipermail/biopython/attachments/20120307/a81ee9ab/attachment.svg>


More information about the Biopython mailing list