ó
XçIc           @   sv   d  d l  Z  d  d l Z d  d l m Z d e j f d „  ƒ  YZ e d k rr e j d d ƒ Z e j	 d e ƒ n  d S(	   iÿÿÿÿN(   t   Motift   MotifTestsBasicc           B   sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C   s™   t  d ƒ |  _ t  d ƒ |  _ t  d ƒ |  _ t  d ƒ |  _ d |  _ d |  _ d |  _ d d l m	 } t
 j
 ƒ  |  _ |  j j | d	 |  j j ƒ ƒ d  S(
   Ns   Motif/alignace.outs   Motif/meme.outs   Motif/SRF.pfms   Motif/Arnt.sitess   Motif/tf.outs   Motif/fa.outiÿÿÿÿ(   t   Seqt   ATATA(   t   opent   ACint   MEMEint   PFMint   SITESint   TFoutt   FAoutt   PFMoutt   Bio.SeqR   R    t   mt   add_instancet   alphabet(   t   selfR   (    (    s   test_Motif.pyt   setUp   s    			c         C   sˆ   |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  t j j |  j ƒ r\ t j	 |  j ƒ n  t j j |  j
 ƒ r„ t j	 |  j
 ƒ n  d  S(   N(   R   t   closeR   R   R   t   ost   patht   existsR	   t   removeR
   (   R   (    (    s   test_Motif.pyt   tearDown   s    c         C   s=   t  j ƒ  } | j |  j ƒ } t | j ƒ d k s9 t ‚ d S(   sD   Test to be sure that Motif can parse AlignAce output files.
        i   N(   R    t   AlignAceParsert   parseR   t   lent   motifst   AssertionError(   R   t   parsert   record(    (    s   test_Motif.pyt   test_alignace_parsing$   s    c         C   s=   t  j ƒ  } | j |  j ƒ } t | j ƒ d k s9 t ‚ d S(   s@   Test to be sure that Motif can parse MEME output files.
        i   N(   R    t
   MEMEParserR   R   R   R   R   (   R   R   R   (    (    s   test_Motif.pyt   test_meme_parsing+   s    c         C   s.   t  j |  j d ƒ } | j d k s* t ‚ d S(   s9   Test to be sure that Motif can parse pfm  files.
        s
   jaspar-pfmi   N(   R    t   readR   t   lengthR   (   R   t   motif(    (    s   test_Motif.pyt   test_pfm_parsing2   s    c         C   s.   t  j |  j d ƒ } | j d k s* t ‚ d S(   s:   Test to be sure that Motif can parse sites files.
        s   jaspar-sitesi   N(   R    R"   R   R#   R   (   R   R$   (    (    s   test_Motif.pyt   test_sites_parsing8   s    c         C   s9   t  |  j d ƒ } | j |  j j d ƒ ƒ | j ƒ  d S(   s<   Ensure that we can write proper FASTA output files.
        t   wt   fastaN(   R   R
   t   writeR   t   formatR   (   R   t   output_handle(    (    s   test_Motif.pyt   test_FAoutput>   s    c         C   s9   t  |  j d ƒ } | j |  j j d ƒ ƒ | j ƒ  d S(   s?   Ensure that we can write proper TransFac output files.
        R'   t   transfacN(   R   R	   R)   R   R*   R   (   R   R+   (    (    s   test_Motif.pyt   test_TFoutputE   s    c         C   s9   t  |  j d ƒ } | j |  j j d ƒ ƒ | j ƒ  d S(   s:   Ensure that we can write proper pfm output files.
        R'   s
   jaspar-pfmN(   R   R   R)   R   R*   R   (   R   R+   (    (    s   test_Motif.pyt   test_pfm_outputL   s    (   t   __name__t
   __module__R   R   R   R!   R%   R&   R,   R.   R/   (    (    (    s   test_Motif.pyR      s   		
						t   __main__t	   verbosityi   t
   testRunner(
   R   t   unittestt   BioR    t   TestCaseR   R0   t   TextTestRunnert   runnert   main(    (    (    s   test_Motif.pyt   <module>   s   G