Package Bio :: Package GA :: Package Crossover :: Module TwoPoint
[hide private]
[frames] | no frames]

Source Code for Module Bio.GA.Crossover.TwoPoint

 1  # This code is part of the Biopython distribution and governed by its 
 2  # license.  Please see the LICENSE file that should have been included 
 3  # as part of this package. 
 4  # 
 5   
 6  """Perform two-point crossovers between the genomes of two organisms. 
 7   
 8  This module performs two-point crossover between two genomes. 
 9  There are two flavors: OnePointCrossover (Point) and TwoPointCrossover. 
10   
11  TwoPointCrossover is the minimal crossover technique that 
12  facilitates diverse genome length.  Do not use this if you need to 
13  maintain consistent genome length. 
14   
15  TwoPointCrossover: 
16  genome 1 --       A B*C D E F 
17  genome 2 --       a b c*d e f 
18   
19  new genome 1 --   A B d e f 
20  new genome 2 --   a b c C D E F 
21   
22  """ 
23  # standard modules 
24  from .GeneralPoint import TwoCrossover 
25   
26   
27 -class TwoPointCrossover(TwoCrossover):
28 """Perform two point crossover between genomes at some defined rate. 29 30 This performs a crossover between two genomes at some defined frequency. 31 The location of the points of crossover are chosen randomly if the 32 crossover meets the probability to occur. 33 """
34 - def __init__(self, crossover_prob = .1):
35 """Initialize to do crossovers at the specified probability. 36 """ 37 TwoCrossover.__init__(self, 2, crossover_prob)
38