Back to index

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

Classes

class  Statistics

Functions

def _build_dnal_cmdline
def _fgrep_count
def _alb_line2coords
def _get_coords
def _any
def align
def main
def _test

Variables

string __version__ = "$Revision: 1.12 $"
int _SCORE_MATCH = 4
int _SCORE_MISMATCH = 1
int _SCORE_GAP_START = 5
int _SCORE_GAP_EXTENSION = 1
list _CMDLINE_DNAL = ["dnal", "-alb", "-nopretty"]
string _CMDLINE_FGREP_COUNT = "fgrep -c '%s' %s"
tuple _re_alb_line2coords = re.compile(r"^\[([^:]+):[^\[]+\[([^:]+):")

Function Documentation

def Bio.Wise.dnal._alb_line2coords (   line) [private]

Definition at line 44 of file dnal.py.

00044 
00045 def _alb_line2coords(line):
00046     return tuple([int(coord)+1 # one-based -> zero-based
00047                   for coord
00048                   in _re_alb_line2coords.match(line).groups()])

def Bio.Wise.dnal._any (   seq,
  pred = bool 
) [private]

Definition at line 67 of file dnal.py.

00067 
00068 def _any(seq, pred=bool):
00069     "Returns True if pred(x) is True at least one element in the iterable"
00070     return True in itertools.imap(pred, seq)

def Bio.Wise.dnal._build_dnal_cmdline (   match,
  mismatch,
  gap,
  extension 
) [private]

Definition at line 30 of file dnal.py.

00030 
00031 def _build_dnal_cmdline(match, mismatch, gap, extension):
00032     res = _CMDLINE_DNAL[:]
00033     res.extend(["-match", str(match)])
00034     res.extend(["-mis", str(mismatch)])
00035     res.extend(["-gap", str(-gap)]) # negative: convert score to penalty
00036     res.extend(["-ext", str(-extension)])  # negative: convert score to penalty
00037 
00038     return res

Here is the caller graph for this function:

def Bio.Wise.dnal._fgrep_count (   pattern,
  file 
) [private]

Definition at line 40 of file dnal.py.

00040 
00041 def _fgrep_count(pattern, file):
00042     return int(commands.getoutput(_CMDLINE_FGREP_COUNT % (pattern, file)))

def Bio.Wise.dnal._get_coords (   filename) [private]

Definition at line 49 of file dnal.py.

00049 
00050 def _get_coords(filename):
00051     alb = file(filename)
00052 
00053     start_line = None
00054     end_line = None
00055 
00056     for line in alb:
00057         if line.startswith("["):
00058             if not start_line:
00059                 start_line = line # rstrip not needed
00060             else:
00061                 end_line = line
00062 
00063     if end_line is None: # sequence is too short
00064         return [(0, 0), (0, 0)]
00065         
00066     return zip(*map(_alb_line2coords, [start_line, end_line])) # returns [(start0, end0), (start1, end1)]

def Bio.Wise.dnal._test (   args,
  keywds 
) [private]

Definition at line 124 of file dnal.py.

00124 
00125 def _test(*args, **keywds):
00126     import doctest, sys
00127     doctest.testmod(sys.modules[__name__], *args, **keywds)

Here is the call graph for this function:

def Bio.Wise.dnal.align (   pair,
  match = _SCORE_MATCH,
  mismatch = _SCORE_MISMATCH,
  gap = _SCORE_GAP_START,
  extension = _SCORE_GAP_EXTENSION,
  keywds 
)

Definition at line 103 of file dnal.py.

00103 
00104 def align(pair, match=_SCORE_MATCH, mismatch=_SCORE_MISMATCH, gap=_SCORE_GAP_START, extension=_SCORE_GAP_EXTENSION, **keywds):
00105     cmdline = _build_dnal_cmdline(match, mismatch, gap, extension)
00106     temp_file = Wise.align(cmdline, pair, **keywds)
00107     try:
00108         return Statistics(temp_file.name, match, mismatch, gap, extension)
00109     except AttributeError:
00110         try:
00111             keywds['dry_run']
00112             return None
00113         except KeyError:
00114             raise

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 115 of file dnal.py.

00115 
00116 def main():
00117     import sys
00118     stats = align(sys.argv[1:3])
00119     print "\n".join(["%s: %s" % (attr, getattr(stats, attr))
00120                      for attr in
00121                      ("matches", "mismatches", "gaps", "extensions")])
00122     print "identity_fraction: %s" % stats.identity_fraction()
00123     print "coords: %s" % stats.coords

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

string Bio.Wise.dnal.__version__ = "$Revision: 1.12 $"

Definition at line 14 of file dnal.py.

list Bio.Wise.dnal._CMDLINE_DNAL = ["dnal", "-alb", "-nopretty"]

Definition at line 28 of file dnal.py.

string Bio.Wise.dnal._CMDLINE_FGREP_COUNT = "fgrep -c '%s' %s"

Definition at line 39 of file dnal.py.

tuple Bio.Wise.dnal._re_alb_line2coords = re.compile(r"^\[([^:]+):[^\[]+\[([^:]+):")

Definition at line 43 of file dnal.py.

Definition at line 26 of file dnal.py.

Definition at line 25 of file dnal.py.

Definition at line 23 of file dnal.py.

Definition at line 24 of file dnal.py.