Back to index

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

Classes

class  Record

Functions

def read
def parse
def __read_names
def __read_threshold
def __read_lengths
def __read_profilewidth
def __read_scores
def __read_query_alignment
def __read_positive_alignment
def __read_hit_alignment

Variables

dictionary __regex

Function Documentation

def Bio.Compass.__read_hit_alignment (   record,
  line 
) [private]

Definition at line 204 of file __init__.py.

00204 
00205 def __read_hit_alignment(record, line):
00206     m = __regex["start"].search(line)
00207     if m:
00208         record.hit_start = int(m.group(1))
00209     m = __regex["align"].match(line)
00210     assert m!=None, "invalid match"
00211     record.hit_aln += m.group(1)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_lengths (   record,
  line 
) [private]

Definition at line 162 of file __init__.py.

00162 
00163 def __read_lengths(record, line):
00164     if not line.startswith("length1="):
00165         raise ValueError("Line does not start with 'length1=':\n%s" % line)
00166     m = __regex["lengths"].search(line)
00167     record.query_length = int(m.group(1))
00168     record.query_filtered_length = float(m.group(2))
00169     record.hit_length = int(m.group(3))
00170     record.hit_filtered_length = float(m.group(4))

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_names (   record,
  line 
) [private]
Ali1: 60456.blo.gz.aln  Ali2: allscop//14984.blo.gz.aln
      ------query-----        -------hit-------------

Definition at line 145 of file __init__.py.

00145 
00146 def __read_names(record, line):
00147     """
00148     Ali1: 60456.blo.gz.aln  Ali2: allscop//14984.blo.gz.aln
00149           ------query-----        -------hit-------------
00150     """        
00151     if not "Ali1:" in line:
00152         raise ValueError("Line does not contain 'Ali1:':\n%s" % line)
00153     m = __regex["names"].search(line)
00154     record.query = m.group(1)
00155     record.hit = m.group(2)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_positive_alignment (   record,
  line 
) [private]

Definition at line 199 of file __init__.py.

00199 
00200 def __read_positive_alignment(record, line):
00201     m = __regex["positive_alignment"].match(line)
00202     assert m!=None, "invalid match"
00203     record.positives += m.group(1)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_profilewidth (   record,
  line 
) [private]

Definition at line 171 of file __init__.py.

00171 
00172 def __read_profilewidth(record, line):
00173     if not "Nseqs1" in line:
00174         raise ValueError("Line does not contain 'Nseqs1':\n%s" % line)
00175     m = __regex["profilewidth"].search(line)
00176     record.query_nseqs = int(m.group(1))
00177     record.query_neffseqs = float(m.group(2))
00178     record.hit_nseqs = int(m.group(3))
00179     record.hit_neffseqs = float(m.group(4))

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_query_alignment (   record,
  line 
) [private]

Definition at line 191 of file __init__.py.

00191 
00192 def __read_query_alignment(record, line):
00193     m = __regex["start"].search(line)
00194     if m:
00195         record.query_start = int(m.group(1))
00196     m = __regex["align"].match(line)
00197     assert m!=None, "invalid match"
00198     record.query_aln += m.group(1)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_scores (   record,
  line 
) [private]

Definition at line 180 of file __init__.py.

00180 
00181 def __read_scores(record, line):
00182     if not line.startswith("Smith-Waterman"):
00183         raise ValueError("Line does not start with 'Smith-Waterman':\n%s" % line)
00184     m = __regex["scores"].search(line)
00185     if m:
00186         record.sw_score = int(m.group(1))
00187         record.evalue = float(m.group(2))
00188     else:
00189         record.sw_score = 0
00190         record.evalue = -1.0

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.__read_threshold (   record,
  line 
) [private]

Definition at line 156 of file __init__.py.

00156 
00157 def __read_threshold(record,line):
00158     if not line.startswith("Threshold"):
00159         raise ValueError("Line does not start with 'Threshold':\n%s" % line)
00160     m = __regex["threshold"].search(line)
00161     record.gap_threshold = float(m.group(1))

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Compass.parse (   handle)

Definition at line 58 of file __init__.py.

00058 
00059 def parse(handle):
00060     record = None
00061     try:
00062         line = handle.next()
00063     except StopIteration:
00064         return
00065     while True:
00066         try:
00067             record = Record()
00068             __read_names(record, line)
00069             line = handle.next()
00070             __read_threshold(record, line)
00071             line = handle.next()
00072             __read_lengths(record, line)
00073             line = handle.next()
00074             __read_profilewidth(record, line)
00075             line = handle.next()
00076             __read_scores(record, line)
00077         except StopIteration:
00078             raise ValueError("Unexpected end of stream.")
00079         for line in handle:
00080             if not line.strip():
00081                 continue
00082             if "Ali1:" in line:
00083                 yield record
00084                 break
00085             __read_query_alignment(record, line)
00086             try:
00087                 line = handle.next()
00088                 __read_positive_alignment(record, line)
00089                 line = handle.next()
00090                 __read_hit_alignment(record, line)
00091             except StopIteration:
00092                 raise ValueError("Unexpected end of stream.")
00093         else:
00094             yield record
00095             break

Here is the call graph for this function:

def Bio.Compass.read (   handle)

Definition at line 26 of file __init__.py.

00026 
00027 def read(handle):
00028     record = None
00029     try:
00030         line = handle.next()
00031         record = Record()
00032         __read_names(record, line)
00033         line = handle.next()
00034         __read_threshold(record, line)
00035         line = handle.next()
00036         __read_lengths(record, line)
00037         line = handle.next()
00038         __read_profilewidth(record, line)
00039         line = handle.next()
00040         __read_scores(record, line)
00041     except StopIteration:
00042         if not record:
00043             raise ValueError("No record found in handle")
00044         else:
00045             raise ValueError("Unexpected end of stream.")
00046     for line in handle:
00047         if not line.strip(): # skip empty lines
00048             continue
00049         __read_query_alignment(record, line)
00050         try:
00051             line = handle.next()
00052             __read_positive_alignment(record, line)
00053             line = handle.next()
00054             __read_hit_alignment(record, line)
00055         except StopIteration:
00056             raise ValueError("Unexpected end of stream.")
00057     return record

Here is the call graph for this function:


Variable Documentation

dictionary Bio.Compass.__regex
Initial value:
00001 {"names": re.compile("Ali1:\s+(\S+)\s+Ali2:\s+(\S+)\s+"),
00002            "threshold": re.compile("Threshold of effective gap content in columns: (\S+)"),
00003            "lengths": re.compile("length1=(\S+)\s+filtered_length1=(\S+)\s+length2=(\S+)\s+filtered_length2=(\S+)"),
00004            "profilewidth": re.compile("Nseqs1=(\S+)\s+Neff1=(\S+)\s+Nseqs2=(\S+)\s+Neff2=(\S+)"),
00005            "scores": re.compile("Smith-Waterman score = (\S+)\s+Evalue = (\S+)"),
00006            "start": re.compile("(\d+)"),
00007            "align": re.compile("^.{15}(\S+)"),
00008            "positive_alignment": re.compile("^.{15}(.+)"),
00009           }

Definition at line 135 of file __init__.py.