#include <stdio.h>
#include "util.h"
Go to the source code of this file.
Data Structures | |
struct | tree_t |
guide-tree structure More... | |
Typedefs | |
typedef unsigned int | uint |
Functions | |
void | MuscleTreeCreate (tree_t *tree, uint uLeafCount, uint uRoot, const uint *Left, const uint *Right, const float *LeftLength, const float *RightLength, const uint *LeafIds, char **LeafNames) |
create a muscle tree | |
void | MuscleTreeToFile (FILE *fp, tree_t *tree) |
write a muscle tree to a file in newick format (distances and all names) | |
int | MuscleTreeFromFile (tree_t *tree, char *ftree) |
void | FreeMuscleTree (tree_t *tree) |
void | LogTree (tree_t *tree, FILE *fp) |
bool | IsRooted (tree_t *tree) |
check if tree is a rooted tree | |
uint | GetNodeCount (tree_t *tree) |
uint | GetLeafCount (tree_t *tree) |
uint | FirstDepthFirstNode (tree_t *tree) |
returns first leaf node for a depth-first traversal of tree | |
uint | NextDepthFirstNode (uint nodeindex, tree_t *tree) |
returns next leaf node index for depth-first traversal of tree | |
bool | IsLeaf (uint nodeindex, tree_t *tree) |
check if given node is a leaf node | |
void | SetLeafId (tree_t *tree, uint uNodeIndex, uint uId) |
uint | GetLeafId (uint nodeindex, tree_t *tree) |
char * | GetLeafName (unsigned uNodeIndex, tree_t *tree) |
uint | GetLeft (uint nodeindex, tree_t *tree) |
uint | GetRight (uint nodeindex, tree_t *tree) |
uint | GetRootNodeIndex (tree_t *tree) |
bool | IsRoot (uint uNodeIndex, tree_t *tree) |
uint | GetParent (unsigned uNodeIndex, tree_t *tree) |
double | GetEdgeLength (uint uNodeIndex1, uint uNodeIndex2, tree_t *tree) |
uint | LeafIndexToNodeIndex (uint uLeafIndex, tree_t *prTree) |
void | AppendTree (tree_t *prDstTree, uint uDstTreeNodeIndex, tree_t *prSrcTree) |
Append a (source) tree to a (dest) tree to a given node which will be replaced. All other nodes in that tree will stay the same. | |
void | TreeValidate (tree_t *tree) |
typedef unsigned int uint |
Append a (source) tree to a (dest) tree to a given node which will be replaced. All other nodes in that tree will stay the same.
[out] | prDstTree | The tree to append to |
[in] | uDstTreeReplaceNodeIndex | Dest tree node to which source tree will be appended |
[in] | prSrcTree | The tree to append |
The easiest would have been to do this by recursively calling AppendBranch() (after adding uSrcTreeNodeIndex as extra argument to this function). But recursion is evil. Yet another version would be to setup all the data and call MuscleTreeCreate() to create a third tree, which seems complicated and wasteful. The approach taken here is the following: increase dest tree memory, copy over each src tree node data and update the indices and counters. This is tricky and has a lot of potential for bugs if tree interface is changed (and even if it isn't).
returns first leaf node for a depth-first traversal of tree
[in] | tree | tree to traverse |
void FreeMuscleTree | ( | tree_t * | tree | ) |
[in] | uNodeIndex | node to examine |
[in] | tree | tree to examine |
char* GetLeafName | ( | unsigned | uNodeIndex, | |
tree_t * | tree | |||
) |
[in] | uNodeIndex | node to examine |
[in] | tree | tree to examine |
[in] | uNodeIndex | node to examine |
[in] | tree | tree to examine |
check if given node is a leaf node
[in] | uNodeIndex | the node index |
tree | the tree |
bool IsRooted | ( | tree_t * | tree | ) |
check if tree is a rooted tree
[in] | tree | tree to check |
void LogTree | ( | tree_t * | tree, | |
FILE * | fp | |||
) |
Debug output
LogMe in phy.cpp
void MuscleTreeCreate | ( | tree_t * | tree, | |
uint | uLeafCount, | |||
uint | uRoot, | |||
const uint * | Left, | |||
const uint * | Right, | |||
const float * | LeftLength, | |||
const float * | RightLength, | |||
const uint * | LeafIds, | |||
char ** | LeafNames | |||
) |
create a muscle tree
[out] | tree | newly created tree |
[in] | uLeafCount | number of leaf nodes |
[in] | uRoot | Internal node index of root node |
[in] | Left | Node index of left sibling of an internal node. Index range: 0--uLeafCount-1 |
[in] | Right | Node index of right sibling of an internal node. Index range: 0--uLeafCount-1 |
[in] | LeftLength | Branch length of left branch of an internal node. Index range: 0--uLeafCount-1 |
[in] | RightLength | Branch length of right branch of an internal node. Index range: 0--uLeafCount-1 |
[in] | LeafIds | Leaf id. Index range: 0--uLeafCount |
[in] | LeafNames | Leaf label. Index range: 0--uLeafCount |
int MuscleTreeFromFile | ( | tree_t * | tree, | |
char * | ftree | |||
) |
return non-Zero on failure
leafids will not be set here (FIXME:CHECK if true)
void MuscleTreeToFile | ( | FILE * | fp, | |
tree_t * | tree | |||
) |
write a muscle tree to a file in newick format (distances and all names)
[in] | tree | tree to write |
[out] | fp | filepointer to write to2 |
returns next leaf node index for depth-first traversal of tree
[in] | tree | tree to traverse |
[in] | uNodeIndex | Current node index |
void TreeValidate | ( | tree_t * | tree | ) |