ó
"ˆIc           @   s¼   d  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 d „  ƒ  YZ
 d	 „  Z d
 e j f d „  ƒ  YZ e d k r¸ e j d d ƒ Z e j d e ƒ n  d S(   s†   Tests for Genetic Algorithm Repair code.

This tests classes which are designed for repairing organisms after
mutation and crossover.
iÿÿÿÿN(   t
   MutableSeq(   t   Schema(   t   Organism(   t   AmbiguousRepairt   TestAlphabetc           B   sB   e  Z d  Z i d d 6d d 6d d 6d d 6Z d d d d g Z RS(   s   Simple test alphabet.
    t   1t   2t   3t   123t   *(   t   __name__t
   __module__t   __doc__t   alphabet_matchest   letters(    (    (    s   test_GARepair.pyR      s   

c         C   s   d S(   s,   Simple class for calculating fitnesses.
    i   (    (   t   genome(    (    s   test_GARepair.pyt   test_fitness   s    t   AmbiguousRepairTestc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sI   Test for the ability to repair too many ambiguous genes in a genome.
    c         C   s@   t  ƒ  } t d | ƒ } t | t ƒ |  _ t | j ƒ |  _ d  S(   Ns	   11*22*33*(   R   R    R   R   t   organismR   R   t
   ambig_info(   t   selft   alphabett   test_genome(    (    s   test_GARepair.pyt   setUp&   s    	c         C   sy   t  |  j d ƒ } x` t d ƒ D]R } | j |  j ƒ } | j j ƒ  } | j j d ƒ d k s t	 d | j ƒ ‚ q Wd S(   s@   Test repair of a single ambiguous position in a genome.
        i   i   R	   s   Did not repair genome, got %sN(
   R   R   t   ranget   repairR   R   t   toseqt   datat   countt   AssertionError(   R   t   repairert   repair_attemptt   new_orgt   new_genome_seq(    (    s   test_GARepair.pyt   test_single_repair-   s    c         C   sy   t  |  j d ƒ } x` t d ƒ D]R } | j |  j ƒ } | j j ƒ  } | j j d ƒ d k s t	 d | j ƒ ‚ q Wd S(   sA   Test repair of multiple ambiguous positions in a genome.
        i    i   R	   s   Did not repair genome, got %sN(
   R   R   R   R   R   R   R   R   R   R   (   R   R   R   R    R!   (    (    s   test_GARepair.pyt   test_multiple_repair9   s    (   R
   R   R   R   R"   R#   (    (    (    s   test_GARepair.pyR   #   s   		t   __main__t	   verbosityi   t
   testRunner(    (   R   t   unittestt   Bio.SeqR    t   Bio.NeuralNetwork.Gene.SchemaR   t   Bio.GA.OrganismR   t   Bio.GA.Repair.StabilizingR   R   R   t   TestCaseR   R
   t   TextTestRunnert   runnert   main(    (    (    s   test_GARepair.pyt   <module>   s   
	"