Back to index

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

List of all members.

Public Member Functions

def __init__
def calculate_fitness

Private Attributes

 _pos_seqs
 _neg_seqs
 _schema_eval

Detailed Description

Calculate fitness for schemas that differentiate between sequences.

Definition at line 257 of file Schema.py.


Constructor & Destructor Documentation

def Bio.NeuralNetwork.Gene.Schema.DifferentialSchemaFitness.__init__ (   self,
  positive_seqs,
  negative_seqs,
  schema_evaluator 
)
Initialize with different sequences to evaluate

Arguments:

o positive_seq - A list of SeqRecord objects which are the 'positive'
sequences -- the ones we want to select for.

o negative_seq - A list of SeqRecord objects which are the 'negative'
sequences that we want to avoid selecting.

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

Definition at line 260 of file Schema.py.

00260 
00261     def __init__(self, positive_seqs, negative_seqs, schema_evaluator):
00262         """Initialize with different sequences to evaluate
00263 
00264         Arguments:
00265         
00266         o positive_seq - A list of SeqRecord objects which are the 'positive'
00267         sequences -- the ones we want to select for.
00268 
00269         o negative_seq - A list of SeqRecord objects which are the 'negative'
00270         sequences that we want to avoid selecting.
00271 
00272         o schema_evaluator - An Schema class which can be used to
00273         evaluate find motif matches in sequences.
00274         """
00275         self._pos_seqs = positive_seqs
00276         self._neg_seqs = negative_seqs
00277         self._schema_eval = schema_evaluator

Here is the caller graph for this function:


Member Function Documentation

Calculate the fitness for a given schema.

Fitness is specified by the number of occurances of the schema in
the positive sequences minus the number of occurances in the
negative examples.

This fitness is then modified by multiplying by the length of the
schema and then dividing by the number of ambiguous characters in
the schema. This helps select for schema which are longer and have
less redundancy.

Definition at line 278 of file Schema.py.

00278 
00279     def calculate_fitness(self, genome):
00280         """Calculate the fitness for a given schema.
00281 
00282         Fitness is specified by the number of occurances of the schema in
00283         the positive sequences minus the number of occurances in the
00284         negative examples.
00285 
00286         This fitness is then modified by multiplying by the length of the
00287         schema and then dividing by the number of ambiguous characters in
00288         the schema. This helps select for schema which are longer and have
00289         less redundancy.
00290         """
00291         # convert the genome into a string
00292         seq_motif = genome.toseq()
00293         motif = seq_motif.tostring()
00294         
00295         # get the counts in the positive examples
00296         num_pos = 0
00297         for seq_record in self._pos_seqs:
00298             cur_counts = self._schema_eval.num_matches(motif,
00299                                                       seq_record.seq.tostring())
00300             num_pos += cur_counts
00301 
00302         # get the counts in the negative examples
00303         num_neg = 0
00304         for seq_record in self._neg_seqs:
00305             cur_counts = self._schema_eval.num_matches(motif,
00306                                                       seq_record.seq.tostring())
00307 
00308             num_neg += cur_counts
00309 
00310         num_ambiguous = self._schema_eval.num_ambiguous(motif)
00311         # weight the ambiguous stuff more highly
00312         num_ambiguous = pow(2.0, num_ambiguous)
00313         # increment num ambiguous to prevent division by zero errors.
00314         num_ambiguous += 1
00315 
00316         motif_size = len(motif)
00317         motif_size = motif_size * 4.0
00318 
00319         discerning_power = num_pos - num_neg
00320         
00321         diff = (discerning_power * motif_size) / float(num_ambiguous)
00322         return diff


Member Data Documentation

Definition at line 275 of file Schema.py.

Definition at line 274 of file Schema.py.

Definition at line 276 of file Schema.py.


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