bpp-phyl3  3.0.0
bpp::LegacyProbabilisticSubstitutionMapping Class Referenceabstract

Legacy data storage class for probabilistic substitution mappings. More...

#include <Bpp/Phyl/Legacy/Mapping/ProbabilisticSubstitutionMapping.h>

+ Inheritance diagram for bpp::LegacyProbabilisticSubstitutionMapping:
+ Collaboration diagram for bpp::LegacyProbabilisticSubstitutionMapping:

Public Member Functions

 LegacyProbabilisticSubstitutionMapping (const Tree &tree, std::shared_ptr< const SubstitutionCountInterface > sc, size_t numberOfSites)
 Build a new LegacyProbabilisticSubstitutionMapping object. More...
 
 LegacyProbabilisticSubstitutionMapping (const Tree &tree)
 Build a new ProbabilisticSubstitutionMapping object. More...
 
LegacyProbabilisticSubstitutionMappingclone () const override
 
 LegacyProbabilisticSubstitutionMapping (const LegacyProbabilisticSubstitutionMapping &psm)=default
 
LegacyProbabilisticSubstitutionMappingoperator= (const LegacyProbabilisticSubstitutionMapping &psm)=default
 
virtual ~LegacyProbabilisticSubstitutionMapping ()
 
size_t getNumberOfSubstitutionTypes () const override
 
double getNumberOfSubstitutions (int nodeId, size_t siteIndex, size_t type) const
 
virtual std::vector< double > getNumberOfSubstitutions (int nodeId, size_t siteIndex) const
 
virtual void setTree (const Tree &tree)
 (Re)-set the phylogenetic tree associated to this mapping. More...
 
virtual void setNumberOfSites (size_t numberOfSites) override
 
virtual double & operator() (size_t nodeIndex, size_t siteIndex, size_t type) override
 Direct access to substitution numbers. More...
 
virtual const double & operator() (size_t nodeIndex, size_t siteIndex, size_t type) const override
 Direct access to substitution numbers. More...
 
std::vector< std::vector< double > > & operator[] (size_t siteIndex)
 Direct access to substitution numbers. More...
 
const std::vector< std::vector< double > > & operator[] (size_t siteIndex) const
 Direct access to substitution numbers. More...
 
virtual const Treetree () const =0
 
const TreeTemplate< Node > & tree () const override
 
virtual bool isEmpty () const =0
 
bool isEmpty () const override
 
virtual size_t getNumberOfSites () const =0
 
size_t getNumberOfSites () const override
 
virtual size_t getNumberOfBranches () const =0
 
size_t getNumberOfBranches () const override
 
virtual int getSitePosition (size_t index) const =0
 
int getSitePosition (size_t index) const override
 
virtual std::vector< double > getBranchLengths () const =0
 
virtual std::vector< double > getBranchLengths () const override
 
virtual size_t getNodeIndex (int nodeId) const =0
 
virtual size_t getNodeIndex (int nodeId) const override
 
virtual void setSitePosition (size_t index, int position)=0
 Set the position of a given site. More...
 
void setSitePosition (size_t index, int position) override
 Set the position of a given site. More...
 
virtual const NodegetNode (size_t nodeIndex) const
 

Private Attributes

std::shared_ptr< const SubstitutionCountInterfacesubstitutionCount_
 
std::vector< std::vector< std::vector< double > > > mapping_
 Substitution numbers storage. More...
 
std::unique_ptr< const TreeTemplate< Node > > tree_
 
std::vector< int > sitesPositions_
 
std::vector< const Node * > nodes_
 
size_t nbSites_
 
size_t nbBranches_
 

Detailed Description

Legacy data storage class for probabilistic substitution mappings.

A 'probabilistic' mapping contains an single value for each branch and each site. This number can be an average number of substitutions, optionally waited, or a probability of observing a certain number of substitutions. Probabilistic was coined there by opposition to the'stochastic' mapping, where a path (number of susbstitutions + there position along the branch) is available for each branch and site. The probabilistic mapping can however be extended to contain a matrix will all types of substitutions, instead of their total number.

Definition at line 27 of file ProbabilisticSubstitutionMapping.h.

Constructor & Destructor Documentation

◆ LegacyProbabilisticSubstitutionMapping() [1/3]

bpp::LegacyProbabilisticSubstitutionMapping::LegacyProbabilisticSubstitutionMapping ( const Tree tree,
std::shared_ptr< const SubstitutionCountInterface sc,
size_t  numberOfSites 
)
inline

Build a new LegacyProbabilisticSubstitutionMapping object.

Parameters
treeThe tree object to use. It will be cloned for internal use.
scA pointer toward the substitution count object that has been used for the mapping, if any. This object allows to get the substitution types description, if there are several. If set to 0, then the mapping will be considered as having only one type of substitution mapped.
numberOfSitesThe number of sites to map.

Definition at line 50 of file ProbabilisticSubstitutionMapping.h.

References setNumberOfSites().

Referenced by clone().

◆ LegacyProbabilisticSubstitutionMapping() [2/3]

bpp::LegacyProbabilisticSubstitutionMapping::LegacyProbabilisticSubstitutionMapping ( const Tree tree)
inline

Build a new ProbabilisticSubstitutionMapping object.

Parameters
treeThe tree object to use. It will be cloned for internal use.

Definition at line 63 of file ProbabilisticSubstitutionMapping.h.

◆ LegacyProbabilisticSubstitutionMapping() [3/3]

bpp::LegacyProbabilisticSubstitutionMapping::LegacyProbabilisticSubstitutionMapping ( const LegacyProbabilisticSubstitutionMapping psm)
default

◆ ~LegacyProbabilisticSubstitutionMapping()

virtual bpp::LegacyProbabilisticSubstitutionMapping::~LegacyProbabilisticSubstitutionMapping ( )
inlinevirtual

Definition at line 79 of file ProbabilisticSubstitutionMapping.h.

Member Function Documentation

◆ clone()

LegacyProbabilisticSubstitutionMapping* bpp::LegacyProbabilisticSubstitutionMapping::clone ( ) const
inlineoverridevirtual

◆ getBranchLengths() [1/2]

virtual std::vector<double> bpp::LegacyMappingInterface::getBranchLengths ( ) const
pure virtualinherited
Returns
A vector with all tree branch lengths.

Implemented in bpp::LegacyAbstractMapping.

◆ getBranchLengths() [2/2]

virtual std::vector<double> bpp::LegacyAbstractMapping::getBranchLengths ( ) const
inlineoverridevirtualinherited
Returns
A vector with all tree branch lengths.

Implements bpp::LegacyMappingInterface.

Definition at line 174 of file Mapping.h.

References bpp::LegacyAbstractMapping::nbBranches_, and bpp::LegacyAbstractMapping::nodes_.

◆ getNode()

virtual const Node* bpp::LegacyAbstractMapping::getNode ( size_t  nodeIndex) const
inlinevirtualinherited

◆ getNodeIndex() [1/2]

virtual size_t bpp::LegacyMappingInterface::getNodeIndex ( int  nodeId) const
pure virtualinherited
Parameters
nodeIdAn id of the node to look for in the map.
Returns
The mapping index for the specified node id.

Implemented in bpp::LegacyAbstractMapping.

◆ getNodeIndex() [2/2]

virtual size_t bpp::LegacyAbstractMapping::getNodeIndex ( int  nodeId) const
inlineoverridevirtualinherited

◆ getNumberOfBranches() [1/2]

◆ getNumberOfBranches() [2/2]

size_t bpp::LegacyAbstractMapping::getNumberOfBranches ( ) const
inlineoverridevirtualinherited

◆ getNumberOfSites() [1/2]

virtual size_t bpp::LegacyMappingInterface::getNumberOfSites ( ) const
pure virtualinherited

◆ getNumberOfSites() [2/2]

size_t bpp::LegacyAbstractMapping::getNumberOfSites ( ) const
inlineoverridevirtualinherited

◆ getNumberOfSubstitutions() [1/2]

virtual std::vector<double> bpp::LegacyProbabilisticSubstitutionMapping::getNumberOfSubstitutions ( int  nodeId,
size_t  siteIndex 
) const
inlinevirtual

◆ getNumberOfSubstitutions() [2/2]

double bpp::LegacyProbabilisticSubstitutionMapping::getNumberOfSubstitutions ( int  nodeId,
size_t  siteIndex,
size_t  type 
) const
inline

◆ getNumberOfSubstitutionTypes()

size_t bpp::LegacyProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes ( ) const
inlineoverridevirtual
Returns
The number of distinct types of substitutions mapped.

Implements bpp::LegacySubstitutionMappingInterface.

Definition at line 82 of file ProbabilisticSubstitutionMapping.h.

References substitutionCount_.

Referenced by setNumberOfSites().

◆ getSitePosition() [1/2]

virtual int bpp::LegacyMappingInterface::getSitePosition ( size_t  index) const
pure virtualinherited
Parameters
indexThe site index.
Returns
The site position corresponding to the index.

Implemented in bpp::LegacyAbstractMapping.

◆ getSitePosition() [2/2]

int bpp::LegacyAbstractMapping::getSitePosition ( size_t  index) const
inlineoverridevirtualinherited
Parameters
indexThe site index.
Returns
The site position corresponding to the index.

Implements bpp::LegacyMappingInterface.

Definition at line 146 of file Mapping.h.

References bpp::LegacyAbstractMapping::isEmpty(), and bpp::LegacyAbstractMapping::sitesPositions_.

◆ isEmpty() [1/2]

virtual bool bpp::LegacyMappingInterface::isEmpty ( ) const
pure virtualinherited
Returns
True is the map is empty, that is, if no tree is associated to the map yet.

Implemented in bpp::LegacyAbstractMapping.

◆ isEmpty() [2/2]

bool bpp::LegacyAbstractMapping::isEmpty ( ) const
inlineoverridevirtualinherited
Returns
True is the map is empty, that is, if no tree is associated to the map yet.

Implements bpp::LegacyMappingInterface.

Definition at line 130 of file Mapping.h.

References bpp::LegacyAbstractMapping::tree_.

Referenced by bpp::LegacyAbstractMapping::getSitePosition(), bpp::LegacyAbstractMapping::setSitePosition(), and bpp::LegacyAbstractMapping::tree().

◆ operator()() [1/2]

virtual const double& bpp::LegacyProbabilisticSubstitutionMapping::operator() ( size_t  nodeIndex,
size_t  siteIndex,
size_t  type 
) const
inlineoverridevirtual

Direct access to substitution numbers.

Warning
No index checking is performed, use with care!

Implements bpp::LegacySubstitutionMappingInterface.

Definition at line 122 of file ProbabilisticSubstitutionMapping.h.

References mapping_.

◆ operator()() [2/2]

virtual double& bpp::LegacyProbabilisticSubstitutionMapping::operator() ( size_t  nodeIndex,
size_t  siteIndex,
size_t  type 
)
inlineoverridevirtual

Direct access to substitution numbers.

Warning
No index checking is performed, use with care!

Implements bpp::LegacySubstitutionMappingInterface.

Definition at line 112 of file ProbabilisticSubstitutionMapping.h.

References mapping_.

◆ operator=()

LegacyProbabilisticSubstitutionMapping& bpp::LegacyProbabilisticSubstitutionMapping::operator= ( const LegacyProbabilisticSubstitutionMapping psm)
default

◆ operator[]() [1/2]

std::vector< std::vector<double> >& bpp::LegacyProbabilisticSubstitutionMapping::operator[] ( size_t  siteIndex)
inline

Direct access to substitution numbers.

Warning
No index checking is performed, use with care!

Definition at line 132 of file ProbabilisticSubstitutionMapping.h.

References mapping_.

◆ operator[]() [2/2]

const std::vector< std::vector<double> >& bpp::LegacyProbabilisticSubstitutionMapping::operator[] ( size_t  siteIndex) const
inline

Direct access to substitution numbers.

Warning
No index checking is performed, use with care!

Definition at line 142 of file ProbabilisticSubstitutionMapping.h.

References mapping_.

◆ setNumberOfSites()

void LegacyProbabilisticSubstitutionMapping::setNumberOfSites ( size_t  numberOfSites)
overridevirtual

◆ setSitePosition() [1/2]

void bpp::LegacyAbstractMapping::setSitePosition ( size_t  index,
int  position 
)
inlineoverridevirtualinherited

Set the position of a given site.

Warning
No index checking is performed, use with care!
Parameters
indexThe site index.
positionThe position of the site.

Implements bpp::LegacyMappingInterface.

Definition at line 152 of file Mapping.h.

References bpp::LegacyAbstractMapping::isEmpty(), and bpp::LegacyAbstractMapping::sitesPositions_.

Referenced by bpp::LegacyRewardMappingTools::readFromStream(), and bpp::LegacySubstitutionMappingTools::readFromStream().

◆ setSitePosition() [2/2]

virtual void bpp::LegacyMappingInterface::setSitePosition ( size_t  index,
int  position 
)
pure virtualinherited

Set the position of a given site.

Warning
No index checking is performed, use with care!
Parameters
indexThe site index.
positionThe position of the site.

Implemented in bpp::LegacyAbstractMapping.

◆ setTree()

void LegacyProbabilisticSubstitutionMapping::setTree ( const Tree tree)
virtual

(Re)-set the phylogenetic tree associated to this mapping.

Parameters
treeThe new tree.

Definition at line 9 of file ProbabilisticSubstitutionMapping.cpp.

References bpp::LegacyAbstractMapping::getNumberOfBranches(), bpp::LegacyAbstractMapping::getNumberOfSites(), mapping_, bpp::LegacyAbstractMapping::setTree(), and bpp::LegacyAbstractMapping::tree().

◆ tree() [1/2]

virtual const Tree& bpp::LegacyMappingInterface::tree ( ) const
pure virtualinherited
Returns
Get the phylogenetic tree associated to this mapping.

Implemented in bpp::LegacyAbstractMapping.

◆ tree() [2/2]

const TreeTemplate<Node>& bpp::LegacyAbstractMapping::tree ( ) const
inlineoverridevirtualinherited
Returns
Get the phylogenetic tree associated to this mapping.

Implements bpp::LegacyMappingInterface.

Definition at line 132 of file Mapping.h.

References bpp::LegacyAbstractMapping::isEmpty(), and bpp::LegacyAbstractMapping::tree_.

Referenced by bpp::LegacyAbstractMapping::setTree(), bpp::LegacyProbabilisticRewardMapping::setTree(), and setTree().

Member Data Documentation

◆ mapping_

std::vector<std::vector<std::vector<double> > > bpp::LegacyProbabilisticSubstitutionMapping::mapping_
private

Substitution numbers storage.

Numbers are stored by sites.

Definition at line 38 of file ProbabilisticSubstitutionMapping.h.

Referenced by getNumberOfSubstitutions(), operator()(), operator[](), setNumberOfSites(), and setTree().

◆ nbBranches_

◆ nbSites_

size_t bpp::LegacyAbstractMapping::nbSites_
privateinherited

◆ nodes_

◆ sitesPositions_

std::vector<int> bpp::LegacyAbstractMapping::sitesPositions_
privateinherited

◆ substitutionCount_

std::shared_ptr<const SubstitutionCountInterface> bpp::LegacyProbabilisticSubstitutionMapping::substitutionCount_
private

Definition at line 31 of file ProbabilisticSubstitutionMapping.h.

Referenced by getNumberOfSubstitutionTypes().

◆ tree_


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