CAFE
Computational Analysis of gene Family Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tree.h
Go to the documentation of this file.
1 #ifndef __TREE_H__
2 #define __TREE_H__
3 
4 #include<utils.h>
5 #include<stdarg.h>
6 #include<utils_string.h>
7 
8 typedef struct tagTree* pTree;
9 typedef struct tagTreeNode* pTreeNode;
10 
11 typedef struct tagTree
12 {
13  pTreeNode root;
14  void* data;
15  int size;
16  int* count;
19 }Tree;
20 
26 typedef struct tagTreeNode
27 {
28  pTreeNode parent;
30  int reg;
31  int id;
32 }TreeNode;
33 
34 /****************************************************************************
35  * Tree
36 ****************************************************************************/
37 
38 typedef pTreeNode (*tree_func_node_new)(pTree ptree);
39 typedef pTree (*tree_func_new)(tree_func_node_new nfunc, int size);
40 typedef void (*tree_func_node)(pTree ptree, pTreeNode pnode, va_list ap);
41 typedef void (*tree_func_node_copy)(pTreeNode psrc, pTreeNode pdest );
42 
43 extern pTree tree_new(tree_func_node_new nfunc, int size);
44 extern void tree_new_fill(pTree ptree, tree_func_node_new nfunc ) ;
45 extern void tree_free(pTree ptree);
46 extern pTreeNode tree_new_empty_node();
47 extern int tree_is_leaf(pTreeNode pnode);
48 extern int tree_is_root(pTree ptree, pTreeNode pnode);
49 extern void tree_add_child_to_node(pTreeNode parent, pTreeNode child);
50 extern void tree_traveral_prefix(pTree ptree, tree_func_node func, ...);
51 extern void tree_traveral_postfix(pTree ptree, tree_func_node func, ...);
52 extern void tree_traveral_infix(pTree ptree, tree_func_node func, ... );
53 extern void tree_clear_reg(pTree ptree);
54 extern void* tree_get_child(pTreeNode ptnode, int idx);
55 extern pTree tree_copy(pTree psrc, tree_func_node_new new_node_func, tree_func_node_copy copy);
56 extern void tree_build_node_list(pTree ptree);
57 
58 typedef enum
59 {
64 
66 typedef struct tagPhylogenyNode
67 {
69  char* name;
70  double branchlength;
71  char* species;
72  char* gene;
74  int bootstrap;
75  int taxaid;
77 
78 /****************************************************************************
79  * Phylogeny
80 ****************************************************************************/
81 
82 typedef void (*phylogeny_func_parse_node)(pTree ptree, pTreeNode pnode);
83 typedef void (*phylogeny_func_name_modify)(pString str, pPhylogenyNode pnode);
84 
85 extern pTree phylogeny_split_tree(pTree ptree, int idx, tree_func_node freenode );
86 extern pString phylogeny_string(pTree ptree, phylogeny_func_name_modify fmod);
87 extern void phylogeny_node_copy(pTreeNode psrc, pTreeNode pdest );
88 extern pTree phylogeny_load_from_string(char* sztree,
89  tree_func_new new_tree_func,
90  tree_func_node_new new_tree_node_func,
91  phylogeny_func_parse_node parsefunc, int size);
92 extern pTree phylogeny_root_tree(pTree ptree,
93  tree_func_node_new new_tree_node_func,
94  phylogeny_func_parse_node parsefunc, ... );
95 extern pTree phylogeny_load_from_file(char* sztree,
96  tree_func_new new_tree_func,
97  tree_func_node_new new_tree_node_func,
98  phylogeny_func_parse_node parsefunc );
99 extern void phylogeny_free(pTree ptree);
100 
101 extern pTreeNode phylogeny_new_empty_node(pTree ptree);
102 extern void phylogeny_clear_node(pPhylogenyNode pnode);
103 extern pTree phylogeny_copy(pTree psrc);
104 extern pTree phylogeny_new(char* sztree, phylogeny_func_parse_node parsefunc );
105 extern int phylogeny_delete_nodes_by_index(pTree ptree, int idx, tree_func_node freenode );
106 extern int phylogeny_delete_nodes_by_reg(pTree ptree, tree_func_node freenode );
107 extern int phylogeny_delete_nodes_by_func(pTree ptree, tree_func_node filter ,tree_func_node freenode );
108 extern pTreeNode phylogeny_get_sibling(pTree ptree, pTreeNode ptnode );
109 
110 extern pString phylogeny_string_nhx(pTree ptree, phylogeny_func_name_modify fmod, int opts);
111 extern pString phylogeny_string_newick(pTree ptree, phylogeny_func_name_modify fmod, int opts);
112 
113 
114 #define PS_SKIP_BL 0x1000
115 #define PS_NWICK 0x0000
116 #define PS_NHX 0x0FFE
117 
118 /****************************************************************************
119  * MetaPhost Config
120 ****************************************************************************/
121 typedef enum
122 {
127 
128 typedef enum
129 {
133 
134 typedef enum
135 {
142 
144 typedef double (*metapost_remark)(pString str, pTree ptree, pMetapostConfig pmc, va_list ap);
145 typedef double (*metapost_annotation_func)(pString str, pTreeNode pnode, pMetapostConfig pmc, va_list ap);
146 
147 typedef struct tagMetapostConfig
148 {
149  int id;
150  int unit;
151  int dir;
152  int shape;
155  double width, height;
157 
158 
159 pString phylogeny_to_mp(pTree ptree, pMetapostConfig pmc, ... );
160 
161 #define TREE_DEBUG 1
162 
163 #endif
Definition: utils.h:49
void * tree_get_child(pTreeNode ptnode, int idx)
Definition: tree.c:80
int phylogeny_delete_nodes_by_index(pTree ptree, int idx, tree_func_node freenode)
Definition: phylogeny.c:650
pTree tree_copy(pTree psrc, tree_func_node_new new_node_func, tree_func_node_copy copy)
Definition: tree.c:231
void tree_add_child_to_node(pTreeNode parent, pTreeNode child)
Definition: tree.c:69
pTreeNode tree_new_empty_node()
Definition: tree.h:136
void(* tree_func_node)(pTree ptree, pTreeNode pnode, va_list ap)
Definition: tree.h:40
pTree phylogeny_split_tree(pTree ptree, int idx, tree_func_node freenode)
Definition: phylogeny.c:571
double height
Definition: tree.h:155
Definition: tree.h:137
pTreeNode root
Definition: tree.h:13
int taxaid
Definition: tree.h:75
void tree_traveral_infix(pTree ptree, tree_func_node func,...)
Definition: cafe_commands.cpp:1910
Definition: utils_string.h:9
pString phylogeny_string_newick(pTree ptree, phylogeny_func_name_modify fmod, int opts)
Definition: phylogeny.c:465
pTree phylogeny_new(char *sztree, phylogeny_func_parse_node parsefunc)
Definition: phylogeny.c:548
pTreeNode phylogeny_get_sibling(pTree ptree, pTreeNode ptnode)
Definition: phylogeny.c:558
pString phylogeny_string_nhx(pTree ptree, phylogeny_func_name_modify fmod, int opts)
Definition: phylogeny.c:477
struct tagPhylogenyNode * pPhylogenyNode
Definition: tree.h:65
void tree_traveral_postfix(pTree ptree, tree_func_node func,...)
Definition: tree.c:126
pArrayList nlist
Definition: tree.h:17
pTree tree_new(tree_func_node_new nfunc, int size)
Definition: tree.c:18
Definition: tree.h:130
int shape
Definition: tree.h:152
pArrayList postfix
Definition: tree.h:18
int bootstrap
Definition: tree.h:74
pArrayList prefix
Definition: tree.h:18
void(* phylogeny_func_name_modify)(pString str, pPhylogenyNode pnode)
Definition: tree.h:83
int id
Definition: tree.h:149
enumPhylogeny_speciation
Definition: tree.h:58
tagMPUnitList
Definition: tree.h:121
TreeNode super
Definition: tree.h:68
int tree_is_root(pTree ptree, pTreeNode pnode)
Definition: tree.c:64
double(* metapost_remark)(pString str, pTree ptree, pMetapostConfig pmc, va_list ap)
Definition: tree.h:144
Definition: tree.h:139
Definition: tree.h:131
double(* metapost_annotation_func)(pString str, pTreeNode pnode, pMetapostConfig pmc, va_list ap)
Definition: tree.h:145
void(* tree_func_node_copy)(pTreeNode psrc, pTreeNode pdest)
Definition: tree.h:41
struct tagMetapostConfig * pMetapostConfig
Definition: tree.h:143
struct tagPhylogenyNode PhylogenyNode
void phylogeny_clear_node(pPhylogenyNode pnode)
Definition: phylogeny.c:19
char * gene
Definition: tree.h:72
void * data
Definition: tree.h:14
int dir
Definition: tree.h:151
Definition: tree.h:62
pString phylogeny_to_mp(pTree ptree, pMetapostConfig pmc,...)
Definition: phylogeny.c:752
Definition: tree.h:125
void tree_traveral_prefix(pTree ptree, tree_func_node func,...)
Definition: tree.c:101
Definition: tree.h:147
pTreeNode(* tree_func_node_new)(pTree ptree)
Definition: tree.h:38
void phylogeny_free(pTree ptree)
Definition: phylogeny.c:143
Definition: tree.h:123
metapost_annotation_func fmod
Definition: tree.h:154
pTree phylogeny_load_from_file(char *sztree, tree_func_new new_tree_func, tree_func_node_new new_tree_node_func, phylogeny_func_parse_node parsefunc)
int * count
Definition: tree.h:16
struct tagTreeNode TreeNode
pTree phylogeny_root_tree(pTree ptree, tree_func_node_new new_tree_node_func, phylogeny_func_parse_node parsefunc,...)
Definition: phylogeny.c:386
Definition: tree.h:138
Definition: tree.h:140
tagMPShapeList
Definition: tree.h:134
struct tagTree * pTree
Definition: tree.h:8
void tree_free(pTree ptree)
Definition: tree.c:29
pTree phylogeny_copy(pTree psrc)
Definition: phylogeny.c:553
int reg
Definition: tree.h:30
void(* phylogeny_func_parse_node)(pTree ptree, pTreeNode pnode)
Definition: tree.h:82
Definition: utils.h:12
pString phylogeny_string(pTree ptree, phylogeny_func_name_modify fmod)
Definition: phylogeny.c:490
struct tagMetapostConfig MetapostConfig
void phylogeny_node_copy(pTreeNode psrc, pTreeNode pdest)
Definition: phylogeny.c:35
metapost_remark fremark
Definition: tree.h:153
void tree_build_node_list(pTree ptree)
Definition: cafe_commands.cpp:1955
Definition: tree.h:11
Definition: tree.h:26
void tree_clear_reg(pTree ptree)
Definition: tree.c:191
struct tagTree Tree
struct tagTreeNode * pTreeNode
Definition: tree.h:9
void tree_new_fill(pTree ptree, tree_func_node_new nfunc)
Definition: tree.c:7
double branchlength
Definition: tree.h:70
pTree phylogeny_load_from_string(char *sztree, tree_func_new new_tree_func, tree_func_node_new new_tree_node_func, phylogeny_func_parse_node parsefunc, int size)
Definition: phylogeny.c:319
int phylogeny_delete_nodes_by_reg(pTree ptree, tree_func_node freenode)
Definition: phylogeny.c:664
pTreeNode phylogeny_new_empty_node(pTree ptree)
Definition: phylogeny.c:28
int unit
Definition: tree.h:150
double width
Definition: tree.h:155
int id
Definition: tree.h:31
pTreeNode parent
Definition: tree.h:28
pTree(* tree_func_new)(tree_func_node_new nfunc, int size)
Definition: tree.h:39
int tree_is_leaf(pTreeNode pnode)
Definition: tree.c:59
char * name
Definition: tree.h:69
Definition: tree.h:61
int duplicated
Definition: tree.h:73
tagMPDirectionList
Definition: tree.h:128
int size
Definition: tree.h:15
Definition: tree.h:66
int phylogeny_delete_nodes_by_func(pTree ptree, tree_func_node filter, tree_func_node freenode)
Definition: phylogeny.c:720
Definition: tree.h:124
char * species
Definition: tree.h:71
pVector children
Definition: tree.h:29