Clustal Omega  1.1.0
src/clustal/muscle_tree.h
Go to the documentation of this file.
00001 /* This a mix of tree functions and data-structures from
00002  * Bob Edgar's Muscle (version 3.7) ported to pure C.
00003  *
00004  * Used files: phy.cpp, tree.h, phytofile.cpp and phyfromclust.cpp
00005  *
00006  * Muscle's code is public domain and so is this code here.
00007 
00008  * From http://www.drive5.com/muscle/license.htm:
00009  * """
00010  * MUSCLE is public domain software
00011  *
00012  * The MUSCLE software, including object and source code and
00013  * documentation, is hereby donated to the public domain.
00014  *
00015  * Disclaimer of warranty
00016  * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00017  * EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION IMPLIED
00018  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019  * """
00020  *
00021  */
00022 
00023 /*
00024  *  RCS $Id: muscle_tree.h 230 2011-04-09 15:37:50Z andreas $
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 /* limit use of uint (see coding_style_guideline.txt) */
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     /* do we have edge lengths info stored (m_dEdgeLength[123]) */
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     /* unused in our version of the code. we might need it at some
00078      * stage so keep it in here, but disable via USE_HEIGHT throughout
00079      * the code */
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