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  """ 
 8  This module provides code to import KEGG Pathway maps for use with 
 9  the Biopython Pathway module. 
10   
11  The pathway maps are in the format: 
12   
13  RXXXXX:[X.X.X.X:] A + 2 B <=> C 
14  RXXXXX:[X.X.X.X:] 3C <=> 2 D + E 
15  ... 
16   
17  where RXXXXX is a five-digit reaction id, and X.X.X.X is the optional 
18  EC number of the enzyme that catalyze the reaction. 
19  """ 
20   
21  from Bio.Pathway import Reaction 
22   
23   
24 -def parse(handle):
25 for line in handle: 26 data, catalysts, reaction = line.split(":") 27 catalysts = [(catalysts,)] 28 reactants = {} 29 before, after = reaction.split("<=>") 30 compounds = before.split(" + ") 31 for compound in compounds: 32 compound = compound.strip() 33 try: 34 number, compound = compound.split() 35 number = -int(number) 36 except ValueError: 37 number = -1 38 reactants[compound] = number 39 compounds = after.split(" + ") 40 for compound in compounds: 41 compound = compound.strip() 42 try: 43 number, compound = compound.split() 44 number = int(number) 45 except ValueError: 46 number = +1 47 reactants[compound] = number 48 yield Reaction(reactants, catalysts, True, data)
49