Commit da40b5aa authored by mvalle's avatar mvalle
Browse files

Moved to main the check for null branch lengths from file.


git-svn-id: https://svn.vital-it.ch/svn/hp2c/trunk/Codeml_Variants/Fastcodeml@5601 95c5a404-1f88-0410-a6b0-c3f062b6f34a
parent 8d4fe618
......@@ -153,7 +153,7 @@ unsigned int PhyloTree::collectGlobalTreeData(std::vector<std::string>& aNodeNam
}
void PhyloTree::checkNullBranchLengths(const TreeNode* aTreeNode) const
void PhyloTree::countNullBranchLengths(int& aOnLeafCnt, int& aOnIntCnt, const TreeNode* aTreeNode) const
{
// Start with the tree root (don't check its branch length that is invalid)
if(aTreeNode == NULL)
......@@ -163,11 +163,10 @@ void PhyloTree::checkNullBranchLengths(const TreeNode* aTreeNode) const
else
{
// Check branch length. It should not be null for leaves
if(aTreeNode->isLeaf() && aTreeNode->getLen() < 1e-14)
if(aTreeNode->getLen() < 1e-14)
{
std::ostringstream o;
o << "Null or missing branch length in tree file for leaf: " << aTreeNode->getLabel() << std::endl;
throw FastCodeMLFatal(o);
if(aTreeNode->isLeaf()) ++aOnLeafCnt;
else ++aOnIntCnt;
}
}
......@@ -175,6 +174,6 @@ void PhyloTree::checkNullBranchLengths(const TreeNode* aTreeNode) const
TreeNode *m;
for(unsigned int idx=0; (m = aTreeNode->getChild(idx)) != NULL; ++idx)
{
checkNullBranchLengths(m);
countNullBranchLengths(aOnLeafCnt, aOnIntCnt, m);
}
}
......@@ -102,11 +102,11 @@ public:
/// Check if any leaf has an associated branch length equal to zero.
///
/// @param[in,out] aOnLeafCnt The count of leaf branches with length zero (should be zeroed before first call)
/// @param[in,out] aOnIntCnt The count of internal branches with length zero (should be zeroed before first call)
/// @param[in] aTreeNode The node from which to start checking the tree. If not present starts from the root.
///
/// @exception FastCodeMLFatal If any leaf has null branch length associated
///
void checkNullBranchLengths(const TreeNode* aTreeNode=NULL) const;
void countNullBranchLengths(int& aOnLeafCnt, int& aOnIntCnt, const TreeNode* aTreeNode=NULL) const;
protected:
......
......@@ -188,7 +188,22 @@ int main(int aRgc, char **aRgv)
msa.checkNameCoherence(tree.getSpecies());
// If times from file then check for null branch lengths for any leaf
if(cmd.mBranchLengthsFromFile) tree.checkNullBranchLengths();
if(cmd.mBranchLengthsFromFile)
{
int zero_on_leaf_cnt = 0;
int zero_on_int_cnt = 0;
tree.countNullBranchLengths(zero_on_leaf_cnt, zero_on_int_cnt);
if(zero_on_leaf_cnt > 0 || zero_on_int_cnt > 0)
{
std::cout << "Found Null or missing branch length in tree file. On leaves: " << zero_on_leaf_cnt << " on internal branches: " << zero_on_int_cnt << std::endl;
}
if(zero_on_leaf_cnt > 0)
{
throw FastCodeMLFatal("Null or missing branch length in tree file");
}
}
// Print the tree with the numbering of internal branches
if(cmd.mVerboseLevel >= VERBOSE_INFO_OUTPUT) tree.printTreeAnnotated(std::cout);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment