CMAPLE 1.0.0
C++ MAximum Parsimonious Likelihood Estimation
|
#include <tree.h>
Public Types | |
enum | TreeSearchType { FAST_TREE_SEARCH , NORMAL_TREE_SEARCH , EXHAUSTIVE_TREE_SEARCH , UNKNOWN_TREE_SEARCH } |
enum | TreeType { BIN_TREE , MUL_TREE , UNKNOWN_TREE } |
Public Member Functions | |
Tree (Alignment *aln, Model *model, std::istream &tree_stream, const bool fixed_blengths=false, std::unique_ptr< cmaple::Params > &¶ms=nullptr) | |
Constructor from a stream of a (bifurcating or multifurcating) tree (with/without branch lengths in NEWICK format), which may or may not contain all taxa in the alignment. Model parameters (if not fixed) will be estimated according to the input tree and the alignment. | |
Tree (Alignment *aln, Model *model, const std::string &tree_filename="", const bool fixed_blengths=false, std::unique_ptr< cmaple::Params > &¶ms=nullptr) | |
Constructor from an optional (bifurcating or multifurcating) tree (with/without branch lengths in NEWICK format), which may or may not contain all taxa in the alignment. If users specify an input tree, model parameters (if not fixed) will be estimated according to that tree and the alignment. | |
~Tree () | |
void | load (std::istream &tree_stream, const bool fixed_blengths=false) |
Load a tree from a stream of a (bifurcating or multifurcating) tree (with/without branch lengths) in NEWICK format, which may or may not contain all taxa in the alignment. Model parameters (if not fixed) will be estimated according to the input tree and the alignment. | |
void | load (const std::string &tree_filename, const bool fixed_blengths=false) |
Load a tree from a (bifurcating or multifurcating) tree (with/without branch lengths) in NEWICK format, which may or may not contain all taxa in the alignment. Model parameters (if not fixed) will be estimated according to the input tree and the alignment. | |
void | changeAln (Alignment *aln) |
Change the alignment. | |
void | changeModel (Model *model) |
Change the substitution model. | |
void | doPlacement (std::ostream &out_stream=std::cout) |
Do placement (using stepwise addition) to build an initial tree. Model parameters (if not fixed) will be estimated during the placement process. | |
void | applySPR (const TreeSearchType tree_search_type, const bool shallow_tree_search, std::ostream &out_stream=std::cout) |
Apply SPR moves to optimize the tree. | |
void | optimizeBranch (std::ostream &out_stream=std::cout) |
Optimize the branch lengths of the tree. | |
void | infer (const TreeSearchType tree_search_type=NORMAL_TREE_SEARCH, const bool shallow_tree_search=false, std::ostream &out_stream=std::cout) |
Infer a maximum likelihood tree by executing doPlacement(), applySPR(), and optimizeBranch() | |
RealNumType | computeLh () |
Compute the log likelihood of the current tree, which may or may not contain all taxa in the alignment. | |
void | computeBranchSupport (const int num_threads=1, const int num_replicates=1000, const double epsilon=0.1, const bool allow_replacing_ML_tree=true, std::ostream &out_stream=std::cout) |
Compute branch supports (aLRT-SH) of the current tree, which may or may not contain all taxa in the alignment. | |
std::string | exportNewick (const TreeType tree_type=BIN_TREE, const bool show_branch_supports=true) |
Export the phylogenetic tree to a string in NEWICK format. | |
The structure of a phylogenetic tree
cmaple::Tree::Tree | ( | Alignment * | aln, |
Model * | model, | ||
std::istream & | tree_stream, | ||
const bool | fixed_blengths = false , |
||
std::unique_ptr< cmaple::Params > && | params = nullptr |
||
) |
Constructor from a stream of a (bifurcating or multifurcating) tree (with/without branch lengths in NEWICK format), which may or may not contain all taxa in the alignment. Model parameters (if not fixed) will be estimated according to the input tree and the alignment.
[in] | aln | An alignment |
[in] | model | A substitution model |
[in] | tree_stream | A stream of an input tree |
[in] | fixed_blengths | TRUE to keep the input branch lengths unchanged (optional) |
[in] | params | an instance of Params which stores all program parameters (optional). Users can build an instance of Params and specify several parameters by using ParamsBuilder |
std::invalid_argument | If any of the following situation occurs.
|
std::logic_error | if any of the following situations occur.
|
std::bad_alloc | if failing to allocate memory to store the tree |
cmaple::Tree::Tree | ( | Alignment * | aln, |
Model * | model, | ||
const std::string & | tree_filename = "" , |
||
const bool | fixed_blengths = false , |
||
std::unique_ptr< cmaple::Params > && | params = nullptr |
||
) |
Constructor from an optional (bifurcating or multifurcating) tree (with/without branch lengths in NEWICK format), which may or may not contain all taxa in the alignment. If users specify an input tree, model parameters (if not fixed) will be estimated according to that tree and the alignment.
[in] | aln | An alignment |
[in] | model | A substitution model |
[in] | tree_filename | Name of a tree file (optinal) |
[in] | fixed_blengths | TRUE to keep the input branch lengths unchanged (optional) |
[in] | params | an instance of Params which stores all program parameters (optional). Users can build an instance of Params and specify several parameters by using ParamsBuilder |
std::invalid_argument | If any of the following situation occurs.
|
ios::failure | if the tree file (if specified) is not found |
std::logic_error | if any of the following situations occur.
|
std::bad_alloc | if failing to allocate memory to store the tree |
cmaple::Tree::~Tree | ( | ) |
Destructor
void cmaple::Tree::load | ( | std::istream & | tree_stream, |
const bool | fixed_blengths = false |
||
) |
Load a tree from a stream of a (bifurcating or multifurcating) tree (with/without branch lengths) in NEWICK format, which may or may not contain all taxa in the alignment. Model parameters (if not fixed) will be estimated according to the input tree and the alignment.
[in] | tree_stream | A stream of an input tree |
[in] | fixed_blengths | TRUE to keep the input branch lengths unchanged (optional) |
std::invalid_argument | if the tree is empty or in an incorrect format |
std::logic_error | if any of the following situations occur.
|
std::bad_alloc | if failing to allocate memory to store the tree |
void cmaple::Tree::load | ( | const std::string & | tree_filename, |
const bool | fixed_blengths = false |
||
) |
Load a tree from a (bifurcating or multifurcating) tree (with/without branch lengths) in NEWICK format, which may or may not contain all taxa in the alignment. Model parameters (if not fixed) will be estimated according to the input tree and the alignment.
[in] | tree_filename | Name of a tree file |
[in] | fixed_blengths | TRUE to keep the input branch lengths unchanged (optional) |
std::invalid_argument | if the tree is empty or in an incorrect format |
ios::failure | if the tree file is not found |
std::logic_error | if any of the following situations occur.
|
std::bad_alloc | if failing to allocate memory to store the tree |
void cmaple::Tree::changeAln | ( | Alignment * | aln | ) |
Change the alignment.
[in] | aln | An alignment |
std::invalid_argument | If the alignment is empty |
std::logic_error | if any of the following situations occur.
|
void cmaple::Tree::changeModel | ( | Model * | model | ) |
Change the substitution model.
[in] | model | A substitution model |
std::invalid_argument | if the model is unknown/unsupported |
std::logic_error | if any of the following situations occur.
|
void cmaple::Tree::doPlacement | ( | std::ostream & | out_stream = std::cout | ) |
Do placement (using stepwise addition) to build an initial tree. Model parameters (if not fixed) will be estimated during the placement process.
[out] | out_stream | The output message stream (optional) |
std::logic_error | if any of the following situations occur.
|
void cmaple::Tree::applySPR | ( | const TreeSearchType | tree_search_type, |
const bool | shallow_tree_search, | ||
std::ostream & | out_stream = std::cout |
||
) |
Apply SPR moves to optimize the tree.
[in] | tree_search_type | A type of tree search |
[in] | shallow_tree_search | TRUE to enable a shallow tree search before a deeper tree search |
[out] | out_stream | The output message stream (optional) |
std::logic_error | if any of the following situations occur.
|
void cmaple::Tree::optimizeBranch | ( | std::ostream & | out_stream = std::cout | ) |
Optimize the branch lengths of the tree.
[out] | out_stream | The output message stream (optional) |
std::logic_error | if any of the following situations occur.
|
void cmaple::Tree::infer | ( | const TreeSearchType | tree_search_type = NORMAL_TREE_SEARCH , |
const bool | shallow_tree_search = false , |
||
std::ostream & | out_stream = std::cout |
||
) |
Infer a maximum likelihood tree by executing doPlacement(), applySPR(), and optimizeBranch()
[in] | tree_search_type | A type of tree search (optional) |
[in] | shallow_tree_search | TRUE to enable a shallow tree search before a deeper tree search (optional) |
[out] | out_stream | The output message stream (optional) |
std::invalid_argument | if tree_search_type is unknown |
std::logic_error | if any of the following situations occur.
|
RealNumType cmaple::Tree::computeLh | ( | ) |
Compute the log likelihood of the current tree, which may or may not contain all taxa in the alignment.
std::logic_error | if any of the following situations occur.
|
void cmaple::Tree::computeBranchSupport | ( | const int | num_threads = 1 , |
const int | num_replicates = 1000 , |
||
const double | epsilon = 0.1 , |
||
const bool | allow_replacing_ML_tree = true , |
||
std::ostream & | out_stream = std::cout |
||
) |
Compute branch supports (aLRT-SH) of the current tree, which may or may not contain all taxa in the alignment.
[in] | num_threads | The number of threads (optional) |
[in] | num_replicates | A positive number of replicates (optional) |
[in] | epsilon | A positive epsilon (optional), which is used to avoid rounding effects, when the best and second best NNI trees have nearly identical site log-likelihood values (see Guindon et al., 2010) |
[in] | allow_replacing_ML_tree | TRUE to allow replacing the ML tree by a higher likelihood tree found when computing branch supports (optional) |
[out] | out_stream | The output message stream (optional) |
std::invalid_argument | if any of the following situations occur.
|
std::logic_error | if any of the following situations occur.
|
std::string cmaple::Tree::exportNewick | ( | const TreeType | tree_type = BIN_TREE , |
const bool | show_branch_supports = true |
||
) |
Export the phylogenetic tree to a string in NEWICK format.
[in] | tree_type | The type of the output tree (optional): BIN_TREE (bifurcating tree), MUL_TREE (multifurcating tree) |
[in] | show_branch_supports | TRUE to output the branch supports (aLRT-SH values) |
std::invalid_argument | if any of the following situations occur.
|