ó
âÏ Gc           @   s"   d  d l  Z  d „  Z d „  Z d S(   iÿÿÿÿNc         C   s‹  t  j d ƒ } t |  ƒ } y |  j ƒ  } Wn# t k
 rP |  j ƒ  j ƒ  } n Xd g } d g } xN t | ƒ D]@ } | j | d t | ƒ t  j | d t | ƒ ƒ | ƒ qp W|  d | !} | j	 d ƒ }	 | j	 d ƒ }
 | j	 d ƒ } | j	 d ƒ } | |	 } | |
 } | | } | | } | j | | | | ƒ |  d } x;t | | ƒ D])} | | d | | d !} | | d k r| j | d ƒ nÜ| d k r”|	 d }	 | j
 d ƒ rý|
 d }
 | |	 } | |
 } | j | | | | ƒ qy| j
 d ƒ rG| d } | |	 } | | } | j | | | | ƒ qy| j
 d ƒ ry| d } | |	 } | | } | j | | | | ƒ qynå| d k r‹|
 d }
 | j
 d ƒ rô|	 d }	 | |	 } | |
 } | j | | | | ƒ qy| j
 d ƒ r>| d } | |
 } | | } | j | | | | ƒ qy| j
 d ƒ ry| d } | |
 } | | } | j | | | | ƒ qynî| d k r‚| d } | j
 d ƒ rë|	 d }	 | |	 } | | } | j | | | | ƒ qy| j
 d ƒ r5|
 d }
 | |
 } | | } | j | | | | ƒ qy| j
 d ƒ ry| d } | | } | | } | j | | | | ƒ qyn÷ | d k ry| d } | j
 d ƒ râ|	 d }	 | |	 } | | } | j | | | | ƒ qy| j
 d ƒ r,|
 d }
 | |
 } | | } | j | | | | ƒ qy| j
 d ƒ ry| d } | | } | | } | j | | | | ƒ qyn  | d } qZW| S(	   sË  Local Composition Complexity (LCC) values over sliding window.

    Returns a list of floats, the LCC values for a sliding window over
    the sequence.

    seq - an unambiguous DNA sequence (a string or Seq object)
    wsize - window size, integer

    The result is the same as applying lcc_simp multiple times, but this
    version is optimized for speed. The optimization works by using the
    value of previous window as a base to compute the next one.i   i    i   t   At   Ct   Tt   Giÿÿÿÿ(   t   matht   logt   lent   uppert   AttributeErrort   tostringt   ranget   appendt   floatt   countt   endswith(   t   seqt   wsizet   l2t   tamseqR   t   componet   lccsalt   it   windowt   cant_at   cant_ct   cant_tt   cant_gt   term_at   term_ct   term_tt   term_gt   tailt   x(    (    sƒ   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqUtils/lcc.pyt   lcc_mult	   sÀ    		'














 









 









 









 c   	      C   s°  t  |  ƒ } y |  j ƒ  } Wn# t k
 rA |  j ƒ  j ƒ  } n Xt j d ƒ } d |  k rf d } n= | j d ƒ t | ƒ t j | j d ƒ t | ƒ ƒ | } d |  k r¸ d } n= | j d ƒ t | ƒ t j | j d ƒ t | ƒ ƒ | } d |  k r
d } n= | j d ƒ t | ƒ t j | j d ƒ t | ƒ ƒ | } d |  k r\d } n= | j d ƒ t | ƒ t j | j d ƒ t | ƒ ƒ | } | | | | } | S(   sQ  Local Composition Complexity (LCC) for a sequence.

    seq - an unambiguous DNA sequence (a string or Seq object)
    
    Returns the Local Composition Complexity (LCC) value for the entire
    sequence (as a float).

    Reference:
    Andrzej K Konopka (2005) Sequence Complexity and Composition
    DOI: 10.1038/npg.els.0005260
    i   R    i    R   R   R   (   R   R   R   R	   R   R   R   R   (	   R   R   R   R   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/SeqUtils/lcc.pyt   lcc_simpx   s0    	(	(	(	((   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/SeqUtils/lcc.pyt   <module>   s   	o