Back to index

python-biopython  1.60
Classes | Functions
Bio.Motif.Parsers.MAST Namespace Reference

Classes

class  Record

Functions

def read
def __read_version
def __read_database_and_motifs
def __read_section_i
def __read_section_ii
def __read_section_iii

Function Documentation

def Bio.Motif.Parsers.MAST.__read_database_and_motifs (   record,
  handle 
) [private]

Definition at line 58 of file MAST.py.

00058 
00059 def __read_database_and_motifs(record, handle):
00060     for line in handle:
00061         if line.startswith('DATABASE AND MOTIFS'):
00062             break
00063     line = handle.next()
00064     if not line.startswith('****'):
00065         raise ValueError("Line does not start with '****':\n%s" % line)
00066     line = handle.next()
00067     if not 'DATABASE' in line:
00068         raise ValueError("Line does not contain 'DATABASE':\n%s" % line)
00069     words = line.strip().split()
00070     record.database = words[1]
00071     if words[2] == '(nucleotide)':
00072         record.alphabet = IUPAC.unambiguous_dna
00073     elif words[2] == '(peptide)':
00074         record.alphabet = IUPAC.protein
00075     for line in handle:
00076         if 'MOTIF WIDTH' in line:
00077             break
00078     line = handle.next()
00079     if not '----' in line:
00080         raise ValueError("Line does not contain '----':\n%s" % line)
00081     for line in handle:
00082         if not line.strip():
00083             break
00084         words = line.strip().split()
00085         motif = MEMEMotif()
00086         motif.alphabet = record.alphabet
00087         motif.name = words[0]
00088         motif.length = int(words[1])
00089         # motif.add_instance(words[2])
00090         record.motifs.append(motif)
00091 

Here is the caller graph for this function:

def Bio.Motif.Parsers.MAST.__read_section_i (   record,
  handle 
) [private]

Definition at line 92 of file MAST.py.

00092 
00093 def __read_section_i(record, handle):
00094     for line in handle:
00095         if line.startswith('SECTION I:'):
00096             break
00097     for line in handle:
00098         if line.startswith('SEQUENCE NAME'):
00099             break
00100     line = handle.next()
00101     if not line.startswith('---'):
00102         raise ValueError("Line does not start with '---':\n%s" % line)
00103     for line in handle:
00104         if not line.strip():
00105             break
00106         else:
00107             sequence, description_evalue_length = line.split(None, 1)
00108             record.sequences.append(sequence)
00109     line = handle.next()
00110     if not line.startswith('****'):
00111         raise ValueError("Line does not start with '****':\n%s" % line)
00112 

Here is the caller graph for this function:

def Bio.Motif.Parsers.MAST.__read_section_ii (   record,
  handle 
) [private]

Definition at line 113 of file MAST.py.

00113 
00114 def __read_section_ii(record, handle):
00115     for line in handle:
00116         if line.startswith('SECTION II:'):
00117             break
00118     for line in handle:
00119         if line.startswith('SEQUENCE NAME'):
00120             break
00121     line = handle.next()
00122     if not line.startswith('---'):
00123         raise ValueError("Line does not start with '---':\n%s" % line)
00124     for line in handle:
00125         if not line.strip():
00126             break
00127         elif line.startswith(" "):
00128             diagram = line.strip()
00129             record.diagrams[sequence] += diagram
00130         else:
00131             sequence, pvalue, diagram = line.split()
00132             record.diagrams[sequence] = diagram
00133     line = handle.next()
00134     if not line.startswith('****'):
00135         raise ValueError("Line does not start with '****':\n%s" % line)
00136 

Here is the caller graph for this function:

def Bio.Motif.Parsers.MAST.__read_section_iii (   record,
  handle 
) [private]

Definition at line 137 of file MAST.py.

00137 
00138 def __read_section_iii(record, handle):
00139     for line in handle:
00140         if line.startswith('SECTION III:'):
00141             break
00142     for line in handle:
00143         if line.startswith('****'):
00144             break
00145     for line in handle:
00146         if line.startswith('*****'):
00147             break
00148     for line in handle:
00149         if line.strip():
00150             break

Here is the caller graph for this function:

def Bio.Motif.Parsers.MAST.__read_version (   record,
  handle 
) [private]

Definition at line 49 of file MAST.py.

00049 
00050 def __read_version(record, handle):
00051     for line in handle:
00052         if "MAST version" in line:
00053             break
00054     else:
00055         raise ValueError("Improper input file. Does not begin with a line with 'MAST version'")
00056     record.version = line.strip().split()[2]
00057 

Here is the caller graph for this function:

def Bio.Motif.Parsers.MAST.read (   handle)
read(handle)

Definition at line 35 of file MAST.py.

00035 
00036 def read(handle):
00037     """read(handle)"""
00038     record = Record()
00039     __read_version(record, handle)
00040     __read_database_and_motifs(record, handle)
00041     __read_section_i(record, handle)
00042     __read_section_ii(record, handle)
00043     __read_section_iii(record, handle)
00044     return record
00045 
00046 
00047 # Everything below is private
00048 

Here is the call graph for this function: