-
Notifications
You must be signed in to change notification settings - Fork 3
/
ecopd.h
276 lines (220 loc) · 6.2 KB
/
ecopd.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*
* ecopd.h
*
* Created on: Oct 30, 2013
* Author: Olga
*/
#ifndef ECOPD_H
#define ECOPD_H
#include "mtree.h"
#include "mtreeset.h"
#include "ecopdmtreeset.h"
#include "pdnetwork.h"
/* ===============================================================================
* Class for processing IP problem - PD/SD with ecological constraints
* ===============================================================================*/
class ECOpd : public MTree
{
public:
/**
CONSTRUCTORs, INITIALIZATION and DESTRUCTOR
*/
ECOpd(const char *userTreeFile, bool &is_rooted);
ECOpd();
~ECOpd();
void initializeEcoPD();
void initializeEcoPD(Params ¶ms);
/*
* Checks whether taxon with id i ("real" id, that is when calling call with i+1 ) is present on the tree/split network
*/
bool OUT_tree(int i);
/*
* Reading and processing Diet Composition matrix
*/
void readDAG(const char *infile);
void readDAG(istream &in);
/*
* Transform problem into IP problem and print it to .lp file, for rooted trees
*/
void printECOlpRooted(const char* fileOUT,ECOpd &tree);
/*
* Transform problem into IP problem and print it to .lp file, for UNrooted trees
*/
void printECOlpUnrooted(const char* fileOUT,ECOpd &tree);
/*
* Transform problem into IP problem and print it to .lp file, for split system
*/
void printInfDAG (const char* fileOUT,PDNetwork &splitsys,Params ¶ms);
/*
* Synchronization of species in the food web with species on the tree
*/
void synchTreeDAG(ECOpd &tree);
/*
* Synchronization of species in the food web with species in the split network
*/
void synchSplitDAG(PDNetwork &system);
/*
* some left_overs from mtree class, function which is not there anymore..
*/
void getBranchOrdered(NodeVector &nodes, NodeVector &nodes2,Node *node = NULL, Node *dad = NULL);
/*
* Find the id of the species on tree by name
*/
int findPhyloID(string name);
/*
* Find the id of the species in the food web by their phylo id (id of this species in the tree)
*/
int findFoodWebID(int id);
/*
* checks whether there are some species present on the tree/splitSys, but not in the foodWeb, and wise versa.
*/
void detectMissingSpecies();
/*
* List of species missing either on the tree/splitSys (missInPhylo), or in the food web (missInDAG)
*/
vector<string> missInPhylo,missInDAG;
/*
* Finding Taxon from tree/splitSys among DAG Species
*/
bool findTaxaDAG(int i);
/*
* Finding Species from DAG among Taxa on tree/splitSys
*/
bool findSpeciesPhylo(int i);
/*
* the number of links in the food web
*/
int linksNUM;
/*
* synchronization of species on Tree/SplitSys and in Food Web
*/
void synchronizeSpecies();
/*
* Reading taxa to be included in the final optimal subset
*/
void readInitialTaxa(const char *infile);
void readInitialTaxa(istream &in);
/*
* list of taxa (names) to be included in the final optimal set
*/
vector<string> initialTaxa;
/*
* Check if the species in InitialTaxa are actually present either on tree/network or in the food web
*/
void checkInitialTaxa();
/*
* find an id (among nvar) of a given species by name
*/
int findSpeciesIDname(string *name);
/*
* Define the subset size and check if it's >1 and <nvar (#of all species in the analysis = (TaxaNUM > SpeciesNUM) ? TaxaNUM : SpeciesNUM)
*/
void defineK(Params ¶ms);
/*
* Check whether the food web is acyclic or not
*/
void checkGraph();
/*
* Diet Composition Matrix (entries either 0/1 or [0,100] )
*/
vector<double*> DAG;
/*
* Prints the sub food web corresponding to the optimal subset
*/
void printSubFoodWeb(char* fileOUT, double* variables);
/*
* t for tree or n for networks
*/
string phyloType;
/*
* Structure of the DAG: taxa with neighbors being their preys
*/
NodeVector taxaDAG;
/*
* two vectors of nodes, corresponding to ends of branches
*/
NodeVector nodes1,nodes2;
/*
* Ids of species not present on tree/split network
*/
vector<int> OUTtreeTaxa;
/*
* Ids of species not present in the food web
*/
vector<int> OUTdagTaxa;
/*
* contains the ids of species based on tree/split network (phylo_oder[i] = j species with id=j in the food web has id=i on tree/split network)
*/
vector<int> phylo_order;
/*
* for each species contains information about its longest food chain (excluding species itself)
*/
vector<int> levelDAG;
/*
* the names of species present in the food web and on the tree/split network respectively
*/
vector<string> dagNames,phyloNames;
/*
* names of all species: union of species on the tree/network and in the food web
*/
vector<string*> names;
/*
* flag for whether to treat the food web as weighted or not weighted
*/
bool weighted;
/*
* the size of an optimal subset to be chosen
*/
int k;
/*
* the diet portion to be conserved for each predator, when equals to 0 corresponds to a naive viability
*/
double T;
/*
* the number of species in the food web (if rooted tree counts also the root, technical)
*/
int SpeciesNUM;
/*
* the number of species on the tree/split network (if rooted tree counts also the root)
*/
int TaxaNUM;
/*
* the number of all species: union of species on the tree/network and in the food web
*/
int nvar;
/*
* calculates for each predator the diet proportional conserved
*/
void dietConserved(double *variables);
/*
* for each predator the diet proportional conserved
*/
vector<double> dietVAL;
/*
* print the results
*/
void printResults(char* fileOUT,double* variables, double score, Params ¶ms);
/*
* Splits number and total SD
*/
int splitsNUM;
double totalSD;
/**************************
* Miscellaneous
**************************/
/*
* These function were used when we analyzed results from LP problems, to set the fractional values to be integers
* now, it is not used
*/
void readREC(const char *infile);
void readREC(istream &in);
void generateFirstMultinorm(vector<int> &x, int n, int k);
bool generateNextMultinorm(vector<int> &x);
vector<string> fractVAR;
vector<int> dvec,hvec;
/*
* Assigns to a given tree topology random branch lengths
*/
void randomBranLenTrees(Params ¶ms);
};
#endif