Package Bio :: Package KEGG :: Package Map
[hide private]
[frames] | no frames]

Source Code for Package Bio.KEGG.Map

 1  # Copyright 2001 by Tarjei Mikkelsen. All rights reserved. 
 2  # Copyright 2007 by Michiel de Hoon. All rights reserved. 
 3  # This code is part of the Biopython distribution and governed by its 
 4  # license.  Please see the LICENSE file that should have been included 
 5  # as part of this package. 
 6   
 7  """Load KEGG Pathway maps for use with the Biopython Pathway module. 
 8   
 9  The pathway maps are in the format:: 
10   
11      RXXXXX:[X.X.X.X:] A + 2 B <=> C 
12      RXXXXX:[X.X.X.X:] 3C <=> 2 D + E 
13      ... 
14   
15  where RXXXXX is a five-digit reaction id, and X.X.X.X is the optional 
16  EC number of the enzyme that catalyze the reaction. 
17  """ 
18   
19  from Bio.Pathway import Reaction 
20   
21   
22 -def parse(handle):
23 for line in handle: 24 data, catalysts, reaction = line.split(":") 25 catalysts = [(catalysts,)] 26 reactants = {} 27 before, after = reaction.split("<=>") 28 compounds = before.split(" + ") 29 for compound in compounds: 30 compound = compound.strip() 31 try: 32 number, compound = compound.split() 33 number = -int(number) 34 except ValueError: 35 number = -1 36 reactants[compound] = number 37 compounds = after.split(" + ") 38 for compound in compounds: 39 compound = compound.strip() 40 try: 41 number, compound = compound.split() 42 number = int(number) 43 except ValueError: 44 number = +1 45 reactants[compound] = number 46 yield Reaction(reactants, catalysts, True, data)
47