ó
"ˆIc           @   sÜ  d  Z  d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d d l	 m Z d d l	 m Z d d	 l	 m Z d
 Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ 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    Test the different representations of Genes.

This exercises the Motif, Schema and Signature methods of representing
genes, as well as generic Pattern methods.
iÿÿÿÿN(   t   Fasta(   t   Seq(   t   IUPAC(   t   Schema(   t   Motif(   t	   Signature(   t   Patterni    t   PatternIOTestc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s6   Tests for reading and writing patterns to a file.
    c         C   se   t  j |  _ t j j d d ƒ |  _ t j j |  j ƒ rL t j |  j ƒ n  t	 j
 |  j ƒ |  _ d  S(   Nt   NeuralNetworks   patternio.txt(   R   t   ambiguous_dnat   alphabett   ost   patht   joint	   test_filet   isfilet   removeR   t	   PatternIOt
   pattern_io(   t   self(    (    s   test_NNGene.pyt   setUp   s
    c         C   s,   t  j j |  j ƒ r( t  j |  j ƒ n  d  S(   N(   R   R   R   R   R   (   R   (    (    s   test_NNGene.pyt   tearDown&   s    c         C   sD  d d d d g } t  |  j d ƒ } |  j j | | ƒ | j ƒ  t  |  j d ƒ } |  j j | ƒ } | j ƒ  | | k s‘ t d | | f ƒ ‚ g  } x' | D] } | j t | |  j	 ƒ ƒ qž Wt  |  j d ƒ } |  j j
 | | ƒ | j ƒ  t  |  j d ƒ } |  j j | ƒ } | j ƒ  | | k s@t d | | f ƒ ‚ d	 S(
   s-   Reading and writing motifs to a file
        t   GACt   AAAt   TTTt   GGGt   wt   rs-   Failed to get back expected motifs %s, got %ss7   Failed to get back expected motifs %s from seqs, got %sN(   t   openR   R   t   writet   closet   readt   AssertionErrort   appendR   R
   t	   write_seq(   R   t   motifst   output_handlet   input_handlet   read_motifst
   seq_motifst   motif(    (    s   test_NNGene.pyt
   test_motif+   s,    



c         C   s.  d d g } t  |  j d ƒ } |  j j | | ƒ | j ƒ  t  |  j d ƒ } |  j j | ƒ } | j ƒ  | | k s‹ t d | | f ƒ ‚ d d g } t  |  j d ƒ } |  j j | | ƒ | j ƒ  t  |  j d ƒ } y" |  j j | ƒ } t d ƒ ‚ Wn# t k
 rn t d ƒ ‚ n X| j ƒ  d	 S(
   s/   Reading and writing schemas to a file.
        t   GTRR   R   R   s'   Read incorrect schemas %s, expected %s.s   G*Cs%   Did not report error on bad alphabet.s#   Got unexpected error while reading.N(   R   R   R   R   R   R   R    t
   ValueError(   R   t   schemasR$   R%   t   read_schemas(    (    s   test_NNGene.pyt   test_schemaL   s.    


c         C   s   d d	 g } t  |  j d ƒ } |  j j | | ƒ | j ƒ  t  |  j d ƒ } |  j j | ƒ } | j ƒ  | | k s‹ t d | | f ƒ ‚ d S(
   s2   Reading and writing signatures to a file.
        R   R   R   R   R   s,   Got back unexpected signatures %s, wanted %sN(   R   R   (   R   R   (   R   R   R   R   R   R   R    (   R   t
   signaturesR$   R%   t	   read_sigs(    (    s   test_NNGene.pyt   test_signaturen   s    

(   t   __name__t
   __module__t   __doc__R   R   R)   R.   R1   (    (    (    s   test_NNGene.pyR      s   			!	"t   PatternRepositoryTestc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s=   Tests for retrieving info from a repository of patterns.
    c         C   sE   i d d 6d d 6d d 6d d 6d	 d
 6|  _  t j |  j  ƒ |  _ d  S(   Ni   t   GATCi
   t   GGGGi    t   GTAGiöÿÿÿt   AAAAiìÿÿÿt   ATAT(   R#   R   t   PatternRepositoryt
   repository(   R   (    (    s   test_NNGene.pyR   €   s    
c         C   s>   |  j  j ƒ  } | d d d d d g k s: t d | ƒ ‚ d S(   s1   Retrieve all patterns from a repository.
        R6   R7   R8   R9   R:   s   Unexpected motifs returned %sN(   R<   t   get_allR    (   R   t
   all_motifs(    (    s   test_NNGene.pyt   test_get_all‰   s    c         C   s‘   xŠ t  d ƒ D]| } |  j j | ƒ } t | ƒ | k sS t d t | ƒ | f ƒ ‚ x3 | D]+ } | |  j j ƒ  k sZ t d | ƒ ‚ qZ Wq Wd S(   s6   Retrieve random patterns from the repository.
        i   s1   Got unexpected number of patterns %s, expected %ss   Got unexpected pattern %sN(   t   rangeR<   t
   get_randomt   lenR    R#   t   keys(   R   t   num_patternst   patternst   pattern(    (    s   test_NNGene.pyt   test_get_random‘   s    c         C   sš   x“ d
 d d f D]‚ \ } } |  j  j | ƒ } t | ƒ | k s\ t d t | ƒ | f ƒ ‚ x3 | D]+ } | |  j j ƒ  k sc t d | ƒ ‚ qc Wq Wd	 S(   sD   Retrieve the top percentge of patterns from the repository.
        i   gš™™™™™É?i   gš™™™™™Ù?i   g      ð?s1   Got unexpected number of patterns %s, expected %ss   Got unexpected pattern %sN(   i   gš™™™™™É?(   i   gš™™™™™Ù?(   i   g      ð?(   R<   t   get_top_percentageRB   R    R#   RC   (   R   RD   t
   percentageRE   RF   (    (    s   test_NNGene.pyt   test_get_top_percentagež   s    c         C   s‘   xŠ t  d ƒ D]| } |  j j | ƒ } t | ƒ | k sS t d t | ƒ | f ƒ ‚ x3 | D]+ } | |  j j ƒ  k sZ t d | ƒ ‚ qZ Wq Wd S(   s7   Retrieve a certain number of the top patterns.
        i   s1   Got unexpected number of patterns %s, expected %ss   Got unexpected pattern %sN(   R@   R<   t   get_topRB   R    R#   RC   (   R   RD   RE   RF   (    (    s   test_NNGene.pyt   test_get_top«   s    c         C   sA   |  j  j d d ƒ } | d d d d g k s= t d | ƒ ‚ d S(   sH   Retrieve patterns from both sides of the list (top and bottom).
        i   R6   R7   R9   R:   s   Got unexpected patterns %sN(   R<   t   get_differingR    (   R   RE   (    (    s   test_NNGene.pyt   test_get_differing¸   s    c         C   s˜   |  j  j ƒ  } t | ƒ d k s1 t d | ƒ ‚ |  j  j ƒ  |  j  j ƒ  } t | ƒ d k so t d | ƒ ‚ | d d d g k s” t d | ƒ ‚ d	 S(
   sH   Test the ability to remove A rich patterns from the repository.
        i   s   Unexpected starting: %si   s   Unexpected ending: %sR6   R7   R8   s   Unexpected patterns: %sN(   R<   R=   RB   R    t   remove_polyA(   R   RE   (    (    s   test_NNGene.pyt   test_remove_polyA¿   s    ""c         C   s`   |  j  j d ƒ } | d k s. t d | ƒ ‚ |  j  j d ƒ } | d k s\ t d | ƒ ‚ d S(   sC   Retrieve counts for particular patterns in the repository.
        R7   i
   s)   Did not count item in the respository: %st   NOT_IN_THEREi    s#   Counted items not in repository: %sN(   R<   t   countR    (   R   t	   num_times(    (    s   test_NNGene.pyt
   test_countÌ   s    (   R2   R3   R4   R   R?   RG   RJ   RL   RN   RP   RT   (    (    (    s   test_NNGene.pyR5   }   s   								t   MotifFinderTestc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s-   Tests for finding motifs from sequences.
    c   	      C   sî   t  j j d d ƒ } t  j j d d ƒ } g  |  _ g  |  _ xœ | |  j f | |  j f f D]| \ } } t | d ƒ } t j d t j	 ƒ } t j
 | | ƒ } x- | j ƒ  } | d  k r¼ Pn  | j | ƒ q  W| j ƒ  q[ Wt j ƒ  |  _ d  S(   NR   s   enolase.fastas   repeat.fastaR   R
   (   R   R   R   t   test_recordst   diff_recordsR   R    t   SequenceParserR   t   unambiguous_dnat   Iteratort   nextt   NoneR!   R   R   t   MotifFindert   motif_finder(	   R   R   t	   diff_filet   filet   recordst   handlet
   seq_parsert   iteratort
   seq_record(    (    s   test_NNGene.pyR   Ü   s     		c         C   sO   |  j  j |  j d ƒ } | j d ƒ } | d d k sK t d | d ƒ ‚ d S(   s/   Find all motifs in a set of sequences.
        i   i   i    t   TTGGAAAGs   Got unexpected motif %sN(   R^   t   findRV   RK   R    (   R   t   motif_repositoryt	   top_motif(    (    s   test_NNGene.pyt	   test_find÷   s    c         C   sr   |  j  j |  j |  j d ƒ } | j d d ƒ \ } } | d k sR t d | ƒ ‚ | d k sn t d | ƒ ‚ d S(   sK   Find the difference in motif counts between two sets of sequences.
        i   i   Rf   s   Got unexpected top motif %st   AATGGCATs   Got unexpected bottom motif %sN(   R^   t   find_differencesRV   RW   RM   R    (   R   Rh   t   topt   bottom(    (    s   test_NNGene.pyt   test_find_differences   s
    (   R2   R3   R4   R   Rj   Ro   (    (    (    s   test_NNGene.pyRU   Ù   s   			t   MotifCoderTestc           B   s    e  Z d  Z d „  Z d „  Z RS(   s=   Test the ability to encode sequences as a set of motifs.
    c         C   s[   d d d d g } d d d d d g f d d	 d d	 d g f f |  _  t j | ƒ |  _ d  S(
   Nt   GAGt   GATt   GCCt   ATAt   GATCGCCg        g      ð?t   GATGATCGAGCCg      à?(   t   match_stringsR   t
   MotifCodert   coder(   R   R#   (    (    s   test_NNGene.pyR     s    c         C   sd   x] |  j  D]R \ } } t | t j ƒ } |  j j | ƒ } | | k s
 t d | | f ƒ ‚ q
 Wd S(   s:   Convert a sequence into its motif representation.
        s1   Did not match representation, expected %s, got %sN(   Rw   R   R   RY   Ry   t   representationR    (   R   t   match_stringt   expectedt   seq_to_codet   matches(    (    s   test_NNGene.pyt   test_representation  s    (   R2   R3   R4   R   R   (    (    (    s   test_NNGene.pyRp     s   		t
   SchemaTestc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   sB   Matching ambiguous motifs with multiple ambiguity characters.
    c         C   s—   i d d 6d d 6d d 6d d 6d d 6d d 6} t  j  | ƒ |  _ d	 |  _ d
 d
 g f d	 d	 g f d d	 g f d d	 g f d d
 d g f g |  _ d  S(   Nt   Gt   At   Tt   Ct   AGt   Rt   AGTCt   *t   GATAGt   GAs   GA*AGt   GATRGs   *At   TA(   R   t   motif_coderR{   t
   match_info(   R   t   ambiguity_chars(    (    s   test_NNGene.pyR   (  s    

	c         C   sX   xQ |  j  D]F \ } } |  j j | |  j ƒ } | | k s
 t d | | f ƒ ‚ q
 Wd S(   s(   Find all matches in a sequence.
        s   Expected %s, got %sN(   RŽ   R   t   find_matchesR{   R    (   R   R(   R|   t   found_matches(    (    s   test_NNGene.pyt   test_find_matches9  s
    c         C   sd   x] |  j  D]R \ } } |  j j | |  j ƒ } | t | ƒ k s
 t d | t | ƒ f ƒ ‚ q
 Wd S(   s9   Find how many matches are present in a sequence.
        s   Expected %s, got %sN(   RŽ   R   t   num_matchesR{   RB   R    (   R   R(   R|   R“   (    (    s   test_NNGene.pyt   test_num_matchesB  s
    c         C   s”   d g  f d d d d g f d d g f d d d d d g f f } xK | D]C \ } } |  j  j | ƒ } | | k sI t d	 | | | f ƒ ‚ qI Wd
 S(   s=   Find the positions of ambiguous items in a sequence.
        R6   s   G***i   i   i   t   GARTs   *R*Ri    s   Expected %s, got %s for %sN(   R   t   find_ambiguousR    (   R   t
   ambig_infoR(   R|   t   found_positions(    (    s   test_NNGene.pyt   test_find_ambiguousK  s    		c         C   sd   d d d d f } xK | D]C \ } } |  j  j | ƒ } | | k s t d	 | | | f ƒ ‚ q Wd
 S(   s:   Find the number of ambiguous items in a sequence.
        R6   i    s   G***i   R•   i   s   *R*Ri   s   Expected %s, got %s for %sN(   R6   i    (   s   G***i   (   R•   i   (   s   *R*Ri   (   R   t   num_ambiguousR    (   R   R—   R(   R|   t	   found_num(    (    s   test_NNGene.pyt   test_num_ambiguousY  s    	c         C   sQ   d } |  j  j | d ƒ |  j  j j | ƒ s: t d ƒ ‚ |  j  j | d ƒ d S(   sJ   Make sure motif compiled regular expressions are cached properly.
        R6   t   GATCGATCs#   Did not find motif cached properly.N(   R   R   t   _motif_cachet   has_keyR    (   R   R)   (    (    s   test_NNGene.pyt   test_motif_cachef  s
    	c         C   sG   |  j  j ƒ  } d d d d g } | | k sC t d | | f ƒ ‚ d S(   sB   Return all unambiguous characters that can be in a motif.
        R‚   R„   R   Rƒ   s   Got %s, expected %sN(   R   t   all_unambiguousR    (   R   t   found_unambigR|   (    (    s   test_NNGene.pyt   test_all_unambiguouss  s    (
   R2   R3   R4   R   R’   R”   R™   Rœ   R    R£   (    (    (    s   test_NNGene.pyR€   %  s   								t   SchemaFinderTestc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s2   Test finding schemas from a set of sequences.
    c   
      C   s  t  j j d d ƒ } t  j j d d ƒ } g  |  _ g  |  _ xœ | |  j f | |  j f f D]| \ } } t | d ƒ } t j d t j	 ƒ } t j
 | | ƒ } x- | j ƒ  } | d  k r¼ Pn  | j | ƒ q  W| j ƒ  q[ Wd |  _ t j ƒ  }	 d |	 _ t j d |  j d	 |	 ƒ |  _ d  S(
   NR   s   enolase.fastas   repeat.fastaR   R
   i   i   t   num_schemast   schema_finder(   R   R   R   RV   RW   R   R    RX   R   RY   RZ   R[   R\   R!   R   R¥   R   t   GeneticAlgorithmFindert   min_generationst   SchemaFindert   finder(
   R   R   R_   R`   Ra   Rb   Rc   Rd   Re   t	   schema_ga(    (    s   test_NNGene.pyR     s(    				c         C   sV   t  rR |  j j |  j |  j ƒ } | j ƒ  } t | ƒ |  j k sR t d ƒ ‚ n  d S(   s+   Find schemas from sequence inputs.
        s   Got too few schemas.N(	   t   VERBOSERª   Rg   RV   RW   R=   RB   R¥   R    (   R   R<   R,   (    (    s   test_NNGene.pyRj   ž  s    c         C   sU   t  rQ |  j j |  j |  j ƒ } | j ƒ  } t | ƒ |  j k sQ t d ƒ ‚ n  d S(   sG   Find schemas that differentiate between two sets of sequences.
        s   Got too few schemas.N(	   R¬   Rª   Rl   RV   RW   R=   RB   R¥   R    (   R   R<   R,   (    (    s   test_NNGene.pyRo   ¨  s
    (   R2   R3   R4   R   Rj   Ro   (    (    (    s   test_NNGene.pyR¤   |  s   		
t   SchemaCoderTestc           B   s    e  Z d  Z d „  Z d „  Z RS(   s5   Test encoding sequences as a grouping of motifs.
    c         C   s·   i d d 6d d 6d d 6d d 6d d 6d d 6} t  j  | ƒ } d } t  j | | ƒ |  _ d
 d d d d d g f d t d ƒ t d ƒ d t d ƒ t d ƒ d d g f g |  _ d  S(   NR   R‚   Rƒ   R„   R…   R†   R‡   Rˆ   RŠ   R‰   s   GA*AGR‹   s   *Ag      à?g      ð?t   GAGAGATAi   i   i    i   (   RŠ   R‰   s   GA*AGR‹   s   *A(   R   t   SchemaCoderR   t   floatRw   (   R   R   t   motif_representationR#   (    (    s   test_NNGene.pyR   ¶  s    

	c         C   sd   x] |  j  D]R \ } } t | t j ƒ } |  j j | ƒ } | | k s
 t d | | f ƒ ‚ q
 Wd S(   s:   Convert a string into a representation of motifs.
        s   Got %s, expected %sN(   Rw   R   R   RY   R   Rz   R    (   R   R{   R|   t	   match_seqt	   found_rep(    (    s   test_NNGene.pyR   È  s
    (   R2   R3   R4   R   R   (    (    (    s   test_NNGene.pyR­   ³  s   	t   SchemaMatchingTestc           B   s    e  Z d  Z d „  Z d „  Z RS(   s0   Matching schema to strings works correctly.
    c         C   s   d |  j  j |  j f S(   Ns   %s:%s(   t	   __class__R2   R4   (   R   (    (    s   test_NNGene.pyt   shortDescriptionÔ  s    c         C   sÖ   t  j d d ƒ } | d k s* t d ƒ ‚ t  j d d ƒ } | d k sT t d ƒ ‚ t  j d d ƒ } | d k s~ t d ƒ ‚ t  j d d ƒ } | d k s¨ t d	 ƒ ‚ t  j d
 d ƒ } | d k sÒ t d ƒ ‚ d  S(   NR6   t   AAAAAi    s/   Expected no match because of length differencess   GAT*i   s   Expected matchs   C*TCs+   Expected no match because of char mismatch.s   G*TCs   *TTCs$   Expected match because of ambiguity.(   R   t   matches_schemaR    (   R   t   match(    (    s   test_NNGene.pyt   runTest×  s    (   R2   R3   R4   R¶   Rº   (    (    (    s   test_NNGene.pyR´   Ñ  s   	t   SchemaFactoryTestc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s3   Test the SchemaFactory for generating Schemas.
    c         C   s    t  j j |  | ƒ d  |  _ d  S(   N(   t   unittestt   TestCaset   __init__R\   t   schema_bank(   R   t   method(    (    s   test_NNGene.pyR¾   ê  s    c         C   sv   t  j ƒ  |  _ t j j t j ƒ  d d ƒ |  _ i d d 6d d 6d d 6d d 6d d 6d	 d
 6} t  j  | ƒ |  _ d  S(   NR   s   enolase.fastaR   R‚   Rƒ   R„   R…   R†   R‡   Rˆ   (	   R   t   SchemaFactoryt   factoryR   R   R   t   getcwdR   t   schema(   R   R   (    (    s   test_NNGene.pyR   ð  s    !

c         C   sŠ   i d d 6d d 6d d 6d d 6} t  j | ƒ } |  j j | d	 d
 ƒ } t r† d GHx/ | j ƒ  D] } d | | j | ƒ f GHqa Wn  d S(   s8   Generating schema from a simple list of motifs.
        i   t   GATCGAAi   t   GATCGATi   t   GATTGACi
   t   TTTTTTTg      à?i   s	   
Schemas:s   %s: %sN(   R   R;   RÂ   t   from_motifsR¬   R=   RR   (   R   R#   t
   motif_bankR¿   RÄ   (    (    s   test_NNGene.pyt   test_easy_from_motifsþ  s    

c         C   sP   |  j  ƒ  } t rL d GHx2 | j d ƒ D] } d | | j | ƒ f GHq' Wn  d S(   s:   Generating schema from a real life set of motifs.
        s	   
Schemas:i   s   %s: %sN(   t   _load_schema_repositoryR¬   RK   RR   (   R   R¿   RÄ   (    (    s   test_NNGene.pyt   test_hard_from_motifs  s
    c   
      C   sØ   |  j  d k	 r |  j  St |  j d ƒ } t j d t j ƒ } t j | | ƒ } g  } x- | j	 ƒ  } | d k rt Pn  | j
 | ƒ qX W| j ƒ  t j ƒ  } d } | j | | ƒ } |  j j | d d ƒ }	 |	 |  _  |	 S(   s¸   Helper function to load a schema repository from a file.

        This also caches a schema bank, to prevent having to do this
        time consuming operation multiple times.
        R   R
   i	   gš™™™™™¹?i   N(   R¿   R\   R   R   R    RX   R   RY   RZ   R[   R!   R   R   R]   Rg   RÂ   RÉ   (
   R   t   motif_handleRc   Rd   t   seq_recordsRe   R^   t
   motif_sizeRÊ   R¿   (    (    s   test_NNGene.pyRÌ     s$    
	c   	      C   s¾   |  j  ƒ  } | j d ƒ } t j | |  j ƒ } t |  j d ƒ } t j d t	 j
 ƒ } t j | | ƒ } xD | j ƒ  } | d k rˆ Pn  | j | j ƒ } t rl d G| GHql ql W| j ƒ  d S(   s7   Convert sequences into schema representations.
        i   R   R
   s   Schema values:N(   RÌ   RK   R   R¯   RÄ   R   R   R    RX   R   RY   RZ   R[   R\   Rz   t   seqR¬   R   (	   R   R¿   t   top_schemast   schema_codert   fasta_handleRc   Rd   Re   t   schema_values(    (    s   test_NNGene.pyt   test_schema_representationB  s    (	   R2   R3   R4   R¾   R   RË   RÍ   RÌ   RÖ   (    (    (    s   test_NNGene.pyR»   ç  s   				
	*t   SignatureFinderTestc           B   s    e  Z d  Z d „  Z d „  Z RS(   s?   Test the ability to find signatures in a set of sequences.
    c         C   s¤   t  j j d d ƒ } g  |  _ t | d ƒ } t j d t j ƒ } t j	 | | ƒ } x0 | j
 ƒ  } | d  k rs Pn  |  j j | ƒ qW W| j ƒ  t j ƒ  |  _ d  S(   NR   s   enolase.fastaR   R
   (   R   R   R   RV   R   R    RX   R   RY   RZ   R[   R\   R!   R   R   t   SignatureFindert
   sig_finder(   R   R   Rb   Rc   Rd   Re   (    (    s   test_NNGene.pyR   `  s    	
c         C   sR   |  j  j |  j d d ƒ } | j d ƒ } | d d	 k sN t d | d ƒ ‚ d S(
   s.   Find signatures from sequence inputs.
        i   i	   i   i    t   TTGGAAt   TGGAAAs   Unexpected signature %sN(   RÚ   RÛ   (   RÙ   Rg   RV   RK   R    (   R   R<   t   top_sig(    (    s   test_NNGene.pyRj   v  s    (   R2   R3   R4   R   Rj   (    (    (    s   test_NNGene.pyR×   ]  s   	t   SignatureCoderTestc           B   s    e  Z d  Z d „  Z d „  Z RS(   sA   Test the ability to encode sequences as a set of signatures.
    c      	   C   s¡   d d d g } t  j | d ƒ |  _ d d d d	 g f d
 d d d	 g f d d d d d	 g f d d d	 d	 g f d d d	 d	 g f d d	 d	 d	 g f g |  _ d  S(   NR   R   R   t   CAAt   TTGi	   t   GACAAAGACTTTg      ð?g        t   CAAAGACGACTTTAAATTTg      à?t   AAATTTAAAGACTTTGACg      @t   GACGACt   GACAAAAAAAAAGACt   GACAAAAAAAAAAGAC(   R   R   (   R   R   (   RÞ   Rß   (   R   t   SignatureCoderRy   t	   test_seqs(   R   R/   (    (    s   test_NNGene.pyR   ‚  s    c         C   sg   x` |  j  D]U \ } } t | t j ƒ } |  j j | ƒ } | | k s
 t d | | | f ƒ ‚ q
 Wd S(   s>   Convert a sequence into its signature representation.
        s0   Non-expected representation %s for %s, wanted %sN(   Rç   R   R   RY   Ry   Rz   R    (   R   t
   seq_stringR|   t   test_seqt	   predicted(    (    s   test_NNGene.pyR   Ž  s    (   R2   R3   R4   R   R   (    (    (    s   test_NNGene.pyRÝ     s   	t   __main__t	   verbosityi   t
   testRunner(   R4   R   R¼   t   BioR    t   Bio.SeqR   t   Bio.AlphabetR   t   Bio.NeuralNetwork.GeneR   R   R   R   R¬   R½   R   R5   RU   Rp   R€   R¤   R­   R´   R»   R×   RÝ   R2   t   TextTestRunnert   runnert   main(    (    (    s   test_NNGene.pyt   <module>   s0   b\3W7v"