Back to index

python-biopython  1.60
Classes | Functions | Variables
Bio.KEGG.Enzyme Namespace Reference

Classes

class  Record

Functions

def parse
def _test

Variables

list rxn_wrap
list name_wrap
list id_wrap
list struct_wrap

Function Documentation

def Bio.KEGG.Enzyme._test ( ) [private]
Run the Bio.KEGG.Enzyme module's doctests.

This will try and locate the unit tests directory, and run the doctests
from there in order that the relative paths used in the examples work.

Definition at line 295 of file __init__.py.

00295 
00296 def _test():
00297     """Run the Bio.KEGG.Enzyme module's doctests.
00298     
00299     This will try and locate the unit tests directory, and run the doctests
00300     from there in order that the relative paths used in the examples work.
00301     """
00302     import doctest
00303     import os
00304     if os.path.isdir(os.path.join("..","..","..","Tests")):
00305         print "Runing doctests..."
00306         cur_dir = os.path.abspath(os.curdir)
00307         os.chdir(os.path.join("..","..","..","Tests"))
00308         doctest.testmod()
00309         os.chdir(cur_dir)
00310         del cur_dir
00311         print "Done"

def Bio.KEGG.Enzyme.parse (   handle)
Parse a KEGG Enzyme file, returning Record objects.

This is an iterator function, typically used in a for loop.  For
example, using one of the example KEGG files in the Biopython
test suite,

>>> handle = open("KEGG/enzyme.sample")
>>> for record in parse(handle):
...     print record.entry, record.name[0]
...
1.1.1.1 Alcohol dehydrogenase
1.1.1.62 Estradiol 17beta-dehydrogenase
1.1.1.68 Transferred to EC 1.7.99.5
1.6.5.3 NADH dehydrogenase (ubiquinone)
1.14.13.28 3,9-Dihydroxypterocarpan 6a-monooxygenase
2.4.1.68 Glycoprotein 6-alpha-L-fucosyltransferase
3.1.1.6 Acetylesterase
2.7.2.1 Acetate kinase

Definition at line 181 of file __init__.py.

00181 
00182 def parse(handle):
00183     """Parse a KEGG Enzyme file, returning Record objects.
00184 
00185     This is an iterator function, typically used in a for loop.  For
00186     example, using one of the example KEGG files in the Biopython
00187     test suite,
00188 
00189     >>> handle = open("KEGG/enzyme.sample")
00190     >>> for record in parse(handle):
00191     ...     print record.entry, record.name[0]
00192     ...
00193     1.1.1.1 Alcohol dehydrogenase
00194     1.1.1.62 Estradiol 17beta-dehydrogenase
00195     1.1.1.68 Transferred to EC 1.7.99.5
00196     1.6.5.3 NADH dehydrogenase (ubiquinone)
00197     1.14.13.28 3,9-Dihydroxypterocarpan 6a-monooxygenase
00198     2.4.1.68 Glycoprotein 6-alpha-L-fucosyltransferase
00199     3.1.1.6 Acetylesterase
00200     2.7.2.1 Acetate kinase
00201     """
00202     record = Record()
00203     for line in handle:
00204         if line[:3]=="///":
00205             yield record
00206             record = Record()
00207             continue
00208         if line[:12]!="            ":
00209             keyword = line[:12]
00210         data = line[12:].strip()
00211         if keyword=="ENTRY       ":
00212             words = data.split()
00213             record.entry = words[1]
00214         elif keyword=="CLASS       ":
00215             record.classname.append(data)
00216         elif keyword=="COFACTOR    ":
00217             record.cofactor.append(data)
00218         elif keyword=="COMMENT     ":
00219             record.comment.append(data)
00220         elif keyword=="DBLINKS     ":
00221             if ":" in data:
00222                 key, values = data.split(":")
00223                 values = values.split()
00224                 row = (key, values)
00225                 record.dblinks.append(row)
00226             else:
00227                 row = record.dblinks[-1]
00228                 key, values = row
00229                 values.extend(data.split())
00230                 row = key, values
00231                 record.dblinks[-1] = row
00232         elif keyword=="DISEASE     ":
00233             if ":" in data:
00234                 database, data = data.split(":")
00235                 number, name = data.split(None, 1)
00236                 row = (database, number, name)
00237                 record.disease.append(row)
00238             else:
00239                 row = record.disease[-1]
00240                 database, number, name = row
00241                 name = name + " " + data
00242                 row = database, number, name
00243                 record.disease[-1] = row
00244         elif keyword=="EFFECTOR    ":
00245              record.effector.append(data.strip(";"))
00246         elif keyword=="GENES       ":
00247             if data[3:5]==': ':
00248                 key, values = data.split(":",1)
00249                 values = [value.split("(")[0] for value in values.split()]
00250                 row = (key, values)
00251                 record.genes.append(row)
00252             else:
00253                 row = record.genes[-1]
00254                 key, values = row
00255                 for value in data.split():
00256                     value = value.split("(")[0]
00257                     values.append(value)
00258                 row = key, values
00259                 record.genes[-1] = row
00260         elif keyword=="INHIBITOR   ":
00261              record.inhibitor.append(data.strip(";"))
00262         elif keyword=="NAME        ":
00263              record.name.append(data.strip(";"))
00264         elif keyword=="PATHWAY     ":
00265             if data[:5]=='PATH:':
00266                 path, map, name = data.split(None,2)
00267                 pathway = (path[:-1], map, name)
00268                 record.pathway.append(pathway)
00269             else:
00270                 pathway = record.pathway[-1]
00271                 path, map, name = pathway
00272                 name = name + " " + data
00273                 pathway = path, map, name
00274                 record.pathway[-1] = pathway
00275         elif keyword=="PRODUCT     ":
00276              record.product.append(data.strip(";"))
00277         elif keyword=="REACTION    ":
00278              record.reaction.append(data.strip(";"))
00279         elif keyword=="STRUCTURES  ":
00280             if data[:4]=='PDB:':
00281                 database = data[:3]
00282                 accessions = data[4:].split()
00283                 row = (database, accessions)
00284                 record.structures.append(row)
00285             else:
00286                 row = record.structures[-1]
00287                 database, accessions = row
00288                 accessions.extend(data.split())
00289                 row = (database, accessions)
00290                 record.structures[-1] = row
00291         elif keyword=="SUBSTRATE   ":
00292              record.substrate.append(data.strip(";"))
00293         elif keyword=="SYSNAME     ":
00294              record.sysname.append(data.strip(";"))


Variable Documentation

Initial value:
00001 lambdaindent:[indent, "",
00002                            (" ","",1,0)]

Definition at line 30 of file __init__.py.

Initial value:
00001 [0, "",
00002              (" ","$",1,1),
00003              ("-","$",1,1)]

Definition at line 27 of file __init__.py.

Initial value:
00001 [0, "",
00002             (" + ","",1,1),
00003             (" = ","",1,1),
00004             (" ","$",1,1),
00005             ("-","$",1,1)]

Definition at line 22 of file __init__.py.

Initial value:
00001 lambdaindent:[indent, "",
00002                                ("  ","",1,1)]

Definition at line 32 of file __init__.py.