Back to index

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

List of all members.

Public Member Functions

def __init__
def calculate_fitness

Private Attributes

 _records
 _evaluator

Detailed Description

Calculate a fitness giving weight to schemas that match many times.

This fitness function tries to maximize schemas which are found many
times in a group of sequences.

Definition at line 323 of file Schema.py.


Constructor & Destructor Documentation

def Bio.NeuralNetwork.Gene.Schema.MostCountSchemaFitness.__init__ (   self,
  seq_records,
  schema_evaluator 
)
Initialize with sequences to evaluate.

Arguments:

o seq_records -- A set of SeqRecord objects which we use to
calculate the fitness.

o schema_evaluator - An Schema class which can be used to
evaluate find motif matches in sequences.

Definition at line 329 of file Schema.py.

00329 
00330     def __init__(self, seq_records, schema_evaluator):
00331         """Initialize with sequences to evaluate.
00332 
00333         Arguments:
00334         
00335         o seq_records -- A set of SeqRecord objects which we use to
00336         calculate the fitness.
00337 
00338         o schema_evaluator - An Schema class which can be used to
00339         evaluate find motif matches in sequences.
00340         """
00341         self._records = seq_records
00342         self._evaluator = schema_evaluator

Here is the caller graph for this function:


Member Function Documentation

Calculate the fitness of a genome based on schema matches.

This bases the fitness of a genome completely on the number of times
it matches in the set of seq_records. Matching more times gives a
better fitness

Definition at line 343 of file Schema.py.

00343 
00344     def calculate_fitness(self, genome):
00345         """Calculate the fitness of a genome based on schema matches.
00346 
00347         This bases the fitness of a genome completely on the number of times
00348         it matches in the set of seq_records. Matching more times gives a
00349         better fitness
00350         """
00351         # convert the genome into a string
00352         seq_motif = genome.toseq()
00353         motif = seq_motif.tostring()
00354         
00355         # find the number of times the genome matches
00356         num_times = 0
00357         for seq_record in self._records:
00358             cur_counts = self._evaluator.num_matches(motif,
00359                                                      seq_record.seq.tostring())
00360             num_times += cur_counts
00361 
00362         return num_times
00363 
# -- Helper classes

Member Data Documentation

Definition at line 341 of file Schema.py.

Definition at line 340 of file Schema.py.


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