bpp-phyl3  3.0.0
bpp::SimpleMutationProcess Class Reference

Generally used mutation process model. More...

#include <Bpp/Phyl/Simulation/MutationProcess.h>

+ Inheritance diagram for bpp::SimpleMutationProcess:
+ Collaboration diagram for bpp::SimpleMutationProcess:

Public Member Functions

 SimpleMutationProcess (std::shared_ptr< const SubstitutionModelInterface > model)
 Build a new SimpleMutationProcess object. More...
 
virtual ~SimpleMutationProcess ()
 
size_t evolve (size_t initialState, double time) const
 Method redefinition for better performance. More...
 
size_t mutate (size_t state) const
 Mutate a character in state i. More...
 
size_t mutate (size_t state, unsigned int n) const
 Mutate a character in state i n times. More...
 
double getTimeBeforeNextMutationEvent (size_t state) const
 Get the time before next mutation event. More...
 
MutationPath detailedEvolve (size_t initialState, double time) const
 Simulation a character evolution during a specified time according to the given substitution model and send the total path with all intermediate states and times between mutation events. More...
 
MutationPath detailedEvolve (size_t initialState, size_t finalState, double time) const
 Simulation a character evolution during a specified time according to the given substitution model and send the total path with all intermediate states and times between mutation events, conditional to the final state.q. More...
 
std::shared_ptr< const SubstitutionModelInterfacegetSubstitutionModel () const
 Get the substitution model associated to the mutation process. More...
 

Protected Attributes

std::shared_ptr< const SubstitutionModelInterfacemodel_
 The substitution model to use: More...
 
size_t size_
 The number of states allowed for the character to mutate. More...
 
VVdouble repartition_
 The repartition function for states probabilities. More...
 

Detailed Description

Generally used mutation process model.

This builds a MutationProcess according to a given SubstitutionModel. The underlying mutation process is the following:

  1. Draw a random time $ t $ from an exponential law with parameter $ - \lambda_i $,
  2. Mutate the initial state. The probability of mutating state $i$ to state $j$ is:

    \[ \frac{Q_{i,j}}{\sum_k Q_{i,k}}. \]

Definition at line 325 of file MutationProcess.h.

Constructor & Destructor Documentation

◆ SimpleMutationProcess()

SimpleMutationProcess::SimpleMutationProcess ( std::shared_ptr< const SubstitutionModelInterface model)

Build a new SimpleMutationProcess object.

Parameters
modelThe substitution model to use.

Definition at line 137 of file MutationProcess.cpp.

References bpp::abs(), bpp::AbstractMutationProcess::repartition_, bpp::AbstractMutationProcess::size_, and bpp::NumConstants::TINY().

◆ ~SimpleMutationProcess()

SimpleMutationProcess::~SimpleMutationProcess ( )
virtual

Definition at line 178 of file MutationProcess.cpp.

Member Function Documentation

◆ detailedEvolve() [1/2]

MutationPath AbstractMutationProcess::detailedEvolve ( size_t  initialState,
double  time 
) const
virtualinherited

Simulation a character evolution during a specified time according to the given substitution model and send the total path with all intermediate states and times between mutation events.

Parameters
initialStateThe state before beginning evolution.
timeThe time during which evolution must occur.
Returns
The resulting mutation path.

Implements bpp::MutationProcess.

Definition at line 70 of file MutationProcess.cpp.

References bpp::MutationPath::addEvent().

Referenced by bpp::NonHomogeneousSequenceSimulator::dEvolveInternal(), and bpp::SimpleSubstitutionProcessSiteSimulator::evolveInternal().

◆ detailedEvolve() [2/2]

MutationPath AbstractMutationProcess::detailedEvolve ( size_t  initialState,
size_t  finalState,
double  time 
) const
virtualinherited

Simulation a character evolution during a specified time according to the given substitution model and send the total path with all intermediate states and times between mutation events, conditional to the final state.q.

Parameters
initialStateThe state before beginning evolution.
finalStateThe state after evolution.
timeThe time during which evolution must occur.
Returns
The resulting mutation path.

Implements bpp::MutationProcess.

Definition at line 89 of file MutationProcess.cpp.

References bpp::MutationPath::addEvent(), bpp::MutationPath::clear(), bpp::exp(), bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), and bpp::log().

◆ evolve()

size_t SimpleMutationProcess::evolve ( size_t  initialState,
double  time 
) const
virtual

Method redefinition for better performance.

Parameters
initialStateThe state before beginning evolution.
timeThe time during which evolution must occur.
Returns
The resulting state after evolution is completed.

Reimplemented from bpp::AbstractMutationProcess.

Definition at line 182 of file MutationProcess.cpp.

References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), bpp::AbstractMutationProcess::model_, bpp::AbstractMutationProcess::size_, and bpp::TextTools::toString().

◆ getSubstitutionModel()

std::shared_ptr<const SubstitutionModelInterface> bpp::AbstractMutationProcess::getSubstitutionModel ( ) const
inlinevirtualinherited

Get the substitution model associated to the mutation process.

Returns
The SubstitutionModel associated to this instance.

Implements bpp::MutationProcess.

Definition at line 309 of file MutationProcess.h.

References bpp::AbstractMutationProcess::model_.

◆ getTimeBeforeNextMutationEvent()

double AbstractMutationProcess::getTimeBeforeNextMutationEvent ( size_t  state) const
virtualinherited

Get the time before next mutation event.

Parameters
stateThe actual state of the chain;
Returns
A random time before next mutation event.

Implements bpp::MutationProcess.

Definition at line 48 of file MutationProcess.cpp.

References bpp::RandomTools::randExponential().

◆ mutate() [1/2]

size_t AbstractMutationProcess::mutate ( size_t  state) const
virtualinherited

Mutate a character in state i.

Parameters
stateThe current state of the character.

Implements bpp::MutationProcess.

Definition at line 15 of file MutationProcess.cpp.

References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), and bpp::TextTools::toString().

◆ mutate() [2/2]

size_t AbstractMutationProcess::mutate ( size_t  state,
unsigned int  n 
) const
virtualinherited

Mutate a character in state i n times.

Parameters
stateThe current state of the character.
nThe number of mutations to perform.

Implements bpp::MutationProcess.

Definition at line 28 of file MutationProcess.cpp.

References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry().

Member Data Documentation

◆ model_

std::shared_ptr<const SubstitutionModelInterface> bpp::AbstractMutationProcess::model_
protectedinherited

The substitution model to use:

Definition at line 282 of file MutationProcess.h.

Referenced by evolve(), and bpp::AbstractMutationProcess::getSubstitutionModel().

◆ repartition_

VVdouble bpp::AbstractMutationProcess::repartition_
protectedinherited

The repartition function for states probabilities.

repartition_[i][j] = probability that, being in state i at time t, we'll be in state <= j at time t+1.

Definition at line 295 of file MutationProcess.h.

Referenced by bpp::SelfMutationProcess::SelfMutationProcess(), and SimpleMutationProcess().

◆ size_

size_t bpp::AbstractMutationProcess::size_
protectedinherited

The number of states allowed for the character to mutate.

Definition at line 287 of file MutationProcess.h.

Referenced by evolve(), bpp::SelfMutationProcess::SelfMutationProcess(), and SimpleMutationProcess().


The documentation for this class was generated from the following files: