Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes
Bio.Graphics.GenomeDiagram._AbstractDrawer.AbstractDrawer Class Reference

CLASSES. More...

List of all members.

Public Member Functions

def __init__
def set_page_size
def set_margins
def set_bounds
def is_in_bounds
def __len__

Public Attributes

 tracklines
 cross_track_links
 xcenter
 ycenter
 pagesize
 y0
 ylim
 pagewidth
 pageheight
 end
 length

Properties

 xcentre
 ycentre

Private Member Functions

def _set_xcentre
def _set_ycentre
def _current_track_start_end

Private Attributes

 _parent

Detailed Description

CLASSES.

AbstractDrawer

    Provides:

    Methods:

    o __init__(self, parent, pagesize='A3', orientation='landscape',
             x=0.05, y=0.05, xl=None, xr=None, yt=None, yb=None,
             start=None, end=None, tracklines=0) Called on instantiation

    o set_page_size(self, pagesize, orientation)    Set the page size to the
                                                passed size and orientation

    o set_margins(self, x, y, xl, xr, yt, yb)   Set the drawable area of the
                                                page

    o set_bounds(self, start, end)  Set the bounds for the elements to be
                                    drawn

    o is_in_bounds(self, value)     Returns a boolean for whether the position
                                    is actually to be drawn

    o __len__(self)     Returns the length of sequence that will be drawn

    Attributes:

    o tracklines    Boolean for whether to draw lines dilineating tracks

    o pagesize      Tuple describing the size of the page in pixels

    o x0            Float X co-ord for leftmost point of drawable area

    o xlim          Float X co-ord for rightmost point of drawable area

    o y0            Float Y co-ord for lowest point of drawable area

    o ylim          Float Y co-ord for topmost point of drawable area

    o pagewidth     Float pixel width of drawable area

    o pageheight    Float pixel height of drawable area

    o xcenter       Float X co-ord of center of drawable area

    o ycenter       Float Y co-ord of center of drawable area

    o start         Int, base to start drawing from

    o end           Int, base to stop drawing at

    o length        Size of sequence to be drawn
    
    o cross_track_links List of tuples each with four entries (track A,
                        feature A, track B, feature B) to be linked.

Definition at line 296 of file _AbstractDrawer.py.


Constructor & Destructor Documentation

def Bio.Graphics.GenomeDiagram._AbstractDrawer.AbstractDrawer.__init__ (   self,
  parent,
  pagesize = 'A3',
  orientation = 'landscape',
  x = 0.05,
  y = 0.05,
  xl = None,
  xr = None,
  yt = None,
  yb = None,
  start = None,
  end = None,
  tracklines = 0,
  cross_track_links = None 
)
__init__(self, parent, pagesize='A3', orientation='landscape',
 x=0.05, y=0.05, xl=None, xr=None, yt=None, yb=None,
 start=None, end=None, tracklines=0)

    o parent    Diagram object containing the data that the drawer
        draws

    o pagesize  String describing the ISO size of the image, or a tuple
        of pixels

    o orientation   String describing the required orientation of the
            final drawing ('landscape' or 'portrait')

    o x         Float (0->1) describing the relative size of the X
        margins to the page

    o y         Float (0->1) describing the relative size of the Y
        margins to the page

    o xl        Float (0->1) describing the relative size of the left X
        margin to the page (overrides x)

    o xl        Float (0->1) describing the relative size of the left X
        margin to the page (overrides x)

    o xr        Float (0->1) describing the relative size of the right X
        margin to the page (overrides x)

    o yt        Float (0->1) describing the relative size of the top Y
        margin to the page (overrides y)

    o yb        Float (0->1) describing the relative size of the lower Y
        margin to the page (overrides y)

    o start     Int, the position to begin drawing the diagram at

    o end       Int, the position to stop drawing the diagram at

    o tracklines    Boolean flag to show (or not) lines delineating tracks
            on the diagram            

    o cross_track_links List of tuples each with four entries (track A,
                feature A, track B, feature B) to be linked.

Definition at line 354 of file _AbstractDrawer.py.

00354 
00355                  start=None, end=None, tracklines=0, cross_track_links=None):
00356         """ __init__(self, parent, pagesize='A3', orientation='landscape',
00357                  x=0.05, y=0.05, xl=None, xr=None, yt=None, yb=None,
00358                  start=None, end=None, tracklines=0)
00359 
00360             o parent    Diagram object containing the data that the drawer
00361                         draws
00362 
00363             o pagesize  String describing the ISO size of the image, or a tuple
00364                         of pixels
00365 
00366             o orientation   String describing the required orientation of the
00367                             final drawing ('landscape' or 'portrait')
00368 
00369             o x         Float (0->1) describing the relative size of the X
00370                         margins to the page
00371 
00372             o y         Float (0->1) describing the relative size of the Y
00373                         margins to the page
00374 
00375             o xl        Float (0->1) describing the relative size of the left X
00376                         margin to the page (overrides x)
00377 
00378             o xl        Float (0->1) describing the relative size of the left X
00379                         margin to the page (overrides x)
00380 
00381             o xr        Float (0->1) describing the relative size of the right X
00382                         margin to the page (overrides x)
00383 
00384             o yt        Float (0->1) describing the relative size of the top Y
00385                         margin to the page (overrides y)
00386 
00387             o yb        Float (0->1) describing the relative size of the lower Y
00388                         margin to the page (overrides y)
00389 
00390             o start     Int, the position to begin drawing the diagram at
00391 
00392             o end       Int, the position to stop drawing the diagram at
00393 
00394             o tracklines    Boolean flag to show (or not) lines delineating tracks
00395                             on the diagram            
00396 
00397             o cross_track_links List of tuples each with four entries (track A,
00398                                 feature A, track B, feature B) to be linked.
00399         """
00400         self._parent = parent   # The calling Diagram object
00401 
00402         # Perform 'administrative' tasks of setting up the page
00403         self.set_page_size(pagesize, orientation)   # Set drawing size
00404         self.set_margins(x, y, xl, xr, yt, yb)      # Set page margins
00405         self.set_bounds(start, end) # Set limits on what will be drawn
00406         self.tracklines = tracklines    # Set flags
00407         if cross_track_links is None:
00408             cross_track_links = []
00409         else:
00410             self.cross_track_links = cross_track_links
        

Here is the caller graph for this function:


Member Function Documentation

__len__(self)

    Returns the length of the region to be drawn

Definition at line 525 of file _AbstractDrawer.py.

00525 
00526     def __len__(self):
00527         """ __len__(self)
00528 
00529             Returns the length of the region to be drawn
00530         """
00531         return self.length
        

Definition at line 532 of file _AbstractDrawer.py.

00532 
00533     def _current_track_start_end(self):        
00534         track = self._parent[self.current_track_level]
00535         if track.start is None:
00536             start = self.start
00537         else:
00538             start = max(self.start, track.start)
00539         if track.end is None:
00540             end = self.end
00541         else:
00542             end = min(self.end, track.end)
00543         return start, end

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 411 of file _AbstractDrawer.py.

00411 
00412     def _set_xcentre(self, value):
00413         import warnings
00414         import Bio
00415         warnings.warn("The _set_xcentre method and .xcentre attribute are deprecated; please use the .xcenter attribute instead", Bio.BiopythonDeprecationWarning)
        self.xcenter = value

Definition at line 420 of file _AbstractDrawer.py.

00420 
00421     def _set_ycentre(self, value):
00422         import warnings
00423         import Bio
00424         warnings.warn("The _set_ycentre method and .xcentre attribute are deprecated; please use the .ycenter attribute instead", Bio.BiopythonDeprecationWarning)
        self.ycenter = value
is_in_bounds(self, value)

    o value   A base position

    Returns 1 if the value is within the region selected for drawing

Definition at line 513 of file _AbstractDrawer.py.

00513 
00514     def is_in_bounds(self, value):
00515         """ is_in_bounds(self, value)
00516 
00517             o value   A base position
00518 
00519             Returns 1 if the value is within the region selected for drawing
00520         """
00521         if value >= self.start and value <= self.end:
00522             return 1
00523         return 0
00524 

Here is the call graph for this function:

Here is the caller graph for this function:

set_bounds(self, start, end)

    o start     The first base (or feature mark) to draw from

    o end       The last base (or feature mark) to draw to

    Sets start and end points for the drawing as a whole

Definition at line 490 of file _AbstractDrawer.py.

00490 
00491     def set_bounds(self, start, end):
00492         """ set_bounds(self, start, end)
00493 
00494             o start     The first base (or feature mark) to draw from
00495 
00496             o end       The last base (or feature mark) to draw to
00497 
00498             Sets start and end points for the drawing as a whole
00499         """
00500         low, high = self._parent.range()  # Extent of tracks
00501 
00502         if start is not None and end is not None and start > end:
00503             start, end = end, start
00504 
00505         if start is None or start < 0:  # Check validity of passed args and 
00506             start = 0   # default to 0
00507         if end is None or end < 0:
00508             end = high + 1  # default to track range top limit
00509         
00510         self.start, self.end = int(start), int(end)
00511         self.length = self.end - self.start + 1
00512 

def Bio.Graphics.GenomeDiagram._AbstractDrawer.AbstractDrawer.set_margins (   self,
  x,
  y,
  xl,
  xr,
  yt,
  yb 
)
set_margins(self, x, y, xl, xr, yt, yb)

    o x         Float(0->1), Absolute X margin as % of page

    o y         Float(0->1), Absolute Y margin as % of page

    o xl        Float(0->1), Left X margin as % of page

    o xr        Float(0->1), Right X margin as % of page

    o yt        Float(0->1), Top Y margin as % of page

    o yb        Float(0->1), Bottom Y margin as % of page

    Set the page margins as proportions of the page 0->1, and also
    set the page limits x0, y0 and xlim, ylim, and page center
    xorigin, yorigin, as well as overall page width and height

Definition at line 457 of file _AbstractDrawer.py.

00457 
00458     def set_margins(self, x, y, xl, xr, yt, yb):
00459         """ set_margins(self, x, y, xl, xr, yt, yb)
00460 
00461             o x         Float(0->1), Absolute X margin as % of page
00462 
00463             o y         Float(0->1), Absolute Y margin as % of page
00464 
00465             o xl        Float(0->1), Left X margin as % of page
00466 
00467             o xr        Float(0->1), Right X margin as % of page
00468 
00469             o yt        Float(0->1), Top Y margin as % of page
00470 
00471             o yb        Float(0->1), Bottom Y margin as % of page
00472 
00473             Set the page margins as proportions of the page 0->1, and also
00474             set the page limits x0, y0 and xlim, ylim, and page center
00475             xorigin, yorigin, as well as overall page width and height
00476         """
00477         # Set left, right, top and bottom margins
00478         xmargin_l = xl or x
00479         xmargin_r = xr or x
00480         ymargin_top = yt or y
00481         ymargin_btm = yb or y
00482         
00483         # Set page limits, center and height/width
00484         self.x0, self.y0 = self.pagesize[0]*xmargin_l, self.pagesize[1]*ymargin_btm
00485         self.xlim, self.ylim = self.pagesize[0]*(1-xmargin_r), self.pagesize[1]*(1-ymargin_top)
00486         self.pagewidth = self.xlim-self.x0
00487         self.pageheight = self.ylim-self.y0
00488         self.xcenter, self.ycenter = self.x0+self.pagewidth/2., self.y0+self.pageheight/2.
00489 
            
def Bio.Graphics.GenomeDiagram._AbstractDrawer.AbstractDrawer.set_page_size (   self,
  pagesize,
  orientation 
)
set_page_size(self, pagesize, orientation)

    o pagesize      Size of the output image, a tuple of pixels (width,
            height, or a string in the reportlab.lib.pagesizes
            set of ISO sizes.

    o orientation   String: 'landscape' or 'portrait'

    Set the size of the drawing

Definition at line 429 of file _AbstractDrawer.py.

00429 
00430     def set_page_size(self, pagesize, orientation):
00431         """ set_page_size(self, pagesize, orientation)
00432 
00433             o pagesize      Size of the output image, a tuple of pixels (width,
00434                             height, or a string in the reportlab.lib.pagesizes
00435                             set of ISO sizes.
00436 
00437             o orientation   String: 'landscape' or 'portrait'
00438 
00439             Set the size of the drawing
00440         """
00441         if type(pagesize) == type('a'):     # A string, so translate
00442             pagesize = page_sizes(pagesize)
00443         elif type(pagesize) == type((1,2)): # A tuple, so don't translate
00444             pagesize = pagesize
00445         else:
00446             raise ValueError, "Page size %s not recognised" % pagesize        
00447         shortside, longside = min(pagesize), max(pagesize)
00448 
00449         orientation = orientation.lower()
00450         if orientation not in ('landscape', 'portrait'):
00451             raise ValueError, "Orientation %s not recognised" % orientation
00452         if orientation == 'landscape':
00453             self.pagesize = (longside, shortside)
00454         else:
00455             self.pagesize = (shortside, longside)
00456 

Here is the call graph for this function:


Member Data Documentation

Definition at line 399 of file _AbstractDrawer.py.

Definition at line 409 of file _AbstractDrawer.py.

Definition at line 509 of file _AbstractDrawer.py.

Definition at line 510 of file _AbstractDrawer.py.

Definition at line 486 of file _AbstractDrawer.py.

Definition at line 452 of file _AbstractDrawer.py.

Definition at line 485 of file _AbstractDrawer.py.

Definition at line 405 of file _AbstractDrawer.py.

Definition at line 415 of file _AbstractDrawer.py.

Definition at line 483 of file _AbstractDrawer.py.

Definition at line 424 of file _AbstractDrawer.py.

Definition at line 484 of file _AbstractDrawer.py.


Property Documentation

Initial value:
property(fget = lambda self : self.xcenter,
                       fset = _set_xcentre,
                       doc="Backwards compatible alias for xcenter (DEPRECATED)")

Definition at line 416 of file _AbstractDrawer.py.

Initial value:
property(fget = lambda self : self.ycenter,
                       fset = _set_ycentre,
                       doc="Backwards compatible alias for ycenter (DEPRECATED)")

Definition at line 425 of file _AbstractDrawer.py.


The documentation for this class was generated from the following file: