Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
Bio.Graphics.GenomeDiagram._Feature.Feature Class Reference

List of all members.

Public Member Functions

def __init__
def set_feature
def get_feature
def set_colour
def set_color
def __getattr__

Public Attributes

 parent
 id
 color
 border
 hide
 sigil
 arrowhead_length
 arrowshaft_height
 name_qualifiers
 label
 label_font
 label_size
 label_color
 label_angle
 label_position
 locations
 type
 strand
 name
 end

Private Member Functions

def __process_feature

Private Attributes

 _colortranslator
 _feature

Detailed Description

Class to wrap Bio.SeqFeature objects for GenomeDiagram

    Provides:

    Methods:

    o __init__(self, parent=None, feature_id=None, feature=None,
             color=colors.lightgreen) Called when the feature is
             instantiated

    o set_feature(self, feature) Wrap the passed feature

    o get_feature(self) Return the unwrapped Bio.SeqFeature object

    o set_color(self, color) Set the color in which the feature will
            be drawn (accepts multiple formats: reportlab color.Color()
            tuple and color.name, or integer representing Artemis color

    o get_color(self) Returns color.Color tuple of the feature's color

    o __getattr__(self, name) Catches attribute requests and passes them to
            the wrapped Bio.SeqFeature object

    Attributes:

    o parent    FeatureSet, container for the object

    o id        Unique id

    o color    color.Color, color to draw the feature

    o hide      Boolean for whether the feature will be drawn or not

    o sigil     String denoting the type of sigil to use for the feature.
                Currently either "BOX" or "ARROW" are supported.

    o arrowhead_length  Float denoting length of the arrow head to be drawn,
                        relative to the bounding box height.  The arrow shaft
                        takes up the remainder of the bounding box's length.

    o arrowshaft_height  Float denoting length of the representative arrow
                         shaft to be drawn, relative to the bounding box height.
                         The arrow head takes the full height of the bound box.
     
    o name_qualifiers   List of Strings, describes the qualifiers that may
                contain feature names in the wrapped Bio.SeqFeature object

    o label     Boolean, 1 if the label should be shown

    o label_font    String describing the font to use for the feature label

    o label_size    Int describing the feature label font size

    o label_color  color.Color describing the feature label color

    o label_angle   Float describing the angle through which to rotate the
                feature label in degrees (default = 45, linear only)

    o label_position    String, 'start', 'end' or 'middle' denoting where
                to place the feature label (linear only)

    o locations     List of tuples of (start, end) ints describing where the
                feature and any subfeatures start and end

    o type      String denoting the feature type

    o name      String denoting the feature name

    o strand    Int describing the strand on which the feature is found

Definition at line 34 of file _Feature.py.


Constructor & Destructor Documentation

def Bio.Graphics.GenomeDiagram._Feature.Feature.__init__ (   self,
  parent = None,
  feature_id = None,
  feature = None,
  color = colors.lightgreen,
  label = 0,
  border = None,
  colour = None 
)
__init__(self, parent=None, feature_id=None, feature=None,
 color=colors.lightgreen, label=0)

    o parent    FeatureSet containing the feature

    o feature_id    Unique id for the feature

    o feature   Bio.SeqFeature object to be wrapped

    o color    color.Color Color to draw the feature (overridden
       by backwards compatible argument with UK spelling,
       colour).  Either argument is overridden if 'color'
       is found in feature qualifiers

    o border   color.Color Color to draw the feature border, use
       None for the same as the fill color, False for no border.

    o label     Boolean, 1 if the label should be shown

Definition at line 107 of file _Feature.py.

00107 
00108                  color=colors.lightgreen, label=0, border=None, colour=None):
00109         """ __init__(self, parent=None, feature_id=None, feature=None,
00110                  color=colors.lightgreen, label=0)
00111 
00112             o parent    FeatureSet containing the feature
00113 
00114             o feature_id    Unique id for the feature
00115 
00116             o feature   Bio.SeqFeature object to be wrapped
00117 
00118             o color    color.Color Color to draw the feature (overridden
00119                        by backwards compatible argument with UK spelling,
00120                        colour).  Either argument is overridden if 'color'
00121                        is found in feature qualifiers
00122 
00123             o border   color.Color Color to draw the feature border, use
00124                        None for the same as the fill color, False for no border.
00125 
00126             o label     Boolean, 1 if the label should be shown
00127         """
00128         #Let the UK spelling (colour) override the USA spelling (color)
00129         if colour is not None:
00130             color = colour
00131 
00132         self._colortranslator = ColorTranslator()
00133         
00134         # Initialise attributes
00135         self.parent = parent
00136         self.id = feature_id        
00137         self.color = color            # default color to draw the feature
00138         self.border = border
00139         self._feature = None            # Bio.SeqFeature object to wrap
00140         self.hide = 0                   # show by default
00141         self.sigil = 'BOX'
00142         self.arrowhead_length = 0.5 # 50% of the box height
00143         self.arrowshaft_height = 0.4 # 40% of the box height
00144         self.name_qualifiers = ['gene', 'label', 'name', 'locus_tag', 'product']
00145         self.label = label
00146         self.label_font = 'Helvetica'
00147         self.label_size = 6
00148         self.label_color = colors.black
00149         self.label_angle = 45
00150         self.label_position = 'start'
00151         
00152         if feature is not None:
00153             self.set_feature(feature)

Here is the caller graph for this function:


Member Function Documentation

__getattr__(self, name) -> various

    If the Feature class doesn't have the attribute called for,
    check in self._feature for it

Definition at line 233 of file _Feature.py.

00233 
00234     def __getattr__(self, name):
00235         """ __getattr__(self, name) -> various
00236 
00237             If the Feature class doesn't have the attribute called for,
00238             check in self._feature for it
00239         """
00240         return getattr(self._feature, name) # try to get the attribute from the feature
00241 
00242 
    
__process_feature(self)

    Examine the feature to be wrapped, and set some of the Feature's
    properties accordingly

Definition at line 165 of file _Feature.py.

00165 
00166     def __process_feature(self):
00167         """ __process_feature(self)
00168 
00169             Examine the feature to be wrapped, and set some of the Feature's
00170             properties accordingly
00171         """
00172         self.locations = []
00173         bounds = []
00174         if self._feature.sub_features == []:
00175             start = self._feature.location.nofuzzy_start
00176             end = self._feature.location.nofuzzy_end
00177             #if start > end and self.strand == -1:
00178             #    start, end = end, start
00179             self.locations.append((start, end))
00180             bounds += [start, end]
00181         else:
00182             for subfeature in self._feature.sub_features:
00183                 start = subfeature.location.nofuzzy_start
00184                 end = subfeature.location.nofuzzy_end
00185                 #if start > end and self.strand == -1:
00186                 #    start, end = end, start
00187                 self.locations.append((start, end))                
00188                 bounds += [start, end]
00189         self.type = str(self._feature.type)                     # Feature type
00190         #TODO - Strand can vary with subfeatures (e.g. mixed strand tRNA)
00191         if self._feature.strand is None:
00192             #This is the SeqFeature default (None), but the drawing code
00193             #only expects 0, +1 or -1.
00194             self.strand = 0
00195         else:
00196             self.strand = int(self._feature.strand)                 # Feature strand
00197         if 'color' in self._feature.qualifiers:                # Artemis color (if present)
00198             self.color = self._colortranslator.artemis_color( \
00199                                          self._feature.qualifiers['color'][0])
00200         self.name = self.type
00201         for qualifier in self.name_qualifiers:            
00202             if qualifier in self._feature.qualifiers:
00203                 self.name = self._feature.qualifiers[qualifier][0]
00204                 break
00205         #Note will be 0 to N for origin wrapping feature on genome of length N 
00206         self.start, self.end = min(bounds), max(bounds)
00207 

Here is the caller graph for this function:

get_feature(self) -> Bio.SeqFeature

    Returns the unwrapped Bio.SeqFeature object

Definition at line 208 of file _Feature.py.

00208 
00209     def get_feature(self):
00210         """ get_feature(self) -> Bio.SeqFeature
00211 
00212             Returns the unwrapped Bio.SeqFeature object
00213         """
00214         return self._feature

set_color(self, color)

    o color    The color to draw the feature - either a colors.Color
       object, an RGB tuple of floats, or an integer
       corresponding to colors in colors.txt
           
    Set the color in which the feature will be drawn

Definition at line 220 of file _Feature.py.

00220 
00221     def set_color(self, color):
00222         """ set_color(self, color)
00223 
00224             o color    The color to draw the feature - either a colors.Color
00225                        object, an RGB tuple of floats, or an integer
00226                        corresponding to colors in colors.txt
00227                            
00228             Set the color in which the feature will be drawn
00229         """
00230         #TODO - Make this into the set method for a color property?
00231         color = self._colortranslator.translate(color)
00232         self.color = color

Backwards compatible variant of set_color(self, color) using UK spelling.

Definition at line 215 of file _Feature.py.

00215 
00216     def set_colour(self, colour):
00217         """Backwards compatible variant of set_color(self, color) using UK spelling."""
00218         color = self._colortranslator.translate(colour)
00219         self.color = color

set_feature(self, feature)

    o feature   Bio.SeqFeature object to be wrapped

    Defines the Bio.SeqFeature object to be wrapped

Definition at line 154 of file _Feature.py.

00154 
00155     def set_feature(self, feature):
00156         """ set_feature(self, feature)
00157 
00158             o feature   Bio.SeqFeature object to be wrapped
00159 
00160             Defines the Bio.SeqFeature object to be wrapped
00161         """
00162         self._feature = feature
00163         self.__process_feature()
00164 

Here is the call graph for this function:


Member Data Documentation

Definition at line 131 of file _Feature.py.

Definition at line 138 of file _Feature.py.

Definition at line 141 of file _Feature.py.

Definition at line 142 of file _Feature.py.

Definition at line 137 of file _Feature.py.

Definition at line 136 of file _Feature.py.

Definition at line 205 of file _Feature.py.

Definition at line 139 of file _Feature.py.

Definition at line 135 of file _Feature.py.

Definition at line 144 of file _Feature.py.

Definition at line 148 of file _Feature.py.

Definition at line 147 of file _Feature.py.

Definition at line 145 of file _Feature.py.

Definition at line 149 of file _Feature.py.

Definition at line 146 of file _Feature.py.

Definition at line 171 of file _Feature.py.

Definition at line 199 of file _Feature.py.

Definition at line 143 of file _Feature.py.

Definition at line 134 of file _Feature.py.

Definition at line 140 of file _Feature.py.

Definition at line 193 of file _Feature.py.

Definition at line 188 of file _Feature.py.


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