inc/phyloTree.h File Reference

#include "linefile.h"

Include dependency graph for phyloTree.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  phyloName
struct  phyloTree

Functions

phyloTreephyloOpenTree (char *fileName)
phyloTreephyloReadTree (struct lineFile *lf)
phyloTreephyloParseString (char *string)
void phyloPrintTree (struct phyloTree *, FILE *f)
void phyloDebugTree (struct phyloTree *, FILE *f)
char * phyloFindPath (struct phyloTree *tree, char *ref, char *cross)
char * phyloNodeNames (struct phyloTree *tree)
phyloTreephyloFindName (struct phyloTree *tree, char *name)
phyloTreephyloReRoot (struct phyloTree *inTree)
void phyloDeleteEdge (struct phyloTree *tree, struct phyloTree *edge)
phyloTreephyloAddEdge (struct phyloTree *parent, struct phyloTree *child)
void phyloClearTreeMarks (struct phyloTree *tree)
phyloTreephyloFindMarkUpTree (struct phyloTree *tree)
void phyloMarkUpTree (struct phyloTree *tree)
void phyloPrintTreeNoDups (struct phyloTree *tree, FILE *f)
int phyloCountLeaves (struct phyloTree *tree)


Function Documentation

struct phyloTree* phyloAddEdge ( struct phyloTree parent,
struct phyloTree child 
) [read]

Definition at line 87 of file phyloTree.c.

References newEdge(), and phyloTree::parent.

00089 {
00090 return newEdge(parent, child);
00091 }

Here is the call graph for this function:

void phyloClearTreeMarks ( struct phyloTree tree  ) 

Definition at line 253 of file phyloTree.c.

References phyloTree::edges, phyloTree::mark, phyloTree::numEdges, and phyloClearTreeMarks().

Referenced by phyloClearTreeMarks(), and phyloFindPath().

00255 {
00256 int ii;
00257 
00258 tree->mark = 0;
00259 
00260 for (ii=0; ii < tree->numEdges; ii++)
00261     phyloClearTreeMarks(tree->edges[ii]);
00262 }

Here is the call graph for this function:

Here is the caller graph for this function:

int phyloCountLeaves ( struct phyloTree tree  ) 

Definition at line 394 of file phyloTree.c.

References phyloTree::edges, phyloTree::numEdges, and phyloCountLeaves().

Referenced by phyloCountLeaves().

00395 {
00396 int ii, count = 0;
00397 
00398 if (tree->numEdges == 0)
00399     return 1;
00400 
00401 for (ii=0; ii < tree->numEdges; ii++)
00402     count += phyloCountLeaves(tree->edges[ii]);
00403 
00404 return count;
00405 }

Here is the call graph for this function:

Here is the caller graph for this function:

void phyloDebugTree ( struct phyloTree ,
FILE *  f 
)

Definition at line 218 of file phyloTree.c.

References phyloTree::edges, phyloTree::ident, phyloName::length, phyloName::name, phyloTree::numEdges, phyloDebugTree(), recurseCount, and tabOut().

Referenced by phyloDebugTree().

00220 {
00221 if (tree)
00222     {
00223     int ii;
00224     fprintf(f,"%s:%g numEdges %d\n",tree->ident->name, tree->ident->length, tree->numEdges);
00225     recurseCount++;
00226     for (ii= 0; ii < tree->numEdges; ii++)
00227         {
00228         tabOut(f);
00229         phyloDebugTree(tree->edges[ii], f);
00230         }
00231     recurseCount--;
00232     }
00233 }

Here is the call graph for this function:

Here is the caller graph for this function:

void phyloDeleteEdge ( struct phyloTree tree,
struct phyloTree edge 
)

Definition at line 377 of file phyloTree.c.

References phyloTree::edges, and phyloTree::numEdges.

Referenced by reParent().

00379 {
00380 int ii;
00381 
00382 for (ii=0; ii < tree->numEdges; ii++)
00383     if (tree->edges[ii] == edge)
00384         {
00385         memcpy(&tree->edges[ii], &tree->edges[ii+1], sizeof(tree) * (tree->numEdges - ii - 1));
00386         tree->numEdges--;
00387         //phyloFreeTree(edge);
00388         return;
00389         }
00390 
00391 errAbort("tried to delete non-existant edge");
00392 }

Here is the caller graph for this function:

struct phyloTree* phyloFindMarkUpTree ( struct phyloTree tree  )  [read]

Definition at line 264 of file phyloTree.c.

References phyloTree::mark, and phyloTree::parent.

Referenced by phyloFindPath().

00266 {
00267 do
00268     {
00269     if (tree->mark)
00270         return tree;
00271     tree = tree->parent;
00272     } while (tree);
00273 
00274 return NULL;
00275 }

Here is the caller graph for this function:

struct phyloTree* phyloFindName ( struct phyloTree tree,
char *  name 
) [read]

Definition at line 235 of file phyloTree.c.

References phyloTree::edges, phyloTree::ident, phyloName::name, phyloTree::numEdges, phyloFindName(), and sameString.

Referenced by phyloFindName(), and phyloFindPath().

00237 {
00238 struct phyloTree *subTree = NULL;
00239 int ii;
00240 
00241 if (tree->ident->name && sameString(tree->ident->name, name))
00242     return tree;
00243 
00244 for (ii=0; ii < tree->numEdges; ii++)
00245     {
00246     if ((subTree = phyloFindName( tree->edges[ii], name)) != NULL)
00247         break;
00248     }
00249 
00250 return subTree;
00251 }

Here is the call graph for this function:

Here is the caller graph for this function:

char* phyloFindPath ( struct phyloTree tree,
char *  ref,
char *  cross 
)

Definition at line 285 of file phyloTree.c.

References ds, dyStringAppendC(), dyStringAppendN(), phyloTree::ident, phyloTree::mark, phyloName::name, newDyString(), phyloTree::parent, phyloClearTreeMarks(), phyloFindMarkUpTree(), phyloFindName(), and phyloMarkUpTree().

00288 {
00289 struct phyloTree *treeRef, *treeCross, *parent;
00290 struct dyString *ds = newDyString(0);
00291 
00292 if ((treeRef = phyloFindName(tree,ref)) == NULL)
00293     return NULL;
00294 
00295 if ((treeCross = phyloFindName(tree,cross)) == NULL)
00296     return NULL;
00297 
00298 phyloClearTreeMarks(tree);
00299 phyloMarkUpTree(treeCross);
00300 if ((parent = phyloFindMarkUpTree(treeRef)) == NULL)
00301     return NULL;
00302 
00303 /* walk up the tree till we hit the common parent */
00304 while(treeRef != parent)
00305     {
00306     treeRef = treeRef->parent;
00307     if (ds->stringSize)
00308         dyStringAppendC(ds, ' ');
00309     if (treeRef->ident->name)
00310         dyStringAppendN(ds, treeRef->ident->name, strlen(treeRef->ident->name));
00311     }
00312 
00313 /* now walk down the tree till we come to the target species */
00314 while (parent != treeCross)
00315     {
00316     parent = parent->mark;
00317     dyStringAppendC(ds, ' ');
00318     if (parent->ident->name)
00319         dyStringAppendN(ds, parent->ident->name, strlen(parent->ident->name));
00320     }
00321 
00322 return ds->string;
00323 }

Here is the call graph for this function:

void phyloMarkUpTree ( struct phyloTree tree  ) 

Definition at line 277 of file phyloTree.c.

References phyloTree::mark, and phyloTree::parent.

Referenced by phyloFindPath().

00279 {
00280     tree->mark = tree;
00281     for(;tree->parent; tree = tree->parent)
00282         tree->parent->mark = tree;
00283 }

Here is the caller graph for this function:

char* phyloNodeNames ( struct phyloTree tree  ) 

Definition at line 341 of file phyloTree.c.

References ds, newDyString(), and nodeNames().

00343 {
00344 struct dyString *ds = newDyString(0);
00345 
00346 nodeNames(tree, ds);
00347 
00348 ds->string[ds->stringSize-1]=0;
00349 
00350 return ds->string;
00351 }

Here is the call graph for this function:

struct phyloTree* phyloOpenTree ( char *  fileName  )  [read]

Definition at line 19 of file phyloTree.c.

References lineFileClose(), lineFileOpen(), phyloReadTree(), and TRUE.

00020 {
00021 struct lineFile *lf = lineFileOpen(fileName, TRUE);
00022 struct phyloTree *tree = phyloReadTree(lf);
00023 
00024 lineFileClose(&lf);
00025 
00026 return tree;
00027 }

Here is the call graph for this function:

struct phyloTree* phyloParseString ( char *  string  )  [read]

Definition at line 145 of file phyloTree.c.

References eraseWhiteSpace(), errAbort(), and parseSubTree().

Referenced by phyloReadTree().

00147 {
00148 struct phyloTree *tree = NULL;
00149 char *ptr = string;
00150 
00151 eraseWhiteSpace(string);
00152 
00153 tree = parseSubTree(&ptr);
00154 
00155 if (*ptr != ';')
00156     errAbort("trees must terminated by ';'");
00157 
00158 return tree;
00159 }

Here is the call graph for this function:

Here is the caller graph for this function:

void phyloPrintTree ( struct phyloTree ,
FILE *  f 
)

Definition at line 211 of file phyloTree.c.

References FALSE, and pTree().

00213 {
00214 pTree(tree, f, FALSE);
00215 fprintf(f, ";\n");
00216 }

Here is the call graph for this function:

void phyloPrintTreeNoDups ( struct phyloTree tree,
FILE *  f 
)

Definition at line 204 of file phyloTree.c.

References pTree(), and TRUE.

00206 {
00207 pTree(tree, f, TRUE);
00208 fprintf(f, ";\n");
00209 }

Here is the call graph for this function:

struct phyloTree* phyloReadTree ( struct lineFile lf  )  [read]

Definition at line 6 of file phyloTree.c.

References lineFileNext(), and phyloParseString().

Referenced by phyloOpenTree().

00008 {
00009 struct phyloTree *tree = NULL;
00010 char *ptr;
00011 int len;
00012 
00013 if (lineFileNext(lf, &ptr, &len) && (len > 0))
00014     tree = phyloParseString(ptr);
00015 
00016 return tree;
00017 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct phyloTree* phyloReRoot ( struct phyloTree inTree  )  [read]

Definition at line 368 of file phyloTree.c.

References phyloTree::ident, phyloName::length, and reParent().

00370 {
00371 reParent(tree);
00372 tree->ident->length = 0;
00373 
00374 return tree;
00375 }

Here is the call graph for this function:


Generated on Tue Dec 25 19:09:59 2007 for blat by  doxygen 1.5.2