1
2
3
4
5
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
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