Clustal Omega
1.0.3
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include <ctype.h>
#include "util.h"
#include "log.h"
#include "muscle_tree.h"
Enumerations | |
enum | NEWICK_TOKEN_TYPE { NTT_Unknown, NTT_Lparen, NTT_Rparen, NTT_Colon, NTT_Comma, NTT_Semicolon, NTT_String, NTT_SingleQuotedString, NTT_DoubleQuotedString, NTT_Comment } |
Functions | |
uint | AppendBranch (tree_t *tree, uint uExistingLeafIndex) |
uint | GetNeighbor (uint uNodeIndex, uint uNeighborSubscript, tree_t *tree) |
uint | GetLeft (uint uNodeIndex, tree_t *tree) |
uint | GetRight (uint uNodeIndex, tree_t *tree) |
uint | GetLeafId (uint uNodeIndex, tree_t *tree) |
char * | GetLeafName (unsigned uNodeIndex, tree_t *tree) |
uint | FirstDepthFirstNode (tree_t *tree) |
returns first leaf node for a depth-first traversal of tree | |
uint | NextDepthFirstNode (uint uNodeIndex, tree_t *tree) |
returns next leaf node index for depth-first traversal of tree | |
bool | IsRooted (tree_t *tree) |
check if tree is a rooted tree | |
void | FreeMuscleTree (tree_t *tree) |
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) | |
bool | IsLeaf (uint uNodeIndex, tree_t *tree) |
check if given node is a leaf node | |
bool | IsRoot (uint uNodeIndex, tree_t *tree) |
uint | GetNeighborCount (uint uNodeIndex, tree_t *tree) |
uint | GetParent (unsigned uNodeIndex, tree_t *tree) |
double | GetEdgeLength (uint uNodeIndex1, uint uNodeIndex2, tree_t *tree) |
void | TreeValidate (tree_t *tree) |
int | MuscleTreeFromFile (tree_t *tree, char *ftree) |
void | SetLeafName (unsigned uNodeIndex, const char *ptrName, tree_t *tree) |
void | LogTree (tree_t *tree, FILE *fp) |
uint | GetLeafCount (tree_t *tree) |
uint | GetNodeCount (tree_t *tree) |
void | SetLeafId (tree_t *tree, uint uNodeIndex, uint uId) |
uint | GetRootNodeIndex (tree_t *tree) |
uint | LeafIndexToNodeIndex (uint uLeafIndex, tree_t *prTree) |
void | AppendTree (tree_t *prDstTree, uint uDstTreeReplaceNodeIndex, 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. |
enum NEWICK_TOKEN_TYPE |
uint AppendBranch | ( | tree_t * | tree, |
uint | uExistingLeafIndex | ||
) |
Append a new branch. This adds two new nodes and joins them to an existing leaf node. Return value is k, new nodes have indexes k and k+1 respectively.
void AppendTree | ( | tree_t * | prDstTree, |
uint | uDstTreeReplaceNodeIndex, | ||
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.
[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).
uint FirstDepthFirstNode | ( | tree_t * | tree | ) |
returns first leaf node for a depth-first traversal of tree
[in] | tree | tree to traverse |
void FreeMuscleTree | ( | tree_t * | tree | ) |
double GetEdgeLength | ( | uint | uNodeIndex1, |
uint | uNodeIndex2, | ||
tree_t * | tree | ||
) |
uint GetLeafCount | ( | tree_t * | tree | ) |
replaces m_uLeafCount
[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 |
uint GetNeighbor | ( | uint | uNodeIndex, |
uint | uNeighborSubscript, | ||
tree_t * | tree | ||
) |
uint GetNeighborCount | ( | uint | uNodeIndex, |
tree_t * | tree | ||
) |
uint GetNodeCount | ( | tree_t * | tree | ) |
[in] | uNodeIndex | node to examine |
[in] | tree | tree to examine |
uint GetRootNodeIndex | ( | tree_t * | tree | ) |
check if given node is a leaf node
[in] | uNodeIndex | the node index |
tree | the tree |
check if tree is a rooted tree
[in] | tree | tree to check |
uint LeafIndexToNodeIndex | ( | uint | uLeafIndex, |
tree_t * | prTree | ||
) |
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 |
uint NextDepthFirstNode | ( | uint | uNodeIndex, |
tree_t * | tree | ||
) |
returns next leaf node index for depth-first traversal of tree
[in] | tree | tree to traverse |
[in] | uNodeIndex | Current node index |
void SetLeafName | ( | unsigned | uNodeIndex, |
const char * | ptrName, | ||
tree_t * | tree | ||
) |
void TreeValidate | ( | tree_t * | tree | ) |