40 #ifndef _MUTATIONPROCESS_H_ 41 #define _MUTATIONPROCESS_H_ 43 #include "../Model/SubstitutionModel.h" 44 #include "../Mapping/SubstitutionRegister.h" 46 #include <Bpp/Numeric/VectorTools.h> 93 MutationPath(
const Alphabet* alphabet,
size_t initialState,
double time) :
154 template<
class Scalar>
156 if (counts.getNumberOfRows() !=
alphabet_->getSize()
157 || counts.getNumberOfColumns() !=
alphabet_->getSize())
158 throw Exception(
"MutationPath::getEventCounts. Incorrect input matrix, does not match alphabet size.");
160 for (
size_t i = 0; i <
states_.size(); ++i) {
162 counts(currentState, newState)++;
163 currentState = newState;
173 template<
class Scalar>
176 throw Exception(
"MutationPath::getEventCounts. Incorrect input vector, does not match alphabet size.");
178 for (
size_t i = 0; i <
states_.size(); ++i) {
180 size_t type = reg.
getType(currentState, newState);
181 if (type > 0) counts[type - 1]++;
182 currentState = newState;
217 virtual size_t mutate(
size_t state)
const = 0;
225 virtual size_t mutate(
size_t state,
unsigned int n)
const = 0;
243 virtual size_t evolve(
size_t initialState,
double time)
const = 0;
320 size_t mutate(
size_t state)
const;
321 size_t mutate(
size_t state,
unsigned int n)
const;
323 size_t evolve(
size_t initialState,
double time)
const;
361 size_t evolve(
size_t initialState,
double time)
const;
378 #endif //_MUTATIONPROCESS_H_ void getEventCounts(std::vector< Scalar > &counts, const SubstitutionRegister ®) const
Retrieve the number of substitution events per type of substitution, defined by a SubstitutionRegiste...
virtual double getTimeBeforeNextMutationEvent(size_t state) const =0
Get the time before next mutation event.
size_t initialState_
The initial state.
Interface for all substitution models.
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...
VVdouble repartition_
The repartition function for states probabilities.
std::vector< size_t > states_
The states taken, without initial state.
MutationPath detailedEvolve(size_t initialState, double time) const
Simulation a character evolution during a specified time according to the given substitution model an...
This class is used by MutationProcess to store detailed results of simulations.
The SubstitutionRegister interface.
const Alphabet * getAlphabet() const
size_t mutate(size_t state) const
Mutate a character in state i.
MutationPath(const Alphabet *alphabet, size_t initialState, double time)
Builds a new MutationPath object with initial state 'initialState' and total time 'time'...
SelfMutationProcess(size_t alphabetSize)
size_t size_
The number of states allowed for the character to mutate.
size_t getNumberOfEvents() const
Retrieve the number of substitution events.
Partial implmentation of the MutationProcess interface.
MutationPath & operator=(const MutationPath &path)
Interface for simulations.
MutationPath(const MutationPath &path)
SimpleMutationProcess(const SubstitutionModel *model)
Build a new SimpleMutationProcess object.
std::vector< double > times_
Times between states. The first element in array is the time between the initial state and the first ...
virtual ~SimpleMutationProcess()
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...
double getTimeBeforeNextMutationEvent(size_t state) const
Get the time before next mutation event.
AbstractMutationProcess(const AbstractMutationProcess &)
void getEventCounts(Matrix< Scalar > &counts) const
Retrieve the number of substitution events per type of substitution.
virtual size_t getNumberOfSubstitutionTypes() const =0
AbstractMutationProcess(const SubstitutionModel *model)
virtual size_t getType(size_t fromState, size_t toState) const =0
Get the substitution type far a given pair of model states.
size_t evolve(size_t initialState, double time) const
Simulation a character evolution during a specified time according to the given substitution model an...
virtual ~MutationProcess()
This class is mainly for testing purpose. It allow "self" mutation of the kind i->i;.
double totalTime_
Total time of evolution. Typically, this is a branch length.
virtual const SubstitutionModel * getSubstitutionModel() const =0
Get the substitution model associated to the mutation process.
AbstractMutationProcess & operator=(const AbstractMutationProcess &)
const SubstitutionModel * getSubstitutionModel() const
Get the substitution model associated to the mutation process.
virtual ~SelfMutationProcess()
const Alphabet * alphabet_
size_t getInitialState() const
Retrieve the initial state.
virtual ~AbstractMutationProcess()
size_t evolve(size_t initialState, double time) const
Method redefinition for better performance.
size_t getFinalState() const
Retrieve the final state of this path.
double getTotalTime() const
Retrieve the total time of evolution.
Generally used mutation process model.
virtual size_t mutate(size_t state) const =0
Mutate a character in state i.
const SubstitutionModel * model_
The substitution model to use:
void addEvent(size_t state, double time)
Add a new mutation event.