dna

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

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 CalcFixedDelMutationFitness

func CalcFixedDelMutationFitness(_ *rand.Rand) float64

func CalcFixedFavMutationFitness

func CalcFixedFavMutationFitness(_ *rand.Rand) float64

func CalcUniformAlleleFitness

func CalcUniformAlleleFitness(uniformRandom *rand.Rand) float64

func CalcUniformDelMutationFitness

func CalcUniformDelMutationFitness(uniformRandom *rand.Rand) float64

Calculate a random fitness between -Uniform_fitness_effect_del and 0 (deleterious) or 0 and Uniform_fitness_effect_fav (favorable)

func CalcUniformFavMutationFitness

func CalcUniformFavMutationFitness(uniformRandom *rand.Rand) float64

func CalcWeibullDelMutationFitness

func CalcWeibullDelMutationFitness(uniformRandom *rand.Rand) float64

Algorithm according to Wes and the Fortran version. See init.f90 lines 300-311 and mutation.f90 lines 102-109

func CalcWeibullFavMutationFitness

func CalcWeibullFavMutationFitness(uniformRandom *rand.Rand) float64

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.

func SetModels

func SetModels(c *config.Config)

SetModels is called by main.initialize() to set the function ptrs for the various algorithms chosen by the input file.

Types

type Allele

type Allele struct {
	Count         uint32
	FitnessEffect float32
}

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

type CalcAlleleFitnessType func(uniformRandom *rand.Rand) float64

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

type CalcMutationFitnessType func(uniformRandom *rand.Rand) float64

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.

func CreateInitialAllelePair

func CreateInitialAllelePair(uniqueInt *utils.UniqueInt, uniformRandom *rand.Rand) (favMutn, delMutn Mutation)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL