
Ic           @   s   d  Z  d d l Z d d l m Z d d l m Z d e j f d     YZ e d k r| e j	 d d	  Z
 e j d
 e
  n  d S(   s   Unit test for ClaiN(   t   Cla(   t   Residuest   ClaTestsc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   d |  _  d  S(   Ns   ./SCOP/dir.cla.scop.txt_test(   t   filename(   t   self(    (    s   test_SCOP_Cla.pyt   setUp   s    c         C   sm   t  |  j  } zL d } t j |  } x | D] } | d 7} q. W| d k sZ t d   Wd | j   Xd S(   s   Can we parse a CLA file?i    i   i   s   Wrong number of records?!N(   t   openR   R    t   parset   AssertionErrort   close(   R   t   ft   countt   recordst   record(    (    s   test_SCOP_Cla.pyt	   testParse   s    c         C   si   t  |  j  } zH xA | D]9 } t j |  } t |  j   | j   k s t  q WWd  | j   Xd  S(   N(   R   R   R    t   Recordt   strt   rstripR   R	   (   R   R
   t   lineR   (    (    s   test_SCOP_Cla.pyt   testStr"   s    ,c         C   sE   d } y% t  j |  } t s* t d   Wn t k
 r@ } n Xd  S(   Ns   49268	sp	b.1.2.1	-
s   Should never get here(   R    R   t   FalseR   t
   ValueError(   R   t
   corruptRecR   t   e(    (    s   test_SCOP_Cla.pyt	   testError,   s    c      	   C   s   d } t  j |  } | j d k s* t  | j j d k sB t  | j j d d f k s` t  | j d	 k su t  | j d
 k s t  | j	 d d g d d g d d g d d g d d g d d g d d
 g g k s t | j	   d  S(   Nse   d1dan.1	1dan	T:,U:91-106	b.1.2.1	21953	cl=48724,cf=48725,sf=49265,fa=49266,dm=49267,sp=49268,px=21953s   d1dan.1t   1dant   Tt    t   Ut   91t   106s   b.1.2.1iU  t   cliT  t   cfiU  t   sfiq  t   fair  t   dmis  t   spit  t   px(   R   R   R   (   R   R   R   (
   R    R   t   sidR   t   residuest   pdbidt	   fragmentst   sccst   sunidt	   hierarchy(   R   t   recLineR   (    (    s   test_SCOP_Cla.pyt
   testRecord5   s    !c         C   sb   t  j |  j  } t |  d k s* t  | j d  s? t  | d } | j d k s^ t  d  S(   Ni   t   d4hbia_t   d1hbia_i:  (   R    t   IndexR   t   lenR   t   has_keyR+   (   R   t   indext   rec(    (    s   test_SCOP_Cla.pyt	   testIndexB   s
    
(   t   __name__t
   __module__R   R   R   R   R.   R6   (    (    (    s   test_SCOP_Cla.pyR      s   			
			t   __main__t	   verbosityi   t
   testRunner(   t   __doc__t   unittestt   Bio.SCOPR    t   Bio.SCOP.ResiduesR   t   TestCaseR   R7   t   TextTestRunnert   runnert   main(    (    (    s   test_SCOP_Cla.pyt   <module>   s   <