ó
ÜÙÐHc           @   së   d  Z  d d l m Z d „  Z d „  Z e ƒ  Z d „  Z d „  Z d „  Z e	 d k rç d	 GHd
 d d Z
 d
 d d Z e e
 ƒ e e ƒ k s— t ‚ d e e
 ƒ k s¯ t ‚ d e e
 ƒ k sÇ t ‚ d e e ƒ k sß t ‚ d GHn  d S(   s3   Functions to calculate assorted sequence checksums.iÿÿÿÿ(   t   crc32c         C   s3   y t  |  j ƒ  ƒ SWn t k
 r. t  |  ƒ SXd S(   s@   Returns the crc32 checksum for a sequence (string or Seq object)N(   t   _crc32t   tostringt   AttributeError(   t   seq(    (    sˆ   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqUtils/CheckSum.pyR       s    c          C   s™   g  }  xŒ t  d ƒ D]~ } | } d } x\ t  d ƒ D]N } | d @} | d L} | d @rc | d O} n  | d L} | r2 | d N} q2 q2 W|  j | ƒ q W|  S(	   Ni   i    i   i   l    i   l      0 l        (   t   ranget   append(   t   _table_ht   it   lt   part_ht   jt   rflag(    (    sˆ   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqUtils/CheckSum.pyt   _init_table_h   s    


 
 c         C   sy   d } d } x\ |  D]T } | d @d >} | d ?} | d ?| B} | t  | ƒ Ad @} | t | A} | } q Wd | | f S(   s@   Returns the crc64 checksum for a sequence (string or Seq object)i    iÿ   i   i   s   CRC-%08X%08X(   t   ordR   (   t   st   crclt   crcht   ct   shrt   temp1ht   temp1lt   idx(    (    sˆ   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqUtils/CheckSum.pyt   crc64(   s    

c         C   sƒ   d } } t  |  ƒ t  d ƒ k r1 |  j ƒ  }  n  xG |  D]? } | d 7} | | t | j ƒ  ƒ 7} | d k r8 d } q8 q8 W| d S(   sŽ  Returns the GCG checksum (int) for a sequence (string or Seq object)

    Given a nucleotide or amino-acid secuence (or any string),
    returns the GCG checksum (int). Checksum used by GCG program.
    seq type = str.
    Based on BioPerl GCG_checksum. Adapted by Sebastian Bassi
    with the help of John Lenton, Pablo Ziliani, and Gabriel Genellina.
    All sequences are converted to uppercase i    t   aai   i9   i'  (   t   typeR   R   t   upper(   R   t   indext   checksumt   char(    (    sˆ   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqUtils/CheckSum.pyt   gcg7   s    	

 c         C   sï   y d d l  } | j ƒ  } Wn d d l } | j ƒ  } n Xd d l } t |  ƒ t d ƒ k rw |  j ƒ  j ƒ  }  n |  j ƒ  }  | j |  ƒ y  | j	 | j
 ƒ  ƒ j d ƒ SWn8 d d l } | j | j
 ƒ  ƒ j d d ƒ j d ƒ SXd S(   sX  Returns the SEGUID (string) for a sequence (string or Seq object)
    
    Given a nucleotide or amino-acid secuence (or any string),
    returns the SEGUID string (A SEquence Globally Unique IDentifier).
    seq type = str. 
    For more information about SEGUID, see:
    http://bioinformatics.anl.gov/seguid/
    DOI: 10.1002/pmic.200600032 iÿÿÿÿNR   t   =s   
t    (   t   hashlibt   sha1t   shat   newt   base64R   R   R   t   updatet	   b64encodet   digestt   rstript   ost   encodestringt   replace(   R   R!   t   mR#   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/CheckSum.pyt   seguidI   s     	 t   __main__s   Quick self testt,   QSALTQPASVSGSPGQSITISCTGTSSDVGSYNLVSWYQQHPGKt,   APKLMIYEGSKRPSGVSNRFSGSKSGNTASLTISGLQAEDEADYt   YCSSYAGSSTLVFGGGTKLTVLt   YCCSYAGSSTWVFGGGTKLTVLs   CRC-44CAAD88706CC153t   BpBeDdcNUYNsdk46JoJdw7Pd3BIt   X5XEaayob1nZLOc7eVT9qyczarYt   DoneN(   t   __doc__t   binasciiR    R   R   R   R   R   R.   t   __name__t   str_light_chain_onet   str_light_chain_twot   AssertionError(    (    (    sˆ   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/SeqUtils/CheckSum.pyt   <module>   s    							"