• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

/home/mark/model/software/ScrumPy/ScrumPy/Bioinf/Biomass.py

00001 
00002 from ScrumPy.Util import Set
00003 
00004 import MolWts
00005 
00006 reload(MolWts)
00007 
00008 
00009 class Composition(dict):
00010 
00011     def __init__(self, ammount, components={}):
00012         
00013         self.ammount = float(ammount)
00014         self.update(components)
00015 
00016 
00017     def __float__(self):
00018         
00019         return self.ammount
00020 
00021     def Copy(self):
00022 
00023         components = {}
00024         for k in self.keys():
00025             if hasattr(self[k], "Copy"):
00026                 components[k] = self[k].Copy()
00027             else:
00028                 components[k] = self[k]
00029 
00030         return Composition(self.ammount, components)
00031 
00032 
00033     def AmmountOf(self, i):
00034 
00035         rv = 0.0
00036 
00037         if self.has_key(i):
00038             rv =  float(self) * float(self[i])
00039         
00040         else:
00041             for k in self:
00042                 rec = self[k]
00043                 if hasattr(rec, "AmmountOf"):
00044                     rv += float(self) * rec.AmmountOf(i)
00045                     
00046         return rv
00047 
00048 
00049     def MolsOf(self,i):
00050 
00051         return self.AmmountOf(i) / MolWts.MolWt(i)
00052     
00053 
00054     def GetLeaves(self):
00055 
00056         rv = []
00057 
00058         for k in self:
00059             if hasattr(self[k], "GetLeaves"):
00060                 rv.extend(self[k].GetLeaves())
00061             else:
00062                 rv.append(k)
00063         return rv
00064                         
00065             
00066 
00067         
00068                     
00069                     
00070     
00071 
00072  
00073 def WhatExports(m, compound):
00074 
00075     for reac in m.sm.InvolvedWith(compound).keys():
00076         if "_tx" in reac and len(Set.Intersect(m.sm.Externs, m.smexterns.InvolvedWith(reac).keys())) != 0:
00077             return reac

Generated on Tue Sep 4 2012 15:38:01 for ScrumPy by  doxygen 1.7.1