bpp-phyl  2.2.0
bpp::RewardMappingTools Class Reference

Provide methods to compute reward mappings. More...

#include <Bpp/Phyl/Mapping/RewardMappingTools.h>

Public Member Functions

 RewardMappingTools ()
 
virtual ~RewardMappingTools ()
 

Static Public Member Functions

static ProbabilisticRewardMappingcomputeRewardVectors (const DRTreeLikelihood &drtl, const std::vector< int > &nodeIds, Reward &reward, bool verbose=true) throw (Exception)
 Compute the reward vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static void writeToStream (const ProbabilisticRewardMapping &rewards, const SiteContainer &sites, std::ostream &out) throw (IOException)
 Write the reward vectors to a stream. More...
 
static void readFromStream (std::istream &in, ProbabilisticRewardMapping &rewards) throw (IOException)
 Read the reward vectors from a stream. More...
 
static double computeSumForBranch (const RewardMapping &smap, size_t branchIndex)
 Sum all rewards of a given branch (specified by its index). More...
 
static double computeSumForSite (const RewardMapping &smap, size_t siteIndex)
 Sum all substitutions for each type of a given site (specified by its index). More...
 

Detailed Description

Provide methods to compute reward mappings.

For now, 4 methods are implemented, and provide reward mappings.

See: Minin, V.N. and Suchard, M.A., Fast, accurate and simulation-free stochastic mapping Philosophical Transactions of the Royal Society B 2008 363:3985-95.

Author
Laurent Guéguen

Definition at line 62 of file RewardMappingTools.h.

Constructor & Destructor Documentation

◆ RewardMappingTools()

bpp::RewardMappingTools::RewardMappingTools ( )
inline

Definition at line 65 of file RewardMappingTools.h.

◆ ~RewardMappingTools()

virtual bpp::RewardMappingTools::~RewardMappingTools ( )
inlinevirtual

Definition at line 66 of file RewardMappingTools.h.

Member Function Documentation

◆ computeRewardVectors()

ProbabilisticRewardMapping * RewardMappingTools::computeRewardVectors ( const DRTreeLikelihood drtl,
const std::vector< int > &  nodeIds,
Reward reward,
bool  verbose = true 
)
throw (Exception
)
static

Compute the reward vectors for a particular dataset using the double-recursive likelihood computation.

Parameters
drtlA DRTreeLikelihood object.
nodeIdsThe Ids of the nodes the reward vectors are computed on.
rewardThe Reward to use.
verbosePrint info to screen.
Returns
A vector of reward vectors (one for each site).
Exceptions
ExceptionIf the likelihood object is not initialized.

Definition at line 58 of file RewardMappingTools.cpp.

References bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeLikelihood::ConstBranchModelDescription::getModel(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::TreeTemplate< N >::getNodes(), bpp::Node::getNumberOfSons(), bpp::Node::getSon(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), and bpp::TreeLikelihood::ConstBranchModelIterator::next().

Referenced by bpp::SubstitutionMappingTools::getNormalizationsPerBranch().

◆ computeSumForBranch()

double RewardMappingTools::computeSumForBranch ( const RewardMapping smap,
size_t  branchIndex 
)
static

Sum all rewards of a given branch (specified by its index).

Parameters
smapThe reward map to use.
branchIndexThe index of the reward vector for which the counts should be computed.
Returns
A vector will all rewards summed.

Definition at line 423 of file RewardMappingTools.cpp.

References bpp::Mapping::getNumberOfSites().

◆ computeSumForSite()

double RewardMappingTools::computeSumForSite ( const RewardMapping smap,
size_t  siteIndex 
)
static

Sum all substitutions for each type of a given site (specified by its index).

Parameters
smapThe substitution map to use.
siteIndexThe index of the substitution vector for which the counts should be computed.
Returns
A vector will all counts summed for each types of substitutions.

Definition at line 436 of file RewardMappingTools.cpp.

References bpp::Mapping::getNumberOfBranches().

◆ readFromStream()

void RewardMappingTools::readFromStream ( std::istream &  in,
ProbabilisticRewardMapping rewards 
)
throw (IOException
)
static

Read the reward vectors from a stream.

Parameters
inThe input stream where to read the vectors.
rewardsThe mapping object to fill.
Exceptions
IOExceptionIf an input error happens.

Definition at line 379 of file RewardMappingTools.cpp.

◆ writeToStream()

void RewardMappingTools::writeToStream ( const ProbabilisticRewardMapping rewards,
const SiteContainer &  sites,
std::ostream &  out 
)
throw (IOException
)
static

Write the reward vectors to a stream.

Parameters
rewardsThe reward vectors to write.
sitesThe dataset associated to the vectors (needed to know the position of each site in the dataset).
outThe output stream where to write the vectors.
Exceptions
IOExceptionIf an output error happens.

Definition at line 350 of file RewardMappingTools.cpp.


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