ó
>Ic           @   s•  d  Z  d d l Td d l m Z d Z d d d „  ƒ  YZ e ƒ  Z d „  Z d „  Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z e d „ Z d d  d „  ƒ  YZ d d! d „  ƒ  YZ d d" d „  ƒ  YZ d „  Z d „  Z d „  Z y d d l Z Wn e k
 r7nZ Xd d l Z e j e Z x= e j  j! ƒ  D], Z" e" j# d ƒ sae j  e" e j  e" <qaqaWd S(#   s  This package implements pairwise sequence alignment using a dynamic
programming algorithm.

This provides functions to get global and local alignments between two
sequences.  A global alignment finds the best concordance between all
characters in two sequences.  A local alignment finds just the
subsequences that align the best.

When doing alignments, you can specify the match score and gap
penalties.  The match score indicates the compatibility between an
alignment of two characters in the sequences.  Highly compatible
characters should be given positive scores, and incompatible ones
should be given negative scores or 0.  The gap penalties should be
negative.

The names of the alignment functions in this module follow the
convention
<alignment type>XX
where <alignment type> is either "global" or "local" and XX is a 2
character code indicating the parameters it takes.  The first
character indicates the parameters for matches (and mismatches), and
the second indicates the parameters for gap penalties.

The match parameters are
CODE  DESCRIPTION
x     No parameters.  Identical characters have score of 1, otherwise 0.
m     A match score is the score of identical chars, otherwise mismatch score.
d     A dictionary returns the score of any pair of characters.
c     A callback function returns scores.

The gap penalty parameters are
CODE  DESCRIPTION
x     No gap penalties.
s     Same open and extend gap penalties for both sequences.
d     The sequences have different open and extend gap penalties.
c     A callback function returns the gap penalties.

All the different alignment functions are contained in an object
"align".  For example:

    >>> from Bio import pairwise2
    >>> alignments = pairwise2.align.globalxx("ACCGT", "ACG")

will return a list of the alignments between the two strings.  The
parameters of the alignment function depends on the function called.
Some examples:

>>> pairwise2.align.globalxx("ACCGT", "ACG")
    # Find the best global alignment between the two sequences.
    # Identical characters are given 1 point.  No points are deducted
    # for mismatches or gaps.
    
>>> pairwise2.align.localxx("ACCGT", "ACG")
    # Same thing as before, but with a local alignment.
    
>>> pairwise2.align.globalmx("ACCGT", "ACG", 2, -1)
    # Do a global alignment.  Identical characters are given 2 points,
    # 1 point is deducted for each non-identical character.

>>> pairwise2.align.globalms("ACCGT", "ACG", 2, -1, -.5, -.1)
    # Same as above, except now 0.5 points are deducted when opening a
    # gap, and 0.1 points are deducted when extending it.


To see a description of the parameters for a function, please look at
the docstring for the function.

>>> print newalign.align.localds.__doc__
localds(sequenceA, sequenceB, match_dict, open, extend) -> alignments

iÿÿÿÿ(   t   *(   t   listfnsiè  t   alignc           B   s*   e  Z d  Z d d d „  ƒ  YZ d „  Z RS(   s1   This class provides functions that do alignments.t   alignment_functionc           B   sÁ   e  Z d  Z i g  d f d 6d d g d f d 6d g d f d	 6d
 g d f d 6Z i g  d f d 6d d g d f d 6d d d d g d f d	 6d d g d f d 6Z d „  Z d „  Z d „  Z RS(   sì   This class is callable impersonates an alignment function.
        The constructor takes the name of the function.  This class
        will decode the name of the function to figure out how to
        interpret the parameters.

        t    t   xt   matcht   mismatchsh   match is the score to given to identical characters.  mismatch is
the score given to non-identical ones.t   mt
   match_dicts   match_dict is a dictionary where the keys are tuples of pairs of
characters and the values are the scores, e.g. ("A", "C") : 2.5.t   dt   match_fns]   match_fn is a callback function that takes two characters and
returns the score between them.t   ct   opent   extendsb   open and extend are the gap penalties when a gap is opened and
extended.  They should be negative.t   st   openAt   extendAt   openBt   extendBs}   openA and extendA are the gap penalties for sequenceA, and openB
and extendB for sequeneB.  The penalties should be negative.t   gap_A_fnt   gap_B_fnsž   gap_A_fn and gap_B_fn are callback functions that takes 1) the
index where the gap is opened, and 2) the length of the gap.  They
should return a gap penalty.c         C   s½  | j  d ƒ r3 t | ƒ d k rr t d ƒ ‚ qr n? | j  d ƒ rf t | ƒ d k rr t d ƒ ‚ qr n t | ƒ ‚ | d  | d | d } } } y |  j | \ } } Wn# t k
 rÎ } t d	 | ƒ ‚ n Xy |  j | \ } }	 Wn# t k
 r} t d
 | ƒ ‚ n Xd d g }
 |
 j | ƒ |
 j | ƒ | |  _ | |  _ |
 |  _	 |  j |  _
 d |  j
 d j |  j	 ƒ f } | r| d | 7} n  |	 r¦| d |	 7} n  | d 7} | |  _ d  S(   Nt   globali   s   function should be globalXXt   locali   s   function should be localXXiþÿÿÿiÿÿÿÿs   unknown match type %rs   unknown penalty type %rt	   sequenceAt	   sequenceBs   %s(%s) -> alignments
s   , s   
%s
s
  
alignments is a list of tuples (seqA, seqB, score, begin, end).
seqA and seqB are strings showing the alignment between the
sequences.  score is the score of the alignment.  begin and end
are indexes into seqA and seqB that indicate the where the
alignment occurs.
(   t
   startswitht   lent   AttributeErrort
   match2argst   KeyErrort   penalty2argsR   t   function_namet
   align_typet   param_namest   __name__t   joint   __doc__(   t   selft   nameR!   t
   match_typet   penalty_typet
   match_argst	   match_docR   t   penalty_argst   penalty_docR"   t   doc(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   __init__Ž   s@     			c         O   sD  | j  ƒ  } t | ƒ t |  j ƒ k rU t d |  j t |  j ƒ t | ƒ f ƒ ‚ n  d } x.| t |  j ƒ k  r‹|  j | d k r¨ | | | |  j | <| d 7} q^ |  j | d	 k r|  j | d d
 k sØ t ‚ | | | | d } } t | | ƒ | d <| d 7} q^ |  j | d k rEt | | ƒ | d <| d 7} q^ |  j | d k rÙ|  j | d d k sut ‚ | | | | d } } | j d d ƒ } t	 | | | ƒ | d <t	 | | | ƒ | d <| d 7} q^ |  j | d k rq|  j | d d k s	t ‚ | | | d !\ }	 }
 } } | j d d ƒ } t	 |	 |
 | ƒ | d <t	 | | | ƒ | d <| d 7} q^ t
 d |  j | ƒ ‚ q^ W| j d d ƒ } d t d d ƒ f d t	 d d | ƒ f d t	 d d | ƒ f d d |  j d k f d |  j d k f d d  d! d" g
 } x* | D]" \ } } | j | | ƒ | | <qW| S(#   Ns'   %s takes exactly %d argument (%d given)i    R   R   R   R   R   i   R   R   i   R	   R   R   t   penalize_extend_when_openingR   i   R   i   s   unknown parameter %rt   penalize_end_gapsR   t   align_globallyt   gap_chart   -t   force_generict
   score_onlyt   one_alignment_only(   R   R   R   R   R   (   R0   i    (   R3   R4   (   R5   i    (   R6   i    (   R7   i    (   t   copyR   R"   t	   TypeErrorR    t   AssertionErrort   identity_matcht   dictionary_matcht   gett   affine_penaltyt
   ValueErrorR!   (   R&   t   argst   keywdst   iR   R   R   R   t   peR   R   R   R   t   default_paramsR'   t   default(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   decode½   sb    (
 		c         O   s   |  j  | | Ž  } t |   S(   N(   RF   t   _align(   R&   R@   RA   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   __call__ù   s    (   R#   t
   __module__R%   R   R   R/   RF   RH   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR   k   s(   	

	

		/	<c         C   s   |  j  | ƒ S(   N(   R   (   R&   t   attr(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   __getattr__ý   s    (    (   R#   RI   R%   R   RK   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR   h   s   ’c         C   s¼  |  s | r g  S|	 r® t  | ƒ t k r® | j t k r® t  | ƒ t k r® | j t k r® | j | j } } | j | j } } t |  | | | | | | | | | |
 ƒ } n$ t |  | | | | | | | |
 ƒ	 } | \ } } t | |  | | | | | ƒ } t	 g  | D] } | d ^ qƒ } |
 r)| Sd } d } x\ | t
 | ƒ k  r“| | \ } } t t | | ƒ ƒ t | ƒ k r†| | =q8| d 7} q8Wt |  | | | | | | | | ƒ	 } | S(   Ni    i   (   t   typet   InstanceTypet	   __class__R>   R   R   t   _make_score_matrix_fastt   _make_score_matrix_generict   _find_startt   maxR   t   rintt   abst   _recover_alignments(   R   R   R   R   R   R0   R1   R2   R3   R5   R6   R7   t   open_At   extend_At   open_Bt   extend_BR   t   score_matrixt   trace_matrixt   startst
   best_scoret	   toleranceRB   t   scoret   pos(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRG     sF    				#"
c	         C   sU  t  |  ƒ t  | ƒ }	 }
 g  g  } } x? t |	 ƒ D]1 } | j d  g |
 ƒ | j d  g g |
 ƒ q3 WxU t |	 ƒ D]G } | |  | | d ƒ } | r® | | d | ƒ 7} n  | | | d <qu WxX t d |
 ƒ D]G } | |  d | | ƒ } | r	| | d | ƒ 7} n  | | d | <qÐ Wx-t d |	 ƒ D]} xt d |
 ƒ D]} | | d | d } t | ƒ } | d | d f g } x° t d | d ƒ D]› } | | d | | | | d | ƒ } t | ƒ } | | k r | | } } | j | d | f ƒ q”| | k r”| | } } | d | f g } q”q”Wx° t d | d ƒ D]› } | | | d | | | d | ƒ } t | ƒ } | | k r³| | } } | j | | d f ƒ qG| | k rG| | } } | | d f g } qGqGW| | |  | | | ƒ | | | <| r5| | | d k  r5d | | | <n  | | | | <qAWq+W| | f S(   Ni    i   (   R   t   ranget   appendt   NoneRS   (   R   R   R   R   R   R0   R1   R2   R6   t   lenAt   lenBRZ   R[   RB   R_   t   rowt   colR]   t   best_score_rintt   best_indexest
   score_rint(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRP   ;  sX    
	'' c   #      C   s¼  t  d | | | ƒ } t  d | | | ƒ } t |  ƒ t | ƒ } } g  g  } } x? t | ƒ D]1 } | j d  g | ƒ | j d  g g | ƒ q] Wx[ t | ƒ D]M } | |  | | d ƒ } | rÞ | t  | | | | ƒ 7} n  | | | d <qŸ Wx^ t d | ƒ D]M } | |  d | | ƒ } | r?| t  | | | | ƒ 7} n  | | d | <q Wd  g | d d  g | d } } d  g | d d  g | d } } xA t | d ƒ D]/ } | | d | | | <| d f g | | <q¨WxA t | d ƒ D]/ } | d | | | | <d | f g | | <qìWxt d | ƒ D]} xvt d | ƒ D]e} | | d | d } | d k r~| | d } n
 | d } | d k r¥| | d } n
 | d } t | | | ƒ } t | ƒ } g  } | t | ƒ k r| j | d | d f ƒ n  | t | ƒ k r-| j | | d ƒ n  | t | ƒ k rW| j | | d ƒ n  | | |  | | | ƒ } |	 r–| d k  r–d | | | <n | | | | <| | | | <| | d | d | } | | d | }  t | ƒ t |  ƒ }! }" |! |" k r3| | | d <| d | d f g | | d <n{ |" |! k rP|  | | d <n^ | | | d <| d | d f | | d k r®| | d | d | d f g | | d <n  | | d | d | } | | d | }  t | ƒ t |  ƒ }! }" |! |" k r/| | | d <| d | d f g | | d <qE|" |! k rL|  | | d <qE| | | d <| d | d f | | d k rE| | d | d | d f g | | d <qEqEWq/W| | f S(   Ni   i    (   t   calc_affine_penaltyR   Ra   Rb   Rc   RR   RS   R   (#   R   R   R   RV   RW   RX   RY   R0   R1   R2   R6   t   first_A_gapt   first_B_gapRd   Re   RZ   R[   RB   R_   t   row_cache_scoret   row_cache_indext   col_cache_scoret   col_cache_indexRf   Rg   t   nogap_scoret	   row_scoret	   col_scoreR]   Rh   t
   best_indext
   open_scoret   extend_scoret   open_score_rintt   extend_score_rint(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRO   Œ  sš    		##

""#""+c	       
   C   s×  t  |  ƒ t  | ƒ }	 }
 g  } g  } x§ | D]Ÿ \ } \ } } | rS d \ } } n2 d  t |	 | |
 | ƒ d } } | s… d  } n  | j |  d d !| d d !| | | |	 |
 f | | f f ƒ | r, Pq, q, Wxû| rÌt  | ƒ t k  rÌ| j ƒ  \ } } } } } } } | \ } } | d  k r°t  | ƒ } |  |  | } | |  | } t | | | ƒ \ } } | d  k r‘| r~d } q‘t  | ƒ | } n  | j | | | | | f ƒ qÒ | \ } } | | | | } } t | | ƒ } | | | | } } |  | | | !| | | } | | | | !| | | } | } | r„| | | d k r„t | | ƒ } | j | | | | | | d  f ƒ qÒ xB | | | D]2 } | j | | | | | | | f ƒ | r“Pq“q“WqÒ Wt | ƒ S(   Ni   i    (   NN(   R   Rc   RR   Rb   t   MAX_ALIGNMENTSt   popt   _lpad_until_equalt   _clean_alignments(    R   R   R\   RZ   R[   R2   R1   R3   R7   Rd   Re   t
   tracebackst
   in_processR_   Rf   Rg   t   begint   endt   seqAt   seqBt   prev_post   next_post   prevAt   prevBt   prevlent   nextAt   nextBt   nseqAt   nseqBt   maxseqt   ngapAt   ngapB(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRU     sX    #	!	c         C   sX   | rH | r* t  | | |  | | d ƒ } qT t  | | |  d  d  d ƒ } n t |  ƒ } | S(   Ni   i    (   t   _find_global_startRc   t   _find_local_start(   RZ   R   R   R   R   R1   R2   R\   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRQ   a  s    c         C   sÿ   t  | ƒ t  | d ƒ } } g  } xg t | ƒ D]Y }	 | |	 | d }
 | rl |
 | | | |	 d ƒ 7}
 n  | j |
 |	 | d f f ƒ q0 Wxk t | d ƒ D]Y } | | d | }
 | rÚ |
 | | | | d ƒ 7}
 n  | j |
 | d | f f ƒ qž W| S(   Ni    i   (   R   Ra   Rb   (   R   R   RZ   R   R   R1   t   nrowst   ncolst	   positionsRf   R_   Rg   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR   p  s    !!c         C   s|   g  } t  |  ƒ t  |  d ƒ } } xR t | ƒ D]D } x; t | ƒ D]- } |  | | } | j | | | f f ƒ qC Wq0 W| S(   Ni    (   R   Ra   Rb   (   RZ   R”   R’   R“   Rf   Rg   R_   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR‘   …  s    !c         C   sÁ   t  j |  ƒ }  d } x¥ | t |  ƒ k  r¼ |  | \ } } } } } | d  k r^ t | ƒ } n | d k  r} | t | ƒ } n  | | k r– |  | =q n  | | | | | f |  | <| d 7} q W|  S(   Ni    i   (   R   t   itemsR   Rc   (   t
   alignmentsRB   R‚   Rƒ   R_   R€   R   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR}     s    c         C   sm   t  |  ƒ t  | ƒ } } | | k  r> t |  | | | ƒ }  n% | | k  rc t | | | | ƒ } n  |  | f S(   N(   R   t   _pad(   t   s1t   s2t   chart   ls1t   ls2(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   _pad_until_equal¤  s    c         C   sm   t  |  ƒ t  | ƒ } } | | k  r> t |  | | | ƒ }  n% | | k  rc t | | | | ƒ } n  |  | f S(   N(   R   t   _lpad(   R˜   R™   Rš   R›   Rœ   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR|   ­  s    c         C   s   |  | | S(   N(    (   R   Rš   t   n(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR—   ·  s    c         C   s   | | |  S(   N(    (   R   Rš   RŸ   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRž   »  s    c         C   s   t  |  | d ƒ S(   Ng      à?(   t   int(   R   t	   precision(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRS   À  s    R;   c           B   s&   e  Z d  Z d d d „ Z d „  Z RS(   sñ   identity_match([match][, mismatch]) -> match_fn

    Create a match function for use in an alignment.  match and
    mismatch are the scores to give when two residues are equal or
    unequal.  By default, match is 1 and mismatch is 0.

    i   i    c         C   s   | |  _  | |  _ d  S(   N(   R   R   (   R&   R   R   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR/   Ë  s    	c         C   s   | | k r |  j  S|  j S(   N(   R   R   (   R&   t   charAt   charB(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRH   Î  s    (   R#   RI   R%   R/   RH   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR;   Ã  s   R<   c           B   s#   e  Z d  Z d d „ Z d „  Z RS(   s¬  dictionary_match(score_dict[, symmetric]) -> match_fn

    Create a match function for use in an alignment.  score_dict is a
    dictionary where the keys are tuples (residue 1, residue 2) and
    the values are the match scores between those residues.  symmetric
    is a flag that indicates whether the scores are symmetric.  If
    true, then if (res 1, res 2) doesn't exist, I will use the score
    at (res 2, res 1).

    i   c         C   s   | |  _  | |  _ d  S(   N(   t
   score_dictt	   symmetric(   R&   R¤   R¥   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR/   Þ  s    	c         C   s?   |  j  r. | | f |  j k r. | | } } n  |  j | | f S(   N(   R¥   R¤   (   R&   R¢   R£   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRH   á  s    (   R#   RI   R%   R/   RH   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR<   Ó  s   
R>   c           B   s#   e  Z d  Z d d „ Z d „  Z RS(   s€   affine_penalty(open, extend[, penalize_extend_when_opening]) -> gap_fn

    Create a gap function for use in an alignment.

    i    c         C   sG   | d k s | d k r' t  d ƒ ‚ n  | | |  _ |  _ | |  _ d  S(   Ni    s%   Gap penalties should be non-positive.(   R?   R   R   R0   (   R&   R   R   R0   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR/   î  s    c         C   s   t  | |  j |  j |  j ƒ S(   N(   Rk   R   R   R0   (   R&   t   indext   length(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRH   ó  s    (   R#   RI   R%   R/   RH   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyR>   è  s   c         C   s5   |  d k r d S| | |  } | s1 | | 8} n  | S(   Ni    (    (   R§   R   R   R0   t   penalty(    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyRk   ÷  s    c         C   sþ   g  t  t |  d ƒ ƒ D] } g  ^ q } x` t  t |  ƒ ƒ D]L } xC t  t |  | ƒ ƒ D]+ } | | j t t |  | | ƒ ƒ ƒ qY Wq< Wt t | ƒ } x\ t  t |  ƒ ƒ D]H } x> t  t |  | ƒ ƒ D]& } | | } d | |  | | f GqË WHq® Wd S(   sL   print_matrix(matrix)

    Print out a matrix.  For debugging purposes.

    i    s   %*s N(   Ra   R   Rb   t   strt   mapRR   (   t   matrixR   t   matrixTRB   t   jt   ndigitsRŸ   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   print_matrixÿ  s    )-
c         C   si   g  } | j  d |  ƒ | j  d d | d | | f ƒ | j  d | ƒ | j  d | ƒ d j | ƒ S(   su   format_alignment(align1, align2, score, begin, end) -> string

    Format the alignment prettily into a string.

    s   %s
s   %s%s
t    t   |s     Score=%g
R   (   Rb   R$   (   t   align1t   align2R_   R€   R   R   (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   format_alignment  s    #Nt   __(    (    (    (    ($   R%   t   typest   BioR   Rz   R   RG   RP   RO   RU   RQ   R   R‘   R}   R   R|   R—   Rž   t
   _PRECISIONRS   R;   R<   R>   Rk   R¯   R´   t
   cpairwise2t   ImportErrort   syst   modulesR#   t   this_modulet   __dict__t   keysR'   R   (    (    (    s€   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/pairwise2.pyt   <module>L   sD   
—		9	Q	Š	K			
				
					