Back to index

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

Classes

class  Record
class  Reference

Functions

def read
def parse
def __read_prosite_reference_line
def __read_text_line
def __read_reference_start
def __read_reference_line
def __read_copyright_line
def __read

Function Documentation

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

Definition at line 117 of file Prodoc.py.

00117 
00118 def __read(handle):
00119     # Skip blank lines between records
00120     for line in handle:
00121         line = line.rstrip()
00122         if line and not line.startswith("//"):
00123             break
00124     else:
00125         return None
00126     record = Record()
00127     # Read the accession number
00128     if not line.startswith("{PDOC"):
00129         raise ValueError("Line does not start with '{PDOC':\n%s" % line)
00130     if line[-1] != '}':
00131         raise ValueError("I don't understand accession line\n%s" % line)
00132     record.accession = line[1:-1]
00133     # Read the Prosite references
00134     for line in handle:
00135         if line.startswith('{PS'):
00136             __read_prosite_reference_line(record, line)
00137         else:
00138             break
00139     else:
00140         raise ValueError("Unexpected end of stream.")
00141     # Read the actual text
00142     if not line.startswith('{BEGIN'):
00143         raise ValueError("Line does not start with '{BEGIN':\n%s" % line)
00144     read_line = __read_text_line
00145     for line in handle:
00146         if line.startswith('{END}'):
00147             # Clean up the record and return
00148             for reference in record.references:
00149                 reference.citation = reference.citation.rstrip()
00150                 reference.authors = reference.authors.rstrip()
00151             return record
00152         elif line[0] == '[' and line[3] == ']' and line[4] == ' ':
00153             __read_reference_start(record, line)
00154             read_line = __read_reference_line
00155         elif line.startswith('+----'):
00156             read_line = __read_copyright_line
00157         elif read_line:
00158             if not read_line(record, line):
00159                 read_line = None
00160     raise ValueError("Unexpected end of stream.")

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.ExPASy.Prodoc.__read_copyright_line (   record,
  line 
) [private]

Definition at line 111 of file Prodoc.py.

00111 
00112 def __read_copyright_line(record, line):
00113     # Skip the copyright statement
00114     if line.startswith('+----'):
00115         return False
00116     return True

def Bio.ExPASy.Prodoc.__read_prosite_reference_line (   record,
  line 
) [private]

Definition at line 76 of file Prodoc.py.

00076 
00077 def __read_prosite_reference_line(record, line):
00078     line = line.rstrip()
00079     if line[-1] != '}':
00080         raise ValueError("I don't understand the Prosite reference on line\n%s" % line)
00081     acc, name = line[1:-1].split('; ')
00082     record.prosite_refs.append((acc, name))

Here is the caller graph for this function:

def Bio.ExPASy.Prodoc.__read_reference_line (   record,
  line 
) [private]

Definition at line 99 of file Prodoc.py.

00099 
00100 def __read_reference_line(record, line):
00101     if not line.strip():
00102         return False
00103     reference = record.references[-1]
00104     if line.startswith('     '):
00105         if reference.authors[-1]==',':
00106             reference.authors += line[4:].rstrip()
00107         else:
00108             reference.citation += line[5:]
00109         return True
00110     raise Exception("I don't understand the reference line\n%s" % line)

def Bio.ExPASy.Prodoc.__read_reference_start (   record,
  line 
) [private]

Definition at line 87 of file Prodoc.py.

00087 
00088 def __read_reference_start(record, line):
00089     # Read the references
00090     reference = Reference()
00091     reference.number = line[1:3].strip()
00092     if line[1] == 'E':
00093         # If it's an electronic reference, then the URL is on the
00094         # line, instead of the author.
00095         reference.citation = line[4:].strip()
00096     else:
00097         reference.authors = line[4:].strip()
00098     record.references.append(reference)

Here is the caller graph for this function:

def Bio.ExPASy.Prodoc.__read_text_line (   record,
  line 
) [private]

Definition at line 83 of file Prodoc.py.

00083 
00084 def __read_text_line(record, line):
00085     record.text += line
00086     return True

def Bio.ExPASy.Prodoc.parse (   handle)

Definition at line 36 of file Prodoc.py.

00036 
00037 def parse(handle):
00038     while True:
00039         record = __read(handle)
00040         if not record:
00041             return
00042         yield record
 

Here is the call graph for this function:

def Bio.ExPASy.Prodoc.read (   handle)

Definition at line 28 of file Prodoc.py.

00028 
00029 def read(handle):
00030     record = __read(handle)
00031     # We should have reached the end of the record by now
00032     line = handle.readline()
00033     if line:
00034         raise ValueError("More than one Prodoc record found")
00035     return record

Here is the call graph for this function: