Back to index

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

Classes

class  Record

Functions

def parse
def read
def __read

Function Documentation

def Bio.ExPASy.Enzyme.__read (   handle) [private]

Definition at line 105 of file Enzyme.py.

00105 
00106 def __read(handle):
00107     record = None
00108     for line in handle:
00109         key, value = line[:2], line[5:].rstrip()
00110         if key=="ID":
00111             record = Record()
00112             record["ID"] = value
00113         elif key=="DE":
00114             record["DE"]+=value
00115         elif key=="AN":
00116             if record["AN"] and not record["AN"][-1].endswith("."):
00117                 record["AN"][-1] += " " + value
00118             else:
00119                 record["AN"].append(value)
00120         elif key=="CA":
00121             record["CA"] += value
00122         elif key=="DR":
00123             pair_data = value.rstrip(";").split(';')
00124             for pair in pair_data:
00125                 t1, t2 = pair.split(',')
00126                 row = [t1.strip(), t2.strip()]
00127                 record["DR"].append(row)
00128         elif key=="CF":
00129             if record["CF"]:
00130                 record["CF"] += " " + value
00131             else:
00132                 record["CF"] = value
00133         elif key=="PR":
00134             assert value.startswith("PROSITE; ")
00135             value = value[9:].rstrip(";")
00136             record["PR"].append(value)
00137         elif key=='CC':
00138             if value.startswith("-!- "):
00139                 record["CC"].append(value[4:])
00140             elif value.startswith("    ") and record["CC"]:
00141                 record["CC"][-1] += value[3:]
00142             # copyright notice is silently skipped
00143         elif key=="//":
00144             if record:
00145                 return record
00146             else: # This was the copyright notice
00147                 continue
00148     if record:
00149         raise ValueError("Unexpected end of stream")

Here is the caller graph for this function:

def Bio.ExPASy.Enzyme.parse (   handle)
Parse ENZYME records.

This function is for parsing ENZYME files containing multiple
records.

handle   - handle to the file.

Definition at line 23 of file Enzyme.py.

00023 
00024 def parse(handle):
00025     """Parse ENZYME records.
00026 
00027     This function is for parsing ENZYME files containing multiple
00028     records.
00029 
00030     handle   - handle to the file."""
00031 
00032     while True:
00033         record = __read(handle)
00034         if not record:
00035             break
00036         yield record

Here is the call graph for this function:

def Bio.ExPASy.Enzyme.read (   handle)
Read one ENZYME record.

This function is for parsing ENZYME files containing
exactly one record.

handle   - handle to the file.

Definition at line 37 of file Enzyme.py.

00037 
00038 def read(handle):
00039     """Read one ENZYME record.
00040 
00041     This function is for parsing ENZYME files containing
00042     exactly one record.
00043 
00044     handle   - handle to the file."""
00045 
00046     record = __read(handle)
00047     # We should have reached the end of the record by now
00048     remainder = handle.read()
00049     if remainder:
00050         raise ValueError("More than one ENZYME record found")
00051     return record
00052 

Here is the call graph for this function: