Documentation ¶
Index ¶
- func AppendInitialAllelePair(lb1, lb2 *LinkageBlock, favMutn, delMutn Mutation)
- func AppendInitialContrastingAlleles(lb1, lb2 *LinkageBlock, uniqueInt *utils.UniqueInt, uniformRandom *rand.Rand) (fitnessEffect1, fitnessEffect2 float32)
- func CalcFixedDelMutationFitness(_ *rand.Rand) float64
- func CalcFixedFavMutationFitness(_ *rand.Rand) float64
- func CalcUniformAlleleFitness(uniformRandom *rand.Rand) float64
- func CalcUniformDelMutationFitness(uniformRandom *rand.Rand) float64
- func CalcUniformFavMutationFitness(uniformRandom *rand.Rand) float64
- func CalcWeibullDelMutationFitness(uniformRandom *rand.Rand) float64
- func CalcWeibullFavMutationFitness(uniformRandom *rand.Rand) float64
- func ChrAppendInitialAllelePair(chr1, chr2 *Chromosome, lbIndex int, favMutn, delMutn Mutation)
- func ChrAppendInitialContrastingAlleles(chr1, chr2 *Chromosome, lbIndex int, uniqueInt *utils.UniqueInt, ...)
- func FullCrossover(dad *Chromosome, mom *Chromosome, offspr *Chromosome, _ uint32, ...) (deleterious, neutral, favorable, delAllele, favAllele uint32)
- func NoCrossover(dad *Chromosome, mom *Chromosome, offspr *Chromosome, _ uint32, ...) (uint32, uint32, uint32, uint32, uint32)
- func PartialCrossover(dad *Chromosome, mom *Chromosome, offspr *Chromosome, lBsPerChromosome uint32, ...) (deleterious, neutral, favorable, delAllele, favAllele uint32)
- func SetModels(c *config.Config)
- type Allele
- type AlleleCount
- type CalcAlleleFitnessType
- type CalcMutationFitnessType
- type Chromosome
- func (c *Chromosome) AppendMutation(lbInChr int, mutId uint64, uniformRandom *rand.Rand) MutationType
- func (c *Chromosome) ChromosomeFactory(lBsPerChromosome uint32)
- func (c *Chromosome) Copy(offspr *Chromosome) (deleterious, neutral, favorable, delAllele, favAllele uint32)
- func (c *Chromosome) CountAlleles(allelesForThisIndiv *AlleleCount)
- func (c *Chromosome) GetNumLinkages() uint32
- func (c *Chromosome) Reinitialize()
- func (c *Chromosome) SumFitness() float64
- func (c *Chromosome) TransferLB(newChr *Chromosome, lbIndex int) (uint32, uint32, uint32, uint32, uint32)
- type CrossoverModelType
- type CrossoverType
- type LinkageBlock
- func (lb *LinkageBlock) AppendMutation(mutId uint64, uniformRandom *rand.Rand) (mType MutationType, fitnessEffect float32)
- func (lb *LinkageBlock) CountAlleles(allelesForThisIndiv *AlleleCount)
- func (lb *LinkageBlock) GetMutationStats() (deleterious, neutral, favorable, delAllele, favAllele uint32)
- func (lb *LinkageBlock) GetNumMutations() uint32
- func (lb *LinkageBlock) SumFitness() (fitness float32)
- type Models
- type Mutation
- type MutationFitnessModelType
- type MutationType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendInitialAllelePair ¶
func AppendInitialAllelePair(lb1, lb2 *LinkageBlock, favMutn, delMutn Mutation)
AppendInitialAllelePair adds an initial contrasting allele pair to 2 LBs (favorable to 1, deleterious to the other). The 2 LBs passed in are typically the same LB position on the same chromosome number, 1 from each parent.
func AppendInitialContrastingAlleles ¶
func AppendInitialContrastingAlleles(lb1, lb2 *LinkageBlock, uniqueInt *utils.UniqueInt, uniformRandom *rand.Rand) (fitnessEffect1, fitnessEffect2 float32)
AppendInitialContrastingAlleles adds a random initial contrasting allele pair to 2 LBs (favorable to 1, deleterious to the other). The 2 LBs passed in are typically the same LB position on the same chromosome number, 1 from each parent.
func CalcUniformDelMutationFitness ¶
Calculate a random fitness between -Uniform_fitness_effect_del and 0 (deleterious) or 0 and Uniform_fitness_effect_fav (favorable)
func CalcWeibullDelMutationFitness ¶
Algorithm according to Wes and the Fortran version. See init.f90 lines 300-311 and mutation.f90 lines 102-109
func CalcWeibullFavMutationFitness ¶
Algorithm according to Wes and the Fortran version. See init.f90 lines 300-311 and mutation.f90 line 104
func ChrAppendInitialAllelePair ¶
func ChrAppendInitialAllelePair(chr1, chr2 *Chromosome, lbIndex int, favMutn, delMutn Mutation)
ChrAppendInitialAllelePair adds an initial contrasting allele pair to 2 LBs on 2 chromosomes (favorable to 1, deleterious to the other).
func ChrAppendInitialContrastingAlleles ¶
func ChrAppendInitialContrastingAlleles(chr1, chr2 *Chromosome, lbIndex int, uniqueInt *utils.UniqueInt, uniformRandom *rand.Rand)
ChrAppendInitialContrastingAlleles adds an initial contrasting allele pair to 2 LBs on 2 chromosomes (favorable to 1, deleterious to the other).
func FullCrossover ¶
func FullCrossover(dad *Chromosome, mom *Chromosome, offspr *Chromosome, _ uint32, uniformRandom *rand.Rand) (deleterious, neutral, favorable, delAllele, favAllele uint32)
Create the gamete from dad and mom's chromosomes by randomly choosing each LB from either. Returns the number of each kind of mutation in the new chromosome.
func NoCrossover ¶
func NoCrossover(dad *Chromosome, mom *Chromosome, offspr *Chromosome, _ uint32, uniformRandom *rand.Rand) (uint32, uint32, uint32, uint32, uint32)
Create the gamete from all of dad's chromosomes or all of mom's chromosomes. Returns the number of each kind of mutation in the new chromosome.
func PartialCrossover ¶
func PartialCrossover(dad *Chromosome, mom *Chromosome, offspr *Chromosome, lBsPerChromosome uint32, uniformRandom *rand.Rand) (deleterious, neutral, favorable, delAllele, favAllele uint32)
Create the gamete from dad and mom's chromosomes by randomly choosing sections of LBs from either. Returns the number of each kind of mutation in the new chromosome.
Types ¶
type AlleleCount ¶
type AlleleCount struct { DeleteriousDom map[uint64]Allele DeleteriousRec map[uint64]Allele Neutral map[uint64]Allele FavorableDom map[uint64]Allele FavorableRec map[uint64]Allele DelInitialAlleles map[uint64]Allele FavInitialAlleles map[uint64]Allele }
The number of occurrences of each allele (both mutations and initial alleles) in 1 generation. The map key is the unique id of mutation. Note: this is defined here instead of population.go to avoid circular dependencies
func AlleleCountFactory ¶
func AlleleCountFactory() *AlleleCount
type CalcAlleleFitnessType ¶
These are the different algorithms for assigning a fitness factor to an initial allele. Pointers to 2 of them are chosen at initialization time.
type CalcMutationFitnessType ¶
These are the different algorithms for assigning a fitness factor to a mutation. Pointers to 2 of them are chosen at initialization time.
type Chromosome ¶
type Chromosome struct { LinkageBlocks []LinkageBlock FitnessEffect float32 // keep a running total of the fitness contribution of this LB to the chromosome }
Chromosome represents 1 chromosome in an individual's genome.
func (*Chromosome) AppendMutation ¶
func (c *Chromosome) AppendMutation(lbInChr int, mutId uint64, uniformRandom *rand.Rand) MutationType
AppendMutation creates and adds a mutations to the LB specified. Returns the type of mutation added.
func (*Chromosome) ChromosomeFactory ¶
func (c *Chromosome) ChromosomeFactory(lBsPerChromosome uint32)
Since the Individual's slice of chromosomes isn't ptrs, but the actual objects, we have this factory work on it directly (instead of creating an object and returning a ptr to it).
func (*Chromosome) Copy ¶
func (c *Chromosome) Copy(offspr *Chromosome) (deleterious, neutral, favorable, delAllele, favAllele uint32)
Copy makes a deep copy of this chromosome to offspr
func (*Chromosome) CountAlleles ¶
func (c *Chromosome) CountAlleles(allelesForThisIndiv *AlleleCount)
CountAlleles adds all of this chromosome's alleles (both mutations and initial alleles) to the given struct
func (*Chromosome) GetNumLinkages ¶
func (c *Chromosome) GetNumLinkages() uint32
GetNumLinkages returns the number of linkage blocks from each parent (we assume they always have the same number of LBs from each parent)
func (*Chromosome) Reinitialize ¶
func (c *Chromosome) Reinitialize()
Not currently used, but kept here in case we want to reuse populations - Reinitialize gets an existing/old chromosome ready for reuse. In addition to their member vars, Chromosome objects have an array of LBs. We will end up overwriting the contents of those LB objects (including their Mutation array) in TransferLB(), but we want to reuse the memory allocation of those arrays. In the other Chromosome methods we can tell if the recycled chromosome exists because the ptr to it will be non-nil.
func (*Chromosome) SumFitness ¶
func (c *Chromosome) SumFitness() float64
SumFitness combines the fitness effect of all of its LBs in the additive method
func (*Chromosome) TransferLB ¶
func (c *Chromosome) TransferLB(newChr *Chromosome, lbIndex int) (uint32, uint32, uint32, uint32, uint32)
TransferLB copies a LB from this chromosome to newChr. The LB in newChr may be recycled from a previous gen, we will completely overwrite it. As a side effect, we also update the newChr's fitness stats. Returns the numbers of each kind of mutation.
type CrossoverModelType ¶
type CrossoverModelType string
const ( NO_CROSSOVER CrossoverModelType = "none" FULL_CROSSOVER CrossoverModelType = "full" PARTIAL_CROSSOVER CrossoverModelType = "partial" )
type CrossoverType ¶
type CrossoverType func(dad *Chromosome, mom *Chromosome, offspr *Chromosome, lBsPerChromosome uint32, uniformRandom *rand.Rand) (uint32, uint32, uint32, uint32, uint32)
The different implementations of LB crossover to another chromosome during meiosis
type LinkageBlock ¶
type LinkageBlock struct { // Note: instead of adding the space of another LB member var, we could always make sure the mutn array is barely big enough so the builtin append() would naturally copy it IsPtrToParent bool // whether or not the mutn slice is still a reference to its parents mutn array. We don't copy it until we add a mutation. During create of a new LB, this will naturally be set to false. // contains filtered or unexported fields }
LinkageBlock represents 1 linkage block in the genome of an individual. It tracks the mutations in this LB and the cumulative fitness affect on the individual's fitness.
func (*LinkageBlock) AppendMutation ¶
func (lb *LinkageBlock) AppendMutation(mutId uint64, uniformRandom *rand.Rand) (mType MutationType, fitnessEffect float32)
AppendMutation creates and adds a mutation to this LB.
func (*LinkageBlock) CountAlleles ¶
func (lb *LinkageBlock) CountAlleles(allelesForThisIndiv *AlleleCount)
CountAlleles counts all of this LB's alleles (both mutations and initial alleles) and adds them to the given struct
func (*LinkageBlock) GetMutationStats ¶
func (lb *LinkageBlock) GetMutationStats() (deleterious, neutral, favorable, delAllele, favAllele uint32)
GetMutationStats returns the number of deleterious, neutral, favorable mutations, and deleterious and favorable initial alleles.
func (*LinkageBlock) GetNumMutations ¶
func (lb *LinkageBlock) GetNumMutations() uint32
GetNumMutations returns the current total number of mutations and initial alleles
func (*LinkageBlock) SumFitness ¶
func (lb *LinkageBlock) SumFitness() (fitness float32)
SumFitness combines the fitness effect of all of its mutations in the additive method
type Models ¶
type Models struct { CalcDelMutationFitness CalcMutationFitnessType CalcFavMutationFitness CalcMutationFitnessType Crossover CrossoverType CalcAlleleFitness CalcAlleleFitnessType // this goes with pop.InitialAlleleModelType }
Models holds pointers to functions that implement the various algorithms chosen by the input file.
var Mdl *Models
Mdl is the singleton instance of Models that can be accessed throughout the dna package. It gets set in SetModels().
type Mutation ¶
type Mutation struct { Id uint64 Type MutationType FitnessEffect float32 // even tho we accumulate the fitness in the LB as we go, we need to save this for allele analysis }
A simple struct that is embedded in the LB arrays. (Not a ptr to it.) A lot of mutations exist, so need to keep its size to a minimum.
type MutationFitnessModelType ¶
type MutationFitnessModelType string
const ( FIXED_FITNESS_EFFECT MutationFitnessModelType = "fixed" UNIFORM_FITNESS_EFFECT MutationFitnessModelType = "uniform" WEIBULL_FITNESS_EFFECT MutationFitnessModelType = "weibull" )
type MutationType ¶
type MutationType uint8
Note: we have a lot of mutations, so to keep the size of each to a min, store del/fav and dom/rec in same enum
const ( DELETERIOUS_DOMINANT MutationType = iota DELETERIOUS_RECESSIVE MutationType = iota NEUTRAL MutationType = iota FAVORABLE_DOMINANT MutationType = iota FAVORABLE_RECESSIVE MutationType = iota DEL_ALLELE MutationType = iota // Note: for now we assume that all initial contrasting alleles are co-dominant, so we don't have to store dominant/recessive FAV_ALLELE MutationType = iota )
func CalcMutationType ¶
func CalcMutationType(uniformRandom *rand.Rand) (mType MutationType)
CalcMutationType determines if the next mutation should be deleterious/neutral/favorable based on a random number and the various relevant rates for this population. This is used by the LB to determine which of the Mutation subclasses to create.