Genome — Pykaryote 1.1.0d documentation

### Navigation

- index
- modules |
- next |
- previous |
- Pykaryote 1.1.0d documentation »
- Modules »

# Genome

## Overview

The genome module is responsible for creating and modifying `pykaryote.sim.organims.Organism` genomes.

### Representation

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

### Mutations

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..

## Documentation

Pykaryote Genomes

`pykaryote.sim.genome.` `codon`()

  Returns a random valid codon

`pykaryote.sim.genome.` `copy_gene`(genome)

  Copies a random segment of the genome and inserts it into a random spot

  Args:

  > `genome` (list): the original genome

`pykaryote.sim.genome.` `cut_del_length`(length)

  Returns the length of genome to copy or cut

  Args:

  > `length` (int): The maximum length allowed.

`pykaryote.sim.genome.` `delete_gene`(genome)

  If the genome is long enough, deletes a random segment of the genome

  Args:

  > `genome` (list): the original genome

`pykaryote.sim.genome.` `generate_genome`(length)

  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.

`pykaryote.sim.genome.` `mutate_genome`(genome)
  Creates a new genome from the old one. The new genome has independent chances of:
    - doubling itself
    - copying a segment
    - deleting a segment
    - point mutation at any codon

  Args:

  > `genome` (list): the original genome

`pykaryote.sim.genome.` `point_mutate`(genome)

  Iterates through the genome with a random probability of mutating each codon

  Args:

  > `genome` (list): the original genome

`pykaryote.sim.genome.` `randint`(low, high=None, size=None)

  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).

  low : int
    Lowest (signed) integer to be drawn from the distribution (unless `high=None`, in which case this parameter is the highest such integer).
  high : int, optional
    If provided, one above the largest (signed) integer to be drawn from the distribution (see above for behavior if `high=None`).
  size : int or tuple of ints, optional
    Output shape. Default is None, in which case a single int is returned.
  out : int or ndarray of ints
    size-shaped array of random integers from the appropriate distribution, or a single such random int if size not provided.
  random.random_integers : similar to randint, only for the closed
    interval [low, high], and 1 is the lowest value if high is omitted. In particular, this other one is the one to use to generate uniformly distributed discrete non-integers.

      >>> 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]])

`pykaryote.sim.genome.` `random`() → x in the interval [0, 1).

`pykaryote.sim.genome.` `swap_gene`(gen1, gen2)

  Copies a portion of gen2 into gen1

### Navigation

- index
- modules |
- next |
- previous |
- Pykaryote 1.1.0d documentation »
- Modules »