00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CLUSTALO_MUSCLE_CLUSTALO_TREE_H
00029 #define CLUSTALO_MUSCLE_CLUSTALO_TREE_H
00030
00031 #include <stdio.h>
00032 #include "util.h"
00033
00034 #ifndef uint
00035
00036 typedef unsigned int uint;
00037 #endif
00038
00039 static const uint NULL_NEIGHBOR = UINT_MAX;
00040
00059 typedef struct {
00060 uint m_uNodeCount;
00061 uint m_uCacheCount;
00063 uint *m_uNeighbor1;
00064 uint *m_uNeighbor2;
00065 uint *m_uNeighbor3;
00067
00068 bool *m_bHasEdgeLength1;
00069 bool *m_bHasEdgeLength2;
00070 bool *m_bHasEdgeLength3;
00071
00072 double *m_dEdgeLength1;
00073 double *m_dEdgeLength2;
00074 double *m_dEdgeLength3;
00075
00076 #if USE_HEIGHT
00077
00078
00079
00080 double *m_dHeight;
00081 bool *m_bHasHeight;
00082 #endif
00083
00088 char **m_ptrName;
00089
00094 uint *m_Ids;
00095
00096 bool m_bRooted;
00097 uint m_uRootNodeIndex;
00098 } tree_t;
00099
00100
00101 extern void
00102 MuscleTreeCreate(tree_t *tree, uint uLeafCount, uint uRoot, const uint *Left,
00103 const uint *Right, const float *LeftLength, const float* RightLength,
00104 const uint *LeafIds, char **LeafNames);
00105
00106 extern void
00107 MuscleTreeToFile(FILE *fp, tree_t *tree);
00108
00109 extern int
00110 MuscleTreeFromFile(tree_t *tree, char *ftree);
00111
00112 extern void
00113 FreeMuscleTree(tree_t *tree);
00114
00115 extern void
00116 LogTree(tree_t *tree, FILE *fp);
00117
00118 extern bool
00119 IsRooted(tree_t *tree);
00120
00121 extern uint
00122 GetNodeCount(tree_t *tree);
00123
00124 extern uint
00125 GetLeafCount(tree_t *tree);
00126
00127 extern uint
00128 FirstDepthFirstNode(tree_t *tree);
00129
00130 extern uint
00131 NextDepthFirstNode(uint nodeindex, tree_t *tree);
00132
00133 extern bool
00134 IsLeaf(uint nodeindex, tree_t *tree);
00135
00136 extern void
00137 SetLeafId(tree_t *tree, uint uNodeIndex, uint uId);
00138
00139 extern uint
00140 GetLeafId(uint nodeindex, tree_t *tree);
00141
00142 extern char *
00143 GetLeafName(unsigned uNodeIndex, tree_t *tree);
00144
00145 extern uint
00146 GetLeft(uint nodeindex, tree_t *tree);
00147
00148 extern uint
00149 GetRight(uint nodeindex, tree_t *tree);
00150
00151 extern uint
00152 GetRootNodeIndex(tree_t *tree);
00153
00154 extern bool
00155 IsRoot(uint uNodeIndex, tree_t *tree);
00156
00157 extern uint
00158 GetParent(unsigned uNodeIndex, tree_t *tree);
00159
00160 extern double
00161 GetEdgeLength(uint uNodeIndex1, uint uNodeIndex2, tree_t *tree);
00162
00163 extern uint
00164 LeafIndexToNodeIndex(uint uLeafIndex, tree_t *prTree);
00165
00166 extern void
00167 AppendTree(tree_t *prDstTree,
00168 uint uDstTreeNodeIndex, tree_t *prSrcTree);
00169
00170 extern void
00171 TreeValidate(tree_t *tree);
00172
00173 #endif