Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.Pathway.Reaction Class Reference

List of all members.

Public Member Functions

def __init__
def __eq__
def __ne__
def __hash__
def __repr__
def __str__
def reverse
def species

Public Attributes

 reactants
 catalysts
 data
 reversible

Detailed Description

Abstraction for a biochemical transformation.

This class represents a (potentially reversible) biochemical
transformation of the type:

  a S1 + b S2 + ... --> c P1 + d P2 + ...

where
- a, b, c, d ... are positive numeric stochiometric coefficients,
- S1, S2, ... are substrates
- P1, P2, ... are products

A Reaction should be viewed as the net result of one or more individual
reaction steps, where each step is potentially facilitated by a different
catalyst. Support for 'Reaction algebra' will be added at some point in
the future.

Attributes:

reactants   -- map of involved species to their stochiometric coefficients:
                 reactants[S] = stochiometric constant for S
catalysts   -- list of tuples of catalysts required for this reaction
reversible  -- true iff reaction is reversible
data        -- reference to arbitrary additional data

Invariants:

for all S in reactants: reactants[S] != 0
for all C in catalysts: catalysts[C] != 0

Definition at line 36 of file __init__.py.


Constructor & Destructor Documentation

def Bio.Pathway.Reaction.__init__ (   self,
  reactants = {},
  catalysts = [],
  reversible = 0,
  data = None 
)
Initializes a new Reaction object.

Definition at line 70 of file __init__.py.

00070 
00071                  reversible = 0, data = None):
00072         """Initializes a new Reaction object."""
00073         # enforce invariants on reactants:
00074         self.reactants = reactants.copy()
00075         # loop over original, edit the copy
00076         for r, value in reactants.iteritems():
00077             if value == 0:
00078                 del self.reactants[r]
00079         self.catalysts  = sorted(set(catalysts))
00080         self.data       = data
00081         self.reversible = reversible


Member Function Documentation

def Bio.Pathway.Reaction.__eq__ (   self,
  r 
)
Returns true iff self is equal to r.

Definition at line 82 of file __init__.py.

00082 
00083     def __eq__(self, r):
00084         """Returns true iff self is equal to r."""
00085         return isinstance(r, Reaction) and \
00086                self.reactants == r.reactants and \
00087                self.catalysts == r.catalysts and \
00088                self.data == r.data and \
00089                self.reversible == r.reversible
        

Here is the caller graph for this function:

Returns a hashcode for self.

Definition at line 94 of file __init__.py.

00094 
00095     def __hash__(self):
00096         """Returns a hashcode for self."""
00097         t = tuple(self.species())
00098         return hash(t)

Here is the call graph for this function:

def Bio.Pathway.Reaction.__ne__ (   self,
  r 
)
Returns true iff self is not equal to r.

Definition at line 90 of file __init__.py.

00090 
00091     def __ne__(self, r):
00092         """Returns true iff self is not equal to r."""
00093         return not self.__eq__(r)

Here is the call graph for this function:

Returns a debugging string representation of self.

Definition at line 99 of file __init__.py.

00099 
00100     def __repr__(self):
00101         """Returns a debugging string representation of self."""
00102         return "Reaction(" + \
00103                ",".join(map(repr,[self.reactants,
00104                                   self.catalysts,
00105                                   self.data,
00106                                   self.reversible])) + ")"

Returns a string representation of self.

Definition at line 107 of file __init__.py.

00107 
00108     def __str__(self):
00109         """Returns a string representation of self."""
00110         substrates = ""
00111         products   = ""
00112         all_species = sorted(self.reactants)
00113         for species in all_species:
00114             stoch = self.reactants[species]
00115             if stoch < 0:
00116                 # species is a substrate:
00117                 if substrates != "":
00118                     substrates = substrates + " + "
00119                 if stoch != -1:
00120                     substrates = substrates + str(abs(stoch)) + " "
00121                 substrates = substrates + str(species)
00122             elif stoch > 0:
00123                 # species is a product:
00124                 if products != "":
00125                     products = products + " + "
00126                 if stoch != 1:
00127                     products = products + str(stoch) + " "
00128                 products = products + str(species)
00129             else:
00130                 raise AttributeError("Invalid 0 coefficient in Reaction.reactants")
00131         if self.reversible:
00132             return substrates + " <=> " + products
00133         else:
00134             return substrates + " --> " + products

Returns a new Reaction that is the reverse of self.

Definition at line 135 of file __init__.py.

00135 
00136     def reverse(self):
00137         """Returns a new Reaction that is the reverse of self."""
00138         reactants = {}
00139         for r in self.reactants:
00140             reactants[r] = - self.reactants[r]
00141         return Reaction(reactants, self.catalysts,
00142                         self.reversible, self.data)

Here is the caller graph for this function:

Returns a list of all Species involved in self.

Definition at line 143 of file __init__.py.

00143 
00144     def species(self):
00145         """Returns a list of all Species involved in self."""
00146         return self.reactants.keys()
00147 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 78 of file __init__.py.

Definition at line 79 of file __init__.py.

Definition at line 73 of file __init__.py.

Definition at line 80 of file __init__.py.


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