5 #ifndef BPP_PHYL_SIMULATION_MUTATIONPROCESS_H
6 #define BPP_PHYL_SIMULATION_MUTATIONPROCESS_H
10 #include "../Mapping/SubstitutionRegister.h"
11 #include "../Model/SubstitutionModel.h"
56 std::shared_ptr<const Alphabet>
alphabet,
135 template<
class Scalar>
140 throw Exception(
"MutationPath::getEventCounts. Incorrect input matrix, does not match alphabet size.");
142 for (
size_t i = 0; i <
states_.size(); ++i)
145 counts(currentState, newState)++;
146 currentState = newState;
156 template<
class Scalar>
160 throw Exception(
"MutationPath::getEventCounts. Incorrect input vector, does not match alphabet size.");
162 for (
size_t i = 0; i <
states_.size(); ++i)
165 size_t type = reg.
getType(currentState, newState);
166 if (type > 0) counts[type - 1]++;
167 currentState = newState;
202 virtual size_t mutate(
size_t state)
const = 0;
210 virtual size_t mutate(
size_t state,
unsigned int n)
const = 0;
228 virtual size_t evolve(
size_t initialState,
double time)
const = 0;
282 std::shared_ptr<const SubstitutionModelInterface>
model_;
303 size_t mutate(
size_t state)
const;
304 size_t mutate(
size_t state,
unsigned int n)
const;
306 size_t evolve(
size_t initialState,
double time)
const;
347 size_t evolve(
size_t initialState,
double time)
const;
Partial implementation of the MutationProcess interface.
size_t size_
The number of states allowed for the character to mutate.
size_t evolve(size_t initialState, double time) const
Simulation a character evolution during a specified time according to the given substitution model an...
std::shared_ptr< const SubstitutionModelInterface > model_
The substitution model to use:
size_t mutate(size_t state) const
Mutate a character in state i.
VVdouble repartition_
The repartition function for states probabilities.
double getTimeBeforeNextMutationEvent(size_t state) const
Get the time before next mutation event.
AbstractMutationProcess(std::shared_ptr< const SubstitutionModelInterface > model)
std::shared_ptr< const SubstitutionModelInterface > getSubstitutionModel() const
Get the substitution model associated to the mutation process.
MutationPath detailedEvolve(size_t initialState, double time) const
Simulation a character evolution during a specified time according to the given substitution model an...
virtual size_t getNumberOfColumns() const=0
virtual size_t getNumberOfRows() const=0
This class is used by MutationProcess to store detailed results of simulations.
double getTotalTime() const
Retrieve the total time of evolution.
void getEventCounts(std::vector< Scalar > &counts, const SubstitutionRegisterInterface ®) const
Retrieve the number of substitution events per type of substitution, defined by a SubstitutionRegiste...
void getEventCounts(Matrix< Scalar > &counts) const
Retrieve the number of substitution events per type of substitution.
size_t getInitialState() const
Retrieve the initial state.
std::vector< double > times_
Times between states. The first element in array is the time between the initial state and the first ...
double totalTime_
Total time of evolution. Typically, this is a branch length.
std::shared_ptr< const Alphabet > getAlphabet() const
MutationPath(std::shared_ptr< const Alphabet > alphabet, size_t initialState, double time)
Builds a new MutationPath object with initial state 'initialState' and total time 'time'.
std::vector< size_t > states_
The states taken, without initial state.
size_t initialState_
The initial state.
const Alphabet & alphabet() const
size_t getFinalState() const
Retrieve the final state of this path.
void addEvent(size_t state, double time)
Add a new mutation event.
std::shared_ptr< const Alphabet > alphabet_
size_t getNumberOfEvents() const
Retrieve the number of substitution events.
MutationPath & operator=(const MutationPath &path)
MutationPath(const MutationPath &path)
Interface for simulations.
virtual ~MutationProcess()
virtual std::shared_ptr< const SubstitutionModelInterface > getSubstitutionModel() const =0
Get the substitution model associated to the mutation process.
virtual MutationPath detailedEvolve(size_t initialState, double time) const =0
Simulation a character evolution during a specified time according to the given substitution model an...
virtual size_t evolve(size_t initialState, double time) const =0
Simulation a character evolution during a specified time according to the given substitution model an...
virtual size_t mutate(size_t state) const =0
Mutate a character in state i.
virtual double getTimeBeforeNextMutationEvent(size_t state) const =0
Get the time before next mutation event.
virtual MutationPath detailedEvolve(size_t initialState, size_t finalState, double time) const =0
Simulation a character evolution during a specified time according to the given substitution model an...
virtual size_t mutate(size_t state, unsigned int n) const =0
Mutate a character in state i n times.
This class is mainly for testing purpose. It allow "self" mutation of the kind i->i;.
virtual ~SelfMutationProcess()
SelfMutationProcess(size_t alphabetSize)
Generally used mutation process model.
size_t evolve(size_t initialState, double time) const
Method redefinition for better performance.
virtual ~SimpleMutationProcess()
SimpleMutationProcess(std::shared_ptr< const SubstitutionModelInterface > model)
Build a new SimpleMutationProcess object.
The SubstitutionRegister interface.
virtual size_t getNumberOfSubstitutionTypes() const =0
virtual size_t getType(size_t fromState, size_t toState) const =0
Get the substitution type far a given pair of model states.
Defines the basic types of data flow nodes.
std::vector< Vdouble > VVdouble