Documentation
¶
Index ¶
- func CalcT2(p *Pop, sampleSize int) []float64
- func CalcT3(p *Pop, sampleSize int) []float64
- func CalcT4(p *Pop, sampleSize int) []float64
- func Evolve(eventChan chan *Event)
- func FitnessMutateExponential(f *FitnessMutator) (delta float64)
- func FitnessMutateStep(f *FitnessMutator) (delta float64)
- type BeneficialMutator
- type ByBirthTimeReverse
- type ByRate
- type ByteSequence
- type Config
- type ConstantFrag
- type DeltaMutateFunc
- type Dilution
- type Event
- type ExpFrag
- type FitnessMutator
- type FragSizeGenerator
- type Genome
- type Lineage
- type Lineages
- type LinearSelectionSampler
- type MoranSampler
- type NeutralGenome
- type Operator
- type OutTransfer
- type Pop
- type Rand
- type RandomPopGenerator
- type RouletteWheel
- type Sampler
- type Shock
- type SimpleMutator
- type SimplePopGenerator
- type SimpleTransfer
- type WrightFisherSampler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FitnessMutateExponential ¶
func FitnessMutateExponential(f *FitnessMutator) (delta float64)
FitnessMutateExponential return a exp value of delta.
func FitnessMutateStep ¶
func FitnessMutateStep(f *FitnessMutator) (delta float64)
FitnessMutateStep return the delta fitness.
Types ¶
type BeneficialMutator ¶
type BeneficialMutator struct { S float64 // contains filtered or unexported fields }
BeneficialMutator is a selective mutator.
func NewBeneficialMutator ¶
func NewBeneficialMutator(s float64, src rand.Source) *BeneficialMutator
NewBeneficialMutator returns a new BeneficialMutator.
func (*BeneficialMutator) Operate ¶
func (m *BeneficialMutator) Operate(p *Pop)
Operate increase the fitness score by S.
type ByBirthTimeReverse ¶
type ByBirthTimeReverse struct{ Lineages }
func (ByBirthTimeReverse) Less ¶
func (s ByBirthTimeReverse) Less(i, j int) bool
type ByteSequence ¶
type ByteSequence []byte
type Config ¶
type Config struct { // population parameters Size int // population size Length int // length of genome NumGen int // number of generations. Alphabet string Mutation struct { Beneficial struct { Rate float64 S float64 } Rate float64 } Transfer struct { In struct { Rate float64 Fragment int } Out struct { Rate float64 Fragment int } } SampleMethod string FragGenerator string }
Population config
type ConstantFrag ¶
type ConstantFrag struct {
Length int
}
func NewConstantFrag ¶
func NewConstantFrag(length int) *ConstantFrag
func (*ConstantFrag) Size ¶
func (c *ConstantFrag) Size() int
type DeltaMutateFunc ¶
type DeltaMutateFunc func(f *FitnessMutator) (delta float64)
DeltaMutateFunc is a type of function that increase or decrease the fitness score by delta.
type Dilution ¶
type Dilution struct {
Factor float64
}
Dilution reduces the population by certain poportion.
type Event ¶
func Emit ¶
func Emit(events []*Event, rw *RouletteWheel) *Event
Emit randomly emits an event accourding to the event rate.
type ExpFrag ¶
type ExpFrag struct { Lambda float64 // contains filtered or unexported fields }
func NewExpFrag ¶
NewExpFrag return a new ExpFrag.
type FitnessMutator ¶
type FitnessMutator struct { Scale float64 Shape float64 // contains filtered or unexported fields }
FitnessMutator is a mutator on fitness score.
func NewFitnessMutator ¶
func NewFitnessMutator(scale, shape float64, src rand.Source, deltaFunc DeltaMutateFunc) *FitnessMutator
NewFitnessMutator returns a new fitness mutator.
func (*FitnessMutator) Operate ¶
func (f *FitnessMutator) Operate(p *Pop)
Operate mutate the fitness score.
type FragSizeGenerator ¶
type FragSizeGenerator interface {
Size() int
}
FragSizeGenerator is a interface with a function return the size of fragment.
type LinearSelectionSampler ¶
type LinearSelectionSampler struct {
// contains filtered or unexported fields
}
func NewLinearSelectionSampler ¶
func NewLinearSelectionSampler(src rand.Source) *LinearSelectionSampler
func (*LinearSelectionSampler) Operate ¶
func (w *LinearSelectionSampler) Operate(p *Pop)
func (*LinearSelectionSampler) Start ¶
func (l *LinearSelectionSampler) Start()
func (*LinearSelectionSampler) Time ¶
func (l *LinearSelectionSampler) Time(p *Pop) float64
func (*LinearSelectionSampler) Wait ¶
func (l *LinearSelectionSampler) Wait()
type MoranSampler ¶
type MoranSampler struct {
// contains filtered or unexported fields
}
MoranSampler implements Moran reproduction model.
In each step of Moran process, two individuals are randomly chose: one to reproduce and the other to be replaced.
func NewMoranSampler ¶
func NewMoranSampler(src rand.Source) *MoranSampler
func (*MoranSampler) Operate ¶
func (m *MoranSampler) Operate(p *Pop)
func (*MoranSampler) Time ¶
func (m *MoranSampler) Time(p *Pop) float64
type NeutralGenome ¶
type NeutralGenome struct { Sequence ByteSequence // contains filtered or unexported fields }
func (*NeutralGenome) Copy ¶
func (g *NeutralGenome) Copy() Genome
func (*NeutralGenome) Fitness ¶
func (g *NeutralGenome) Fitness() float64
func (*NeutralGenome) Length ¶
func (g *NeutralGenome) Length() int
func (*NeutralGenome) Seq ¶
func (g *NeutralGenome) Seq() []byte
type Operator ¶
type Operator interface {
Operate(*Pop)
}
Objects implementing the Operator interface can be used to do operations to a population.
type OutTransfer ¶
type OutTransfer struct { SimpleTransfer DonorPop *Pop }
OutTransfer implements transfers from a donor population to a receiver one.
We randomly choose a sequence from the donor population, and one from the reciever population.
func NewOutTransfer ¶
func NewOutTransfer(frag FragSizeGenerator, donorPop *Pop, src rand.Source) *OutTransfer
NewOutTransfer return a new OutTransfer.
func (*OutTransfer) Operate ¶
func (o *OutTransfer) Operate(p *Pop)
Operate perform a out population transfer.
type Pop ¶
type Pop struct { // Genomes stores a array of sequences Genomes []Genome // Circled indicates whether the genome is circled or not. Circled bool Lineages []*Lineage NumGeneration int TargetSize int }
Pop is a population with a list of genomes.
type RandomPopGenerator ¶
type RandomPopGenerator struct { // Rand is a source of random numbers Rand Rand Alphabet []byte Size int // size of population Length int // length of genome }
RandomPopGenerator randomly generates a population with a random neutral ancestral genome, given the size of the population and the length of the genome.
func NewRandomPopGenerator ¶
func NewRandomPopGenerator(r Rand, size, length int, alphabet []byte) *RandomPopGenerator
NewRandomPopGenerator return a Pop.
func (*RandomPopGenerator) Operate ¶
func (r *RandomPopGenerator) Operate(p *Pop)
Operate create genomes for a population.
type RouletteWheel ¶
type RouletteWheel struct {
// contains filtered or unexported fields
}
RouletteWheel is a random generator.
func NewRouletteWheel ¶
func NewRouletteWheel(src rand.Source) *RouletteWheel
NewRouletteWheel return a new RouletteWheel.
func (*RouletteWheel) Select ¶
func (r *RouletteWheel) Select(weights []float64) (index int)
Select return a select index.
type SimpleMutator ¶
type SimpleMutator struct { // Rand is a source of random numbers Alphabet []byte // contains filtered or unexported fields }
SimpleMutator implements a simple mutation model, which assumes the same mutation rate on each site, and equal transition rates between bases.
func NewSimpleMutator ¶
func NewSimpleMutator(alphabet []byte, src rand.Source) *SimpleMutator
NewSimpleMutator returns a new SimpleMutator.
func (*SimpleMutator) Operate ¶
func (s *SimpleMutator) Operate(p *Pop)
Operate mutate a single position at a genome from the *Pop.
type SimplePopGenerator ¶
SimplePopGenerator generate a population with the same ancestral sequence.
func NewSimplePopGenerator ¶
func NewSimplePopGenerator(ancestor Genome, size int) *SimplePopGenerator
NewSimplePopGenerator return a new SimplePopGenerator.
func (*SimplePopGenerator) Operate ¶
func (s *SimplePopGenerator) Operate(p *Pop)
Operate copy the ancestor to all genomes.
type SimpleTransfer ¶
type SimpleTransfer struct { Frag FragSizeGenerator // contains filtered or unexported fields }
SimpleTransfer implements a very simple transfer model. We randomly choose two sequences: one to be the donor, and the other to be the receiver. And a piece of the receiver's genome will be replaced by a sequence at corresponding genomic positions.
func NewSimpleTransfer ¶
func NewSimpleTransfer(frag FragSizeGenerator, src rand.Source) *SimpleTransfer
func (*SimpleTransfer) Operate ¶
func (s *SimpleTransfer) Operate(p *Pop)
type WrightFisherSampler ¶
type WrightFisherSampler struct {
// contains filtered or unexported fields
}
WrightFisherSampler for Wright-Fisher reproduction model.
func NewWrightFisherSampler ¶
func NewWrightFisherSampler(src rand.Source) *WrightFisherSampler
NewWrightFisherSampler create a new WrightFisherSampler.
func (*WrightFisherSampler) Operate ¶
func (w *WrightFisherSampler) Operate(p *Pop)
func (*WrightFisherSampler) Start ¶
func (w *WrightFisherSampler) Start()
func (*WrightFisherSampler) Time ¶
func (w *WrightFisherSampler) Time(p *Pop) float64
func (*WrightFisherSampler) Wait ¶
func (w *WrightFisherSampler) Wait()