Back to index

python-biopython  1.60
Public Member Functions | Private Attributes
Bio.GA.Repair.Stabilizing.AmbiguousRepair Class Reference

List of all members.

Public Member Functions

def __init__
def repair

Private Attributes

 _ambig_finder
 _num_ambiguous
 _alphabet_letters

Detailed Description

Perform repair to reduce the number of Ambiguous genes in a genome.

In cases where ambiguous genes are allowed in a genome (for example,
where you have a wild card character like '*' that will match
anything), these can come to dominate a genome since, really, the
best fitness is someting like '*******'. This repair protects against
that by changing ambiguous characters into some non-ambiguous gene.

Definition at line 11 of file Stabilizing.py.


Constructor & Destructor Documentation

def Bio.GA.Repair.Stabilizing.AmbiguousRepair.__init__ (   self,
  ambig_finder,
  num_ambiguous 
)
Initialize the repair class.

Arguments:

o ambig_finder - A class implementing the function find_ambiguous
which will return a list of all ambiguous positions in a sequence.
It also must have the function all_unambiguous, which will return
all allowed unambiguous letters.

o num_ambiguous - The minimum number of ambiguous items that are
allowed in a genome. If there are more than this present, repair
will be performed.

Definition at line 20 of file Stabilizing.py.

00020 
00021     def __init__(self, ambig_finder, num_ambiguous):
00022         """Initialize the repair class.
00023 
00024         Arguments:
00025 
00026         o ambig_finder - A class implementing the function find_ambiguous
00027         which will return a list of all ambiguous positions in a sequence.
00028         It also must have the function all_unambiguous, which will return
00029         all allowed unambiguous letters.
00030 
00031         o num_ambiguous - The minimum number of ambiguous items that are
00032         allowed in a genome. If there are more than this present, repair
00033         will be performed.
00034         """
00035         self._ambig_finder = ambig_finder
00036         self._num_ambiguous = num_ambiguous
00037         self._alphabet_letters = ambig_finder.all_unambiguous()

Here is the caller graph for this function:


Member Function Documentation

def Bio.GA.Repair.Stabilizing.AmbiguousRepair.repair (   self,
  organism 
)
Perform a repair to remove excess ambiguous genes.

Definition at line 38 of file Stabilizing.py.

00038 
00039     def repair(self, organism):
00040         """Perform a repair to remove excess ambiguous genes.
00041         """
00042         new_org = organism.copy()
00043         
00044         # start getting rid of ambiguous items
00045         while 1:
00046             # first find all of the ambigous items
00047             seq_genome = new_org.genome.toseq()
00048             all_ambiguous = self._ambig_finder.find_ambiguous(seq_genome.tostring())
00049 
00050             # if we have less then the number of ambiguous allowed, stop
00051             if len(all_ambiguous) <= self._num_ambiguous:
00052                 break
00053 
00054             # remove an ambiguous item and replace it with a non-ambiguous
00055             to_change = random.choice(all_ambiguous)
00056             new_gene = random.choice(self._alphabet_letters)
00057             new_org.genome[to_change] = new_gene
00058 
00059         return new_org
00060             

Member Data Documentation

Definition at line 36 of file Stabilizing.py.

Definition at line 34 of file Stabilizing.py.

Definition at line 35 of file Stabilizing.py.


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