The genome module is responsible for creating and modifying pykaryote.sim.organims.Organism genomes.
An individual genome is represented as a list of codons (integers). Condons 0 through n represent the n chemicals in the environment. Codons less than 0 correspond to Organism modes. Which integers correspond to which mode will depend on the configuration, but the ordering will always be:
gather > move > protein
There are 5 independent types of genome modifications that may occur when and Organism reproduces.
1. Genome doubling: The entire genome is copied resulting in a genome twice the original length.
2. Gene copying: A single section of the genome, up to LENGTH units, long is copied and inserted into a random spot in the genome.
3. Gene deletion: A single section of genome, up to LENGTH units long, is deleted from the genome.
4. Point mutation: Every codon in the genome has a chance to mutate to a random codon.
5. Gene transfer: A single section of the genome of 1 Organism is copied into the genome of a different Organism. Both the source and destination Organism are from the new generation, thus your fitness affects the probability of your genetic material being transfered.
These modifications are performed in that order, thus a genome may double, and then a portion of the resulting genome can be copied etc..
Pykaryote Genomes
Returns a random valid codon
Copies a random segment of the genome and inserts it into a random spot
Args:
genome (list): the original genome
Returns the length of genome to copy or cut
Args:
length (int): The maximum length allowed.
If the genome is long enough, deletes a random segment of the genome
Args:
genome (list): the original genome
Returns a new genome of the specified length.
The genome contains either random chemical codons or all 0’s. There are non mode codons.
Args:
length (int): the length of the new genome.
Args:
genome (list): the original genome
Iterates through the genome with a random probability of mutating each codon
Args:
genome (list): the original genome
Return random integers from low (inclusive) to high (exclusive).
Return random integers from the “discrete uniform” distribution in the “half-open” interval [low, high). If high is None (the default), then results are from [0, low).
>>> np.random.randint(2, size=10)
array([1, 0, 0, 0, 1, 1, 0, 0, 1, 0])
>>> np.random.randint(1, size=10)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Generate a 2 x 4 array of ints between 0 and 4, inclusive:
>>> np.random.randint(5, size=(2, 4))
array([[4, 0, 2, 1],
[3, 2, 2, 0]])
Copies a portion of gen2 into gen1