-
Notifications
You must be signed in to change notification settings - Fork 3
/
mtreeset.h
171 lines (142 loc) · 5.77 KB
/
mtreeset.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/***************************************************************************
* Copyright (C) 2006 by BUI Quang Minh, Steffen Klaere, Arndt von Haeseler *
* minh.bui@univie.ac.at *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef MTREESET_H
#define MTREESET_H
#include "mtree.h"
#include "splitgraph.h"
#include "alignment.h"
void readIntVector(const char *file_name, int burnin, int max_count, IntVector &vec);
/**
Set of trees
@author BUI Quang Minh, Steffen Klaere, Arndt von Haeseler
*/
class MTreeSet : public vector<MTree*> {
public:
MTreeSet();
/**
constructor, read trees from user file
@param userTreeFile the name of the user trees
@param is_rooted (IN/OUT) true if tree is rooted
@param burnin the number of beginning trees to be discarded
@param max_count max number of trees to load
*/
MTreeSet(const char *userTreeFile, bool &is_rooted, int burnin, int max_count,
const char *tree_weight_file = NULL);
/**
initialize the tree from a NEWICK tree file
@param userTreeFile the name of the user tree
@param is_rooted (IN/OUT) true if tree is rooted
@param burnin the number of beginning trees to be discarded
@param max_count max number of trees to load
*/
void init(const char *userTreeFile, bool &is_rooted, int burnin, int max_count,
const char *tree_weight_file = NULL, IntVector *weights = NULL, bool compressed = false);
void init(StringIntMap &treels, bool &is_rooted, IntVector &weights);
/**
read the tree from the input file in newick format
@param userTreeFile the name of the user trees
@param is_rooted (IN/OUT) true if tree is rooted
@param burnin the number of beginning trees to be discarded
@param max_count max number of trees to load
*/
void readTrees(const char *userTreeFile, bool &is_rooted, int burnin, int max_count,
IntVector *weights = NULL, bool compressed = false);
/**
assign the leaf IDs with their names for all trees
*/
void assignLeafID();
/**
check the consistency of trees: taxa names between trees are matched, same rooted or unrooted
*/
void checkConsistency();
/**
@return true if trees are rooted
*/
bool isRooted();
/**
print the tree to the output file in newick format
@param outfile the output file.
@param brtype type of branch to print
*/
void printTrees(const char *outfile, int brtype = WT_BR_LEN);
/**
print the tree to the output file in newick format
@param out the output stream.
@param brtype type of branch to print
*/
void printTrees(ostream & out, int brtype = WT_BR_LEN);
/**
convert all trees into the split system
@param taxname certain taxa name
@param sg (OUT) resulting split graph
@param hash_ss (OUT) hash split set
@param lensum TRUE if summing split length, FALSE to increment only
@param weight_threshold minimum weight cutoff
@param sort_taxa TRUE to sort taxa alphabetically
*/
void convertSplits(vector<string> &taxname, SplitGraph &sg, SplitIntMap &hash_ss,
int weighting_type, double weight_threshold, bool sort_taxa = true);
/**
convert all trees into the split system
@param sg (OUT) resulting split graph
@param hash_ss (OUT) hash split set
@param lensum TRUE to assign split weight as sum of corresponding branch lengths.
Otherwise just count the number of branches.
@param weight_threshold minimum weight cutoff
*/
void convertSplits(SplitGraph &sg, SplitIntMap &hash_ss,
int weighting_type, double weight_threshold);
/**
convert all trees into the split system
@param sg (OUT) resulting split graph
@param split_threshold only keep those splits which appear more than this threshold
@param lensum TRUE to assign split weight as sum of corresponding branch lengths.
Otherwise just count the number of branches.
@param weight_threshold minimum weight cutoff
*/
void convertSplits(SplitGraph &sg, double split_threshold,
int weighting_type, double weight_threshold);
/**
compute the Robinson-Foulds distance between trees
@param rfdist (OUT) RF distance
@param mode RF_ALL_PAIR or RF_ADJACENT_PAIR
@param weight_threshold minimum weight cutoff
*/
void computeRFDist(int *rfdist, int mode = RF_ALL_PAIR, double weight_threshold = -1000);
/**
compute the Robinson-Foulds distance between trees
@param rfdist (OUT) RF distance
*/
void computeRFDist(int *rfdist, MTreeSet *treeset2,
const char* info_file = NULL, const char *tree_file = NULL, int *incomp_splits = NULL);
int categorizeDistinctTrees(IntVector &category);
int sumTreeWeights();
/**
destructor
*/
virtual ~MTreeSet();
/**
new tree allocator
@return a new tree
*/
virtual MTree *newTree() { return new MTree(); }
IntVector tree_weights;
};
#endif