ó
X<c           @   s9   d  Z  d d l Z d d l m Z d d d     YZ d S(   s%   General functionality for mutations.
i’’’’N(   t   Organismt   SafeFitnessMutationc           B   s#   e  Z d  Z d d  Z d   Z RS(   sĘ   Perform mutations, but do not allow decreases in organism fitness.

    This doesn't actually do any mutation work, but just checks that
    newly create organisms do not have lower fitnesses. 
    g        c         C   s%   | |  _  | |  _ t j   |  _ d S(   sc  Initialize to do safe mutations

        Arguments:

        o actual_mutation - A Mutation class which actually implements
        mutation. functionality.

        o accept_less - A probability to accept mutations which
        generate lower fitness. This allows you to accept some
        crossovers which reduce fitness, but not all of them.
        N(   t	   _mutationt   _accept_less_percentt   randomt   Randomt   _accept_less_rand(   t   selft   actual_mutationt   accept_less(    (    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/General.pyt   __init__   s    		c         C   s_   |  j  j |  } | j   | j | j k rW |  j j   } | |  j k rP | S| Sn | Sd S(   s9   Perform safe mutation of the specified organism.
        N(   R   t   mutatet   recalculate_fitnesst   fitnessR   R   R   (   R   t   orgt   new_orgt   accept_less_chance(    (    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/General.pyR      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/General.pyR   	   s   (    (   R   R   t   Bio.GA.OrganismR    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/General.pyt   <module>   s   