ó
,Č/Ic           @   sČ   d  Z  d d l Z d d l Z d d l m Z d d  Z d d  Z d d  Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d d  Z d d  Z d d  Z d d  Z d d  Z d S(   s?   Miscellaneous functions for dealing with sequences (obsolete?).i˙˙˙˙N(   t   default_managerc         C   si   d d l  } | j d d d d t  | d k r= d } n
 d | } t j |  j |  } | j |   S(	   s"   Translate a sequence (DEPRECATED).i˙˙˙˙Ns1   Bio.utils.translate() has been deprecated, and wes6    intend to remove it in a future release of Biopython.s7    Please use the translate method or function in Bio.Seqs'    instead, as described in the Tutorial.t
   translators   translator.id.%d(   t   warningst   warnt   DeprecationWarningt   NoneR    t   resolvet   alphabett	   translate(   t   seqt   idR   t   sR   (    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyR      s    	
c         C   si   d d l  } | j d d d d t  | d k r= d } n
 d | } t j |  j |  } | j |   S(	   sF   Translate a sequence up to the first in frame stop codon (DEPRECATED).i˙˙˙˙Ns9   Bio.utils.translate_to_stop() has been deprecated, and wes6    intend to remove it in a future release of Biopython.s7    Please use the translate method or function in Bio.Seqs'    instead, as described in the Tutorial.R   s   translator.id.%d(   R   R   R   R   R    R   R   t   translate_to_stop(   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/utils.pyR      s    	
c         C   se   d d l  } | j d d d t  | d k r9 d } n
 d | } t j |  j |  } | j |   S(   s'   Back-translate a sequence (DEPRECATED).i˙˙˙˙Ns6   Bio.utils.back_translate() has been deprecated, and wes6    intend to remove it in a future release of Biopython.s3    If you use it, please tell us on the mailing list.R   s   translator.id.%d(   R   R   R   R   R    R   R   t   back_translate(   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/utils.pyR   ,   s    	
c         C   sJ   d d l  } | j d d d d t  t j |  j d  } | j |   S(   s#   Transcribe a sequence (DEPRECATED).i˙˙˙˙Ns2   Bio.utils.transcribe() has been deprecated, and wes6    intend to remove it in a future release of Biopython.s0    Please use the transcribe method or function ins/    Bio.Seq instead, as described in the Tutorial.t   transcriber(   R   R   R   R    R   R   t
   transcribe(   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/utils.pyR   ;   s    c         C   sJ   d d l  } | j d d d d t  t j |  j d  } | j |   S(   s(   Back-transcribe a sequence (DEPRECATED).i˙˙˙˙Ns7   Bio.utils.back_transcribe() has been deprecated, and wes6    intend to remove it in a future release of Biopython.s5    Please use the back_transcribe method or function ins/    Bio.Seq instead, as described in the Tutorial.R   (   R   R   R   R    R   R   t   back_transcribe(   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/utils.pyR   F   s    c         C   s^   |  j  } g  } x- |  j D]" } | | k r | j |  q q Wt j d j |  |  j j  S(   s@   given a sequence with gap encoding, return the ungapped sequencet    (   t   gap_chart   datat   appendt   Seqt   joinR   (   R	   t   gapt   letterst   c(    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyt   ungapQ   s    	c         C   s`   i  } x |  j  j D] } d | | <q Wy  x |  j D] } | | q4 WWn t k
 r[ d SXd S(   Ni   i    (   R   R   R   t   KeyError(   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/utils.pyt   verify_alphabet\   s    c         C   s7   i  } x* |  j  j D] } |  j j |  | | <q W| S(   N(   R   R   R   t   count(   R	   t   dictR   (    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyt   count_monomersg   s    c         C   sI   i  } t  |   } t |   } x$ | D] } | | d | | | <q% W| S(   Ng      Y@(   t   lenR   (   R	   t   dict2t   seq_lenR   t   m(    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyt   percent_monomerso   s    g        c         C   s5   | } x( t  |  d |   D] } | | | } q W| S(   NR   (   t   getattr(   R	   t   tablet   zerot   totalR   (    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyt   sumw   s    c   	      C   s]   | \ } } t  |  d |   } x2 | D]* } | | \ } } | | } | | } q% W| | f S(   NR   (   R%   (	   R	   R&   R'   t   xt   yR   R   t   x2t   y2(    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyt   sum_2ple~   s    
c         C   s1   | d  k r$ t j |  j d  } n  t |  |  S(   Nt   weight_table(   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/utils.pyt   total_weight   s    c         C   s1   | d  k r$ t j |  j d  } n  t |  |  S(   Nt   weight_range_table(   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/utils.pyt   total_weight_range   s    c         C   s   | d k rS t j } d | _ x | D] } | j | 7_ q% Wt | j  | _ n  t j d |  } x |  D] } | | | 7} ql W| S(   sB   given an amino-acid sequence, return it in reduced alphabet form based
       on the letter-translation table passed. Some "standard" tables are in
       Alphabet.Reduced.
       seq: a Seq.Seq type sequence
       reduction_table: a dictionary whose keys are the "from" alphabet, and values
       are the "to" alphabetR   N(   R   t   Alphabett   single_letter_alphabetR   R    t   sizeR   (   R	   t   reduction_tablet   new_alphabett   lettert   new_seq(    (    s|   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/utils.pyt   reduce_sequence   s    		(   g        g        (   t   __doc__R   R3   t   PropertyManagerR    R   R   R   R   R   R   R   R   R   R$   R)   R.   R0   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/utils.pyt   <module>   s"   							