Back to index

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

List of all members.

Public Member Functions

def __init__
def new_graph
def del_graph
def get_graphs
def get_ids
def range
def data_quartiles
def to_string
def __len__
def __getitem__
def __str__

Public Attributes

 id
 name

Private Attributes

 _next_id
 _graphs

Detailed Description

GraphSet

    Provides:

    Methods:

    o __init__(self, set_id=None, name=None)    Called on instantiation

    o new_graph(self, data, name, style='bar', color=colors.lightgreen,
              altcolor=colors.darkseagreen)    Create new graph in the set
                      from the passed data, with the passed parameters

    o del_graph(self, graph_id) Delete graph with the passed id

    o get_graphs(self)  Returns a list of all graphs

    o get_ids(self)     Returns a list of graph ids

    o range(self)       Returns the range covered by the graphs in the set

    o to_string(self, verbose=0)    Returns a string describing the set

    o __len__(self)     Returns the length of sequence covered by the set

    o __getitem__(self, key)    Returns the graph with the id of the passed key

    o __str__(self)     Returns a string describing the set

    Attributes:

    o id        Unique identifier for the set

    o name      String describing the set

Definition at line 37 of file _GraphSet.py.


Constructor & Destructor Documentation

def Bio.Graphics.GenomeDiagram._GraphSet.GraphSet.__init__ (   self,
  name = None 
)
__init__(self, name=None)

    o name      String identifying the graph set sensibly

Definition at line 73 of file _GraphSet.py.

00073 
00074     def __init__(self, name=None):
00075         """ __init__(self, name=None)
00076 
00077             o name      String identifying the graph set sensibly
00078         """
00079         self.id = id            # Unique identifier for the set
00080         self._next_id = 0       # Holds unique ids for graphs
00081         self._graphs = {}       # Holds graphs, keyed by unique id
00082         self.name = name        # Holds description of graph
00083 

Here is the caller graph for this function:


Member Function Documentation

__getitem__(self, key) -> Graph

    Return a graph, keyed by id

Definition at line 213 of file _GraphSet.py.

00213 
00214     def __getitem__(self, key):
00215         """ __getitem__(self, key) -> Graph
00216 
00217             Return a graph, keyed by id
00218         """
00219         return self._graphs[key]
00220 

Here is the caller graph for this function:

__len__(self) -> int

    Return the number of graphs in the set

Definition at line 205 of file _GraphSet.py.

00205 
00206     def __len__(self):
00207         """ __len__(self) -> int
00208 
00209             Return the number of graphs in the set
00210         """
00211         return len(self._graphs)
00212 

__str__(self) -> ""

    Returns a formatted string with information about the feature set

Definition at line 221 of file _GraphSet.py.

00221 
00222     def __str__(self):
00223         """ __str__(self) -> ""
00224 
00225             Returns a formatted string with information about the feature set
00226         """
00227         outstr = ["\n<%s: %s>" % (self.__class__, self.name)]
00228         outstr.append("%d graphs" % len(self._graphs))
00229         outstr = "\n".join(outstr)
00230         return outstr
00231 

Here is the caller graph for this function:

data_quartiles(self) -> (float, float, float, float, float)

    Returns the (minimum, lowerQ, medianQ, upperQ, maximum) values as
    a tuple

Definition at line 172 of file _GraphSet.py.

00172 
00173     def data_quartiles(self):
00174         """ data_quartiles(self) -> (float, float, float, float, float)
00175 
00176             Returns the (minimum, lowerQ, medianQ, upperQ, maximum) values as
00177             a tuple
00178         """
00179         data = []
00180         for graph in self._graphs.values():
00181             data += graph.data.values()
00182         data.sort()
00183         datalen = len(data)
00184         return(data[0], data[datalen/4], data[datalen/2],
00185                data[3*datalen/4], data[-1])
00186 

del_graph(self, graph_id)

    o graph_id        Identifying value of the graph

    Remove a graph from the set, indicated by its id

Definition at line 130 of file _GraphSet.py.

00130 
00131     def del_graph(self, graph_id):
00132         """ del_graph(self, graph_id)
00133 
00134             o graph_id        Identifying value of the graph
00135 
00136             Remove a graph from the set, indicated by its id
00137         """
00138         del self._graphs[graph_id]
00139 

get_graphs(self) -> [Graph, Graph, ...]

    Return a list of all graphs in the graph set, sorted by id (for
    reliable stacking...)

Definition at line 140 of file _GraphSet.py.

00140 
00141     def get_graphs(self):
00142         """ get_graphs(self) -> [Graph, Graph, ...]
00143 
00144             Return a list of all graphs in the graph set, sorted by id (for
00145             reliable stacking...)
00146         """
00147         ids = self._graphs.keys()
00148         ids.sort()
00149         return [self._graphs[id] for id in ids]
00150 

get_ids(self) -> [int, int, ...]

    Return a list of all ids for the graph set

Definition at line 151 of file _GraphSet.py.

00151 
00152     def get_ids(self):
00153         """ get_ids(self) -> [int, int, ...]
00154 
00155             Return a list of all ids for the graph set
00156         """
00157         return self._graphs.keys()
00158 

def Bio.Graphics.GenomeDiagram._GraphSet.GraphSet.new_graph (   self,
  data,
  name = None,
  style = 'bar',
  color = colors.lightgreen,
  altcolor = colors.darkseagreen,
  linewidth = 1,
  center = None,
  colour = None,
  altcolour = None,
  centre = None 
)
new_graph(self, data, name=None, style='bar', color=colors.lightgreen,
  altcolor=colors.darkseagreen)

    o data      List of (position, value) int tuples

    o name      String, description of the graph

    o style     String ('bar', 'heat', 'line') describing how the graph
        will be drawn

    o color    colors.Color describing the color to draw all or 'high'
       (some styles) data (overridden by backwards compatible
       argument with UK spelling, colour).

    o altcolor  colors.Color describing the color to draw 'low' (some
        styles) data (overridden by backwards compatible argument
        with UK spelling, colour).
    
    o linewidth     Float describing linewidth for graph

    o center        Float setting the value at which the x-axis
            crosses the y-axis (overridden by backwards
            compatible argument with UK spelling, centre)

    Add a GraphData object to the diagram (will be stored
    internally

Definition at line 86 of file _GraphSet.py.

00086 
00087                   colour=None, altcolour=None, centre=None):
00088         """ new_graph(self, data, name=None, style='bar', color=colors.lightgreen,
00089                   altcolor=colors.darkseagreen)
00090 
00091             o data      List of (position, value) int tuples
00092 
00093             o name      String, description of the graph
00094 
00095             o style     String ('bar', 'heat', 'line') describing how the graph
00096                         will be drawn
00097 
00098             o color    colors.Color describing the color to draw all or 'high'
00099                        (some styles) data (overridden by backwards compatible
00100                        argument with UK spelling, colour).
00101 
00102             o altcolor  colors.Color describing the color to draw 'low' (some
00103                         styles) data (overridden by backwards compatible argument
00104                         with UK spelling, colour).
00105             
00106             o linewidth     Float describing linewidth for graph
00107 
00108             o center        Float setting the value at which the x-axis
00109                             crosses the y-axis (overridden by backwards
00110                             compatible argument with UK spelling, centre)
00111 
00112             Add a GraphData object to the diagram (will be stored
00113             internally
00114         """
00115         #Let the UK spelling (colour) override the USA spelling (color)
00116         if colour is not None:
00117             color = colour
00118         if altcolour is not None:
00119             altcolor = altcolour
00120         if centre is not None:
00121             center = centre
00122 
00123         id = self._next_id                              # get id number
00124         graph = GraphData(id, data, name, style, color, altcolor, center)
00125         graph.linewidth = linewidth
00126         self._graphs[id] =  graph                       # add graph data
00127         self._next_id += 1                              # increment next id
00128         return graph
00129 

range(self) -> (int, int)

    Returns the lowest and highest base (or mark) numbers as a tuple

Definition at line 159 of file _GraphSet.py.

00159 
00160     def range(self):
00161         """ range(self) -> (int, int)
00162 
00163             Returns the lowest and highest base (or mark) numbers as a tuple
00164         """
00165         lows, highs = [], []
00166         for graph in self._graphs.values():
00167             low, high = graph.range()
00168             lows.append(low)
00169             highs.append(high)
00170         return (min(lows), max(highs))
00171 

to_string(self, verbose=0) -> ""

    o verbose       Flag indicating whether a short or complete account
            of the set is required

    Returns a formatted string with information about the set

Definition at line 187 of file _GraphSet.py.

00187 
00188     def to_string(self, verbose=0):
00189         """ to_string(self, verbose=0) -> ""
00190 
00191             o verbose       Flag indicating whether a short or complete account
00192                             of the set is required
00193 
00194             Returns a formatted string with information about the set
00195         """
00196         if not verbose:
00197             return "%s" % self
00198         else:
00199             outstr = ["\n<%s: %s>" % (self.__class__, self.name)]
00200             outstr.append("%d graphs" % len(self._graphs))
00201             for key in self._graphs:
00202                 outstr.append("%s" % self._graphs[key])
00203             return "\n".join(outstr)
00204 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 80 of file _GraphSet.py.

Definition at line 79 of file _GraphSet.py.

Definition at line 78 of file _GraphSet.py.

Definition at line 81 of file _GraphSet.py.


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