Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_GACrossover.TestCrossover Class Reference

List of all members.

Public Member Functions

def __init__
def do_crossover

Public Attributes

 type

Detailed Description

Provide basic crossover functionality for testing SafeFitness.

Definition at line 316 of file test_GACrossover.py.


Constructor & Destructor Documentation

Definition at line 319 of file test_GACrossover.py.

00319 
00320     def __init__(self):
00321         # whether or not to produce new organisms with lower fitness
00322         # higher fitness, or the same organism
00323         self.type = "lower"


Member Function Documentation

def test_GACrossover.TestCrossover.do_crossover (   self,
  org_1,
  org_2 
)

Definition at line 324 of file test_GACrossover.py.

00324 
00325     def do_crossover(self, org_1, org_2):
00326         seq_org1 = org_1.genome.toseq()
00327         seq_org2 = org_2.genome.toseq()
00328         org1_genome = seq_org1.tostring()
00329         org2_genome = seq_org2.tostring()
00330 
00331         new_org_1 = org_1.copy()
00332         new_org_2 = org_2.copy()
00333         
00334         if self.type == "same":
00335             return new_org_1, new_org_2
00336         elif self.type == "lower":
00337             new_org1_genome = str(int(org1_genome) - 1)
00338             new_org2_genome = str(int(org2_genome) - 1)
00339 
00340             new_org_1.genome = MutableSeq(new_org1_genome,
00341                                           org_1.genome.alphabet)
00342             new_org_2.genome = MutableSeq(new_org2_genome,
00343                                           org_2.genome.alphabet)
00344         elif self.type == "higher":
00345             new_org1_genome = str(int(org1_genome) + 1)
00346             new_org2_genome = str(int(org2_genome) + 1)
00347         else:
00348             raise ValueError("Got type %s" % self.type)
00349 
00350         new_org_1.genome = MutableSeq(new_org1_genome,
00351                                       org_1.genome.alphabet)
00352         new_org_2.genome = MutableSeq(new_org2_genome,
00353                                       org_2.genome.alphabet)
00354 
00355         return new_org_1, new_org_2
                

Member Data Documentation

Definition at line 322 of file test_GACrossover.py.


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