Package Bio :: Package Graphics :: Module KGML_vis :: Class KGMLCanvas
[hide private]
[frames] | no frames]

Class KGMLCanvas

source code

object --+
         |
        KGMLCanvas

Reportlab Canvas-based representation of a KGML pathway map.
Instance Methods [hide private]
 
__init__(self, pathway, import_imagemap=False, label_compounds=True, label_orthologs=True, label_reaction_entries=True, label_maps=True, show_maps=False, fontname='Helvetica', fontsize=6, draw_relations=True, show_orthologs=True, show_compounds=True, show_genes=True, show_reaction_entries=True, margins=(0.02, 0.02))
Initialize.
source code
 
draw(self, filename)
Add the map elements to the drawing.
source code
 
__add_maps(self)
Add maps to the drawing of the map (PRIVATE).
source code
 
__add_graphics(self, graphics)
Add the passed graphics object to the map (PRIVATE).
source code
 
__add_labels(self, graphics)
Add labels for the passed graphics objects to the map (PRIVATE).
source code
 
__add_orthologs(self)
Add 'ortholog' Entry elements to the drawing of the map (PRIVATE).
source code
 
__add_reaction_entries(self)
Add Entry elements for Reactions to the map drawing (PRIVATE).
source code
 
__add_compounds(self)
Add compound elements to the drawing of the map (PRIVATE).
source code
 
__add_genes(self)
Add gene elements to the drawing of the map (PRIVATE).
source code
 
__add_relations(self)
Add relations to the map (PRIVATE).
source code
 
__draw_arrow(self, g_from, g_to)
Draw an arrow between given Entry objects (PRIVATE).
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, pathway, import_imagemap=False, label_compounds=True, label_orthologs=True, label_reaction_entries=True, label_maps=True, show_maps=False, fontname='Helvetica', fontsize=6, draw_relations=True, show_orthologs=True, show_compounds=True, show_genes=True, show_reaction_entries=True, margins=(0.02, 0.02))
(Constructor)

source code 
Initialize.
Overrides: object.__init__

__add_maps(self)

source code 

Add maps to the drawing of the map (PRIVATE).

We do this first, as they're regional labels to be overlaid by information. Also, we want to set the color to something subtle.

We're using Hex colors because that's what KGML uses, and Reportlab doesn't mind.

__add_graphics(self, graphics)

source code 

Add the passed graphics object to the map (PRIVATE).

Add text, add after the graphics object, for sane Z-ordering.

__add_labels(self, graphics)

source code 

Add labels for the passed graphics objects to the map (PRIVATE).

We don't check that the labels fit inside objects such as circles/ rectangles/roundrectangles.

__add_orthologs(self)

source code 

Add 'ortholog' Entry elements to the drawing of the map (PRIVATE).

In KGML, these are typically line objects, so we render them before the compound circles to cover the unsightly ends/junctions.

__add_reaction_entries(self)

source code 

Add Entry elements for Reactions to the map drawing (PRIVATE).

In KGML, these are typically line objects, so we render them before the compound circles to cover the unsightly ends/junctions

__add_relations(self)

source code 

Add relations to the map (PRIVATE).

This is tricky. There is no defined graphic in KGML for a relation, and the corresponding entries are typically defined as objects 'to be connected somehow'. KEGG uses KegSketch, which is not public, and most third-party software draws straight line arrows, with heads to indicate the appropriate direction (at both ends for reversible reactions), using solid lines for ECrel relation types, and dashed lines for maplink relation types.

The relation has: - entry1: 'from' node - entry2: 'to' node - subtype: what the relation refers to

Typically we have entry1 = map/ortholog; entry2 = map/ortholog, subtype = compound.

__draw_arrow(self, g_from, g_to)

source code 

Draw an arrow between given Entry objects (PRIVATE).

Draws an arrow from the g_from Entry object to the g_to Entry object; both must have Graphics objects.