Logo Search packages:      
Sourcecode: python-biopython version File versions  Download package

def Bio::GA::Organism::random_population (   genome_alphabet,
  genome_size,
  num_organisms,
  fitness_calculator 
)

Generate a population of individuals with randomly set genomes.

Arguments:

o genome_alphabet -- An Alphabet object describing all of the
possible letters that could potentially be in the genome of an
organism.

o genome_size -- The size of each organisms genome.

o num_organism -- The number of organisms we want in the population.

o fitness_calculator -- A funtion that will calculate the fitness
of the organism when given the organisms genome.

Definition at line 32 of file Organism.py.

                                         :
    """Generate a population of individuals with randomly set genomes.

    Arguments:

    o genome_alphabet -- An Alphabet object describing all of the
    possible letters that could potentially be in the genome of an
    organism.

    o genome_size -- The size of each organisms genome.

    o num_organism -- The number of organisms we want in the population.

    o fitness_calculator -- A funtion that will calculate the fitness
    of the organism when given the organisms genome.
    """
    all_orgs = []

    # a random number generator to get letters for the genome
    letter_rand = random.Random()

    # figure out what type of characters are in the alphabet
    if type(genome_alphabet.letters[0]) == type("A"):
        alphabet_type = "c"
    elif type(genome_alphabet.letters[0]) == type(1):
        alphabet_type = "i"
    elif type(genome_alphabet.letters[0]) == type(1.0):
        alphabet_type = "d"
    else:
        raise ValueError("Alphabet type is unsupported: %s" % alphabet.letters)

    for org_num in range(num_organisms):
        new_genome = MutableSeq(array.array(alphabet_type), genome_alphabet)

        # generate the genome randomly
        for gene_num in range(genome_size):
            new_gene = letter_rand.choice(genome_alphabet.letters)
            new_genome.append(new_gene)

        # add the new organism with this genome
        all_orgs.append(Organism(new_genome, fitness_calculator))

    return all_orgs

class Organism:


Generated by  Doxygen 1.6.0   Back to index