ó
X<c           @   s<   d  Z  d d l Z d d d     YZ d d d     YZ d S(	   s2   Perform Simple mutations on an organism's genome.
i˙˙˙˙Nt   SinglePositionMutationc           B   s#   e  Z d  Z d d  Z d   Z RS(   sä   Perform a conversion mutation, but only at a single point in the genome.

    This does not randomize the genome as much as ConversionMutation, since
    only one change is allowed per genome at the specified mutation rate.
    güŠńŇMbP?c         C   s:   | |  _  t j   |  _ t j   |  _ t j   |  _ d S(   s   Initialize a mutator.

        Arguments:

        o mutation_rate - The chance of a mutation happening once in the
        genome.
        N(   t   _mutation_ratet   randomt   Randomt   _mutation_randt   _switch_randt	   _pos_rand(   t   selft   mutation_rate(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyt   __init__   s    	c         C   s   | j    } | j j j } |  j j   } | |  j k r| |  j j t	 t
 | j    } |  j j |  } | | j | <n  | S(   s%   Mutate the organisms genome.
        (   t   copyt   genomet   alphabett   lettersR   R   R   R   t   choicet   ranget   lenR   (   R   t   organismt   mutated_orgt   gene_choicest   mutation_chancet   mutation_post
   new_letter(    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyt   mutate   s    !(   t   __name__t
   __module__t   __doc__R	   R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyR       s   t   ConversionMutationc           B   s#   e  Z d  Z d d  Z d   Z RS(   sP  Potentially mutate any item to another in the alphabet.

    This just performs switching mutation -- changing one gene of a genome
    to any other potential gene, at some defined frequency. If the organism
    is determined to mutate, then the alphabet item it is equally likely
    to switch to any other letter in the alphabet.
    güŠńŇMbP?c         C   s+   | |  _  t j   |  _ t j   |  _ d S(   s   Inititialize a mutator.

        Arguments:

        o mutation_rate -- The chance of a mutation happening at any
        position in the genome.
        N(   R   R   R   R   R   (   R   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyR	   7   s    	c         C   s   | j    } | j j j } x] t t | j   D]F } |  j j   } | |  j k r1 |  j	 j
 |  } | | j | <q1 q1 W| S(   s%   Mutate the organisms genome.
        (   R
   R   R   R   R   R   R   R   R   R   R   (   R   R   R   R   t
   gene_indexR   R   (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyR   E   s    (   R   R   R   R	   R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyR   /   s   (    (    (   R   R   R    R   (    (    (    s   /oak/stanford/groups/akundaje/marinovg/programs/biopython-1.50.tar.gz/biopython-1.50/build/lib.linux-x86_64-2.7/Bio/GA/Mutation/Simple.pyt   <module>   s   )