ó
"ˆIc           @   s¼   d  Z  d d l Z d d l Td d l m Z d d l m Z d e j f d „  ƒ  YZ d e j f d	 „  ƒ  YZ	 d
 e j f d „  ƒ  YZ
 e d k r¸ e j d d ƒ Z e j d e ƒ n  d S(   s:   Testing code for Restriction enzyme classes of Biopython.
iÿÿÿÿN(   t   *(   t   Seq(   t   IUPACAmbiguousDNAt   SimpleEnzymec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sH   Tests for dealing with basic enzymes using the Restriction package.
    c         C   s6   t  d t ƒ  ƒ } | t  t j t ƒ  ƒ | |  _ d  S(   Nt   AAAA(   R   R   t   EcoRIt   sitet   ecosite_seq(   t   selft   base_seq(    (    s   test_Restriction.pyt   setUp   s    c         C   s   d  S(   N(    (   R   (    (    s   test_Restriction.pyt   tearDown   s    c         C   s  t  j d k s t ‚ t  j ƒ  t k s- t ‚ t  j ƒ  t k sE t ‚ t  j ƒ  t k s] t ‚ t  j ƒ  d k su t ‚ t  j	 |  j
 ƒ d g k s– t ‚ t  j |  j
 ƒ } t | ƒ d k sÀ t ‚ | d j d k sÙ t ‚ t  j |  j
 ƒ } t | ƒ d k st ‚ d S(   s'   Test basic cutting with EcoRI.
        t   GAATTCs   G^AATT_Ci   i   i   t	   AATTCAAAAN(   R   R   t   AssertionErrort   is_bluntt   Falset   is_5overhangt   Truet   is_3overhangt	   elucidatet   searchR   t   catalyset   lent   datat   catalyze(   R   t   parts(    (    s   test_Restriction.pyt   test_eco_cutting   s    !c         C   sb   t  j |  j d t ƒ} t | ƒ d k s0 t ‚ t  j | d d t ƒ} | d g k s^ t ‚ d S(   s.   Deal with cutting circular sequences.
        t   lineari   i    N(   R   R   R   R   R   R   R   (   R   R   t	   locations(    (    s   test_Restriction.pyt   test_circular_sequences&   s    (   t   __name__t
   __module__t   __doc__R
   R   R   R   (    (    (    s   test_Restriction.pyR      s
   			t   EnzymeComparisonc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s)   Tests for comparing various enzymes.
    c         C   s   d  S(   N(    (   R   (    (    s   test_Restriction.pyR
   1   s    c         C   s   d  S(   N(    (   R   (    (    s   test_Restriction.pyR   4   s    c         C   sj   t  j ƒ  t t g k s t ‚ t  j ƒ  d k s6 t ‚ t j ƒ  d k sN t ‚ t j ƒ  d k sf t ‚ d S(   sG   Test to be sure isochizomer and neoschizomers are as expected.
        s   G^GTAC_Cs   G_GTAC^CN(   t   Acc65It   isoschizomerst   Asp718It   KpnIR   R   (   R   (    (    s   test_Restriction.pyt   test_basic_isochizomers7   s    c         C   s²   t  t  k s t ‚ t  t k s$ t ‚ t  t k s7 t ‚ t  t k sJ t ‚ t  t k s\ t ‚ t  t ?sl t ‚ t  t ?s} t ‚ t  t s t ‚ t  t  s t ‚ t  t s® t ‚ d S(   s<   Comparison operators between iso and neoschizomers.
        N(   R#   R   R&   R%   R   (   R   (    (    s   test_Restriction.pyt   test_comparisons?   s    (   R   R    R!   R
   R   R'   R(   (    (    (    s   test_Restriction.pyR"   .   s
   			t   RestrictionBatchesc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s;   Tests for dealing with batches of restriction enzymes.
    c         C   s   d  S(   N(    (   R   (    (    s   test_Restriction.pyR
   R   s    c         C   s   d  S(   N(    (   R   (    (    s   test_Restriction.pyR   U   s    c         C   s¥   t  t g ƒ } | j t ƒ | t 7} t | ƒ d k s> t ‚ | j t ƒ y | j t ƒ t d ƒ ‚ Wn t	 k
 r{ n X| j
 t ƒ t | ƒ d k s¡ t ‚ d S(   s4   Creating and modifying a restriction batch.
        i   s"   No error with non-existent enzyme.i   N(   t   RestrictionBatchR   t   addR&   t   EcoRVR   R   t   gett   SmaIt
   ValueErrort   remove(   R   t   batch(    (    s   test_Restriction.pyt   test_creating_batchX   s    
c         C   sy   t  d t j d t j d t ƒ  ƒ } t t t g ƒ } | j | ƒ } | t d g k ro | t d g k su t ‚ d S(   s4   Sequence analysis with a restriction batch.
        R   i   i   N(   R   R,   R   R   R   R*   R   R   (   R   t   seqR1   t   hits(    (    s   test_Restriction.pyt   test_batch_analysisj   s
    (   R   R    R!   R
   R   R2   R5   (    (    (    s   test_Restriction.pyR)   O   s
   			t   __main__t	   verbosityi   t
   testRunner(   R!   t   unittestt   Bio.Restrictiont   Bio.SeqR   t   Bio.Alphabet.IUPACR   t   TestCaseR   R"   R)   R   t   TextTestRunnert   runnert   main(    (    (    s   test_Restriction.pyt   <module>   s   
#!&