Back to index

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

Classes

class  Record

Functions

def parse
def _test

Variables

list name_wrap
list id_wrap
list struct_wrap

Function Documentation

def Bio.KEGG.Compound._test ( ) [private]
Run the Bio.KEGG.Compound 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 193 of file __init__.py.

00193 
00194 def _test():
00195     """Run the Bio.KEGG.Compound module's doctests.
00196     
00197     This will try and locate the unit tests directory, and run the doctests
00198     from there in order that the relative paths used in the examples work.
00199     """
00200     import doctest
00201     import os
00202     if os.path.isdir(os.path.join("..","..","..","Tests")):
00203         print "Runing doctests..."
00204         cur_dir = os.path.abspath(os.curdir)
00205         os.chdir(os.path.join("..","..","..","Tests"))
00206         doctest.testmod()
00207         os.chdir(cur_dir)
00208         del cur_dir
00209         print "Done"

def Bio.KEGG.Compound.parse (   handle)
Parse a KEGG Ligan/Compound 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/compound.sample")
>>> for record in parse(handle):
...     print record.entry, record.name[0]
...
C00023 Iron
C00017 Protein
C00099 beta-Alanine
C00294 Inosine
C00298 Trypsin
C00348 Undecaprenyl phosphate
C00349 2-Methyl-3-oxopropanoate
C01386 NH2Mec

Definition at line 120 of file __init__.py.

00120 
00121 def parse(handle):
00122     """Parse a KEGG Ligan/Compound file, returning Record objects.
00123 
00124     This is an iterator function, typically used in a for loop.  For
00125     example, using one of the example KEGG files in the Biopython
00126     test suite,
00127 
00128     >>> handle = open("KEGG/compound.sample")
00129     >>> for record in parse(handle):
00130     ...     print record.entry, record.name[0]
00131     ...
00132     C00023 Iron
00133     C00017 Protein
00134     C00099 beta-Alanine
00135     C00294 Inosine
00136     C00298 Trypsin
00137     C00348 Undecaprenyl phosphate
00138     C00349 2-Methyl-3-oxopropanoate
00139     C01386 NH2Mec
00140     """
00141     record = Record()
00142     for line in handle:
00143         if line[:3]=="///":
00144             yield record
00145             record = Record()
00146             continue
00147         if line[:12]!="            ":
00148             keyword = line[:12]
00149         data = line[12:].strip()
00150         if keyword=="ENTRY       ":
00151             words = data.split()
00152             record.entry = words[0]
00153         elif keyword=="NAME        ":
00154             data = data.strip(";")
00155             record.name.append(data)
00156         elif keyword=="ENZYME      ":
00157             while data:
00158                 column = data[:16]
00159                 data = data[16:]
00160                 if '(' in column:
00161                     entry = column.split()
00162                     enzyme = (entry[0], entry[1][1:-1])
00163                 else:
00164                     enzyme = (column.strip(), "")
00165                 record.enzyme.append(enzyme)
00166         elif keyword=="PATHWAY     ":
00167             if data[:5]=='PATH:':
00168                 path, map, name = data.split(None,2)
00169                 pathway = (path[:-1], map, name)
00170                 record.pathway.append(pathway)
00171             else:
00172                 pathway = record.pathway[-1]
00173                 path, map, name = pathway
00174                 name = name + " " + data
00175                 pathway = path, map, name
00176                 record.pathway[-1] = pathway
00177         elif keyword=="FORMULA     ":
00178             record.formula = data
00179         elif keyword=="MASS        ":
00180             record.mass = data
00181         elif keyword=="DBLINKS     ":
00182             if ":" in data:
00183                 key, values = data.split(":")
00184                 values = values.split()
00185                 row = (key, values)
00186                 record.dblinks.append(row)
00187             else:
00188                 row = record.dblinks[-1]
00189                 key, values = row
00190                 values.extend(data.split())
00191                 row = key, values
00192                 record.dblinks[-1] = row


Variable Documentation

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

Definition at line 26 of file __init__.py.

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

Definition at line 23 of file __init__.py.

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

Definition at line 28 of file __init__.py.