ó
"ˆIc           @   sÈ   d  d l  Z  d  d l Z d  d l m Z d  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(   iÿÿÿÿN(   t   GenePop(   t   FDist(   t   convert_genepop_to_fdistt
   RecordTestc           B   s   e  Z d  „  Z RS(   c         C   s|   t  j ƒ  } t | j ƒ t k s' t ‚ t | j ƒ t k sB t ‚ t | j ƒ t k s] t ‚ t | j ƒ t	 k sx t ‚ d S(   s   Basic test on Record
        N(
   R   t   Recordt   typet   data_orgt   intt   AssertionErrort   num_popst   num_locit	   loci_datat   list(   t   selft   r(    (    s   test_PopGen_FDist_nodepend.pyt   test_record_basic   s
    (   t   __name__t
   __module__R   (    (    (    s   test_PopGen_FDist_nodepend.pyR      s   t
   ParserTestc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s‚   d g } g  |  _  x3 | D]+ } |  j  j t t j j d | ƒ ƒ ƒ q Wd g |  _ d d d d g g |  _ d	 d
 g g |  _ d  S(   Nt   fdist1t   PopGeni   i   i   i    i   (   i   i   (   i    i    i    i   (   i   i   i    i   (	   t   handlest   appendt   opent   ost   patht   joint	   pops_locit   num_markerst   test_pos(   R   t   filest   filename(    (    s   test_PopGen_FDist_nodepend.pyt   setUp   s    		)c         C   s"   x |  j  D] } | j ƒ  q
 Wd  S(   N(   R   t   close(   R   t   handle(    (    s   test_PopGen_FDist_nodepend.pyt   tearDown0   s    c         C   sc  t  j ƒ  } xPt t |  j ƒ ƒ D]9} |  j | } | j | ƒ } t | t  j ƒ s\ t ‚ | j	 d k sq t ‚ | j
 s– t | j |  j | k ƒ ‚ xI t t |  j | ƒ ƒ D]. } | j | d |  j | | k s° t ‚ q° Wxv t t |  j | ƒ ƒ D][ } |  j | } xE | D]= } | \ } }	 }
 } | j | d |	 |
 | k st ‚ qWqü Wq" Wd S(   s.   Basic operation of the Record Parser.
        i    i   N(   R   t   RecordParsert   ranget   lenR   t   parset
   isinstanceR   R   R   R	   R
   R   R   R   R   (   R   t   parsert   indexR"   t   rect   it   my_test_post   testt   locust   popt   post   value(    (    s   test_PopGen_FDist_nodepend.pyt   test_record_parser4   s    %  (   R   R   R    R#   R3   (    (    (    s   test_PopGen_FDist_nodepend.pyR      s   		t   ConversionTestc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sL   d g } g  |  _  x3 | D]+ } |  j  j t t j j d | ƒ ƒ ƒ q Wd  S(   Ns
   c2line.genR   (   R   R   R   R   R   R   (   R   R   R   (    (    s   test_PopGen_FDist_nodepend.pyR    H   s    		c         C   sp   xi t  t |  j ƒ ƒ D]R } t j |  j | ƒ } t | ƒ } | j d k sS t ‚ | j d k s t ‚ q Wd S(   s   Basic conversion test.
        i   N(	   R%   R&   R   R    R'   R   R
   R   R	   (   R   R,   t   gp_rect   fd_rec(    (    s   test_PopGen_FDist_nodepend.pyt   test_convertN   s
    c         C   s"   x |  j  D] } | j ƒ  q
 Wd  S(   N(   R   R!   (   R   R"   (    (    s   test_PopGen_FDist_nodepend.pyR#   X   s    (   R   R   R    R7   R#   (    (    (    s   test_PopGen_FDist_nodepend.pyR4   G   s   		
t   __main__t	   verbosityi   t
   testRunner(   R   t   unittestt
   Bio.PopGenR    R   t   Bio.PopGen.FDist.UtilsR   t   TestCaseR   R   R4   R   t   TextTestRunnert   runnert   main(    (    (    s   test_PopGen_FDist_nodepend.pyt   <module>   s   ,