Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.NeuralNetwork.Gene.Schema.GeneticAlgorithmFinder Class Reference

List of all members.

Public Member Functions

def __init__
def find_schemas

Public Attributes

 alphabet
 initial_population
 min_generations
 motif_generator
 mutator
 crossover
 repair
 base_selector
 selector

Private Member Functions

def _set_up_genetic_algorithm

Detailed Description

Find schemas using a genetic algorithm approach.

This approach to finding schema uses Genetic Algorithms to evolve
a set of schema and find the best schema for a specific set of
records.

The 'default' finder searches for ambiguous DNA elements. This
can be overridden easily by creating a GeneticAlgorithmFinder
with a different alphabet.

Definition at line 175 of file Schema.py.


Constructor & Destructor Documentation

Initialize a finder to get schemas using Genetic Algorithms.

Arguments:

o alphabet -- The alphabet which specifies the contents of the
schemas we'll be generating. This alphabet must contain the
attribute 'alphabet_matches', which is a dictionary specifying
the potential ambiguities of each letter in the alphabet. These
ambiguities will be used in building up the schema.

Definition at line 186 of file Schema.py.

00186 
00187     def __init__(self, alphabet = SchemaDNAAlphabet()):
00188         """Initialize a finder to get schemas using Genetic Algorithms.
00189 
00190         Arguments:
00191 
00192         o alphabet -- The alphabet which specifies the contents of the
00193         schemas we'll be generating. This alphabet must contain the
00194         attribute 'alphabet_matches', which is a dictionary specifying
00195         the potential ambiguities of each letter in the alphabet. These
00196         ambiguities will be used in building up the schema.
00197         """
00198         self.alphabet = alphabet
00199 
00200         self.initial_population = 500
00201         self.min_generations = 10
00202 
00203         self._set_up_genetic_algorithm()

Here is the caller graph for this function:


Member Function Documentation

Overrideable function to set up the genetic algorithm parameters.

This functions sole job is to set up the different genetic
algorithm functionality. Since this can be quite complicated, this
allows cusotmizablity of all of the parameters. If you want to
customize specially, you can inherit from this class and override
this function.

Definition at line 204 of file Schema.py.

00204 
00205     def _set_up_genetic_algorithm(self):
00206         """Overrideable function to set up the genetic algorithm parameters.
00207 
00208         This functions sole job is to set up the different genetic
00209         algorithm functionality. Since this can be quite complicated, this
00210         allows cusotmizablity of all of the parameters. If you want to
00211         customize specially, you can inherit from this class and override
00212         this function.
00213         """
00214         self.motif_generator = RandomMotifGenerator(self.alphabet)
00215         
00216         self.mutator = SinglePositionMutation(mutation_rate = 0.1)
00217         self.crossover = SinglePointCrossover(crossover_prob = 0.25)
00218         self.repair = AmbiguousRepair(Schema(self.alphabet.alphabet_matches),
00219                                       4)
00220         self.base_selector = TournamentSelection(self.mutator, self.crossover,
00221                                                  self.repair, 2)
00222         self.selector = DiversitySelection(self.base_selector,
00223                                            self.motif_generator.random_motif)

def Bio.NeuralNetwork.Gene.Schema.GeneticAlgorithmFinder.find_schemas (   self,
  fitness,
  num_schemas 
)
Find the given number of unique schemas using a genetic algorithm

Arguments:

o fitness - A callable object (ie. function) which will evaluate
the fitness of a motif.

o num_schemas - The number of unique schemas with good fitness
that we want to generate.

Definition at line 224 of file Schema.py.

00224 
00225     def find_schemas(self, fitness, num_schemas):
00226         """Find the given number of unique schemas using a genetic algorithm
00227 
00228         Arguments:
00229 
00230         o fitness - A callable object (ie. function) which will evaluate
00231         the fitness of a motif.
00232 
00233         o num_schemas - The number of unique schemas with good fitness
00234         that we want to generate.
00235         """
00236         start_population = \
00237            Organism.function_population(self.motif_generator.random_motif,
00238                                         self.initial_population,
00239                                         fitness)
00240         finisher = SimpleFinisher(num_schemas, self.min_generations)
00241 
00242         # set up the evolver and do the evolution
00243         evolver = GenerationEvolver(start_population, self.selector)
00244         evolved_pop = evolver.evolve(finisher.is_finished)
00245 
00246         # convert the evolved population into a PatternRepository
00247         schema_info = {}
00248         for org in evolved_pop:
00249             # convert the Genome from a MutableSeq to a Seq so that
00250             # the schemas are just strings (and not array("c")s)
00251             seq_genome = org.genome.toseq()
00252             schema_info[seq_genome.tostring()] = org.fitness
00253 
00254         return PatternRepository(schema_info)
00255 
00256 # -- fitness classes


Member Data Documentation

Definition at line 197 of file Schema.py.

Definition at line 219 of file Schema.py.

Definition at line 216 of file Schema.py.

Definition at line 199 of file Schema.py.

Definition at line 200 of file Schema.py.

Definition at line 213 of file Schema.py.

Definition at line 215 of file Schema.py.

Definition at line 217 of file Schema.py.

Definition at line 221 of file Schema.py.


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