Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.GA.Mutation.Simple.ConversionMutation Class Reference

List of all members.

Public Member Functions

def __init__
def mutate

Private Attributes

 _mutation_rate
 _mutation_rand
 _switch_rand

Detailed Description

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.

Definition at line 47 of file Simple.py.


Constructor & Destructor Documentation

def Bio.GA.Mutation.Simple.ConversionMutation.__init__ (   self,
  mutation_rate = 0.001 
)
Inititialize a mutator.

Arguments:

o mutation_rate -- The chance of a mutation happening at any
position in the genome.

Definition at line 55 of file Simple.py.

00055 
00056     def __init__(self, mutation_rate = 0.001):
00057         """Inititialize a mutator.
00058 
00059         Arguments:
00060 
00061         o mutation_rate -- The chance of a mutation happening at any
00062         position in the genome.
00063         """
00064         self._mutation_rate = mutation_rate
00065         # a random number generator to test if we have a mutation
00066         self._mutation_rand = random.Random()
00067         # a random number generator to switch to a new alphabet letter
00068         self._switch_rand = random.Random()

Here is the caller graph for this function:


Member Function Documentation

def Bio.GA.Mutation.Simple.ConversionMutation.mutate (   self,
  organism 
)
Mutate the organisms genome.

Definition at line 69 of file Simple.py.

00069 
00070     def mutate(self, organism):
00071         """Mutate the organisms genome.
00072         """
00073         mutated_org = organism.copy()
00074         
00075         gene_choices = mutated_org.genome.alphabet.letters
00076         
00077         # potentially mutate any gene in the genome
00078         for gene_index in range(len(mutated_org.genome)):
00079             mutation_chance = self._mutation_rand.random()
00080             # if we have a mutation
00081             if mutation_chance <= self._mutation_rate:
00082                 # get a new letter
00083                 new_letter = self._switch_rand.choice(gene_choices)
00084                 mutated_org.genome[gene_index] = new_letter
00085 
00086         return mutated_org
00087                 
00088         
00089     

Member Data Documentation

Definition at line 65 of file Simple.py.

Definition at line 63 of file Simple.py.

Definition at line 67 of file Simple.py.


The documentation for this class was generated from the following file: