File: TwoPoint.py

package info (click to toggle)
python-biopython 1.30-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 14,680 kB
  • ctags: 11,177
  • sloc: python: 60,275; ansic: 7,728; cpp: 1,844; sql: 1,144; makefile: 193
file content (34 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Perform two-point crossovers between the genomes of two organisms.

This module performs two-point crossover between two genomes.
There are two flavors: OnePointCrossover (Point) and TwoPointCrossover.

TwoPointCrossover is the minimal crossover technique that
facilitates diverse genome length.  Do not use this if you need to
maintain consistent genome length.

TwoPointCrossover:
genome 1 --       A B*C D E F
genome 2 --       a b c*d e f

new genome 1 --   A B d e f
new genome 2 --   a b c C D E F

"""
# standard modules
import whrandom
from GeneralPoint import TwoCrossover

class TwoPointCrossover(TwoCrossover):
    """Perform two point crossover between genomes at some defined rate.

    This performs a crossover between two genomes at some defined frequency.
    The location of the points of crossover are chosen randomly if the
    crossover meets the probability to occur.  
    """
    def __init__(self, crossover_prob = .1):
        """Initialize to do crossovers at the specified probability.
        """
	TwoCrossover.__init__(self, 2, crossover_prob)