15 for (
int i = 0; i < strlen(in); i++)
18 if (in[i] == 40) lbrack++;
19 else if (in[i] == 41) rbrack++;
20 else if (in[i] == 44) comma++;
22 if (lbrack != rbrack)
error(
"Imbalanced parentheses in phylogeny file");
24 p.
nnodes = lbrack + comma + 1;
40 while ((i < strlen(in)) && (in[i] != 59))
88 if ((in[i] != 58) && (in[i] != 91))
106 char *tmp = NULL; tmpn = 0;
108 while ((in[i] != 58) && (in[i] != 91) &&
109 (in[i] != 44) && (in[i] != 41) && (in[i] != 40) &&
113 asprintf(&tmp,
"%c", in[i]); tmpn++;
116 asprintf(&tmp,
"%s%c", tmp2, in[i]); tmpn++;
122 asprintf(&p.
taxon[node],
"%s", tmp);
131 char *tmp = NULL; tmpn = 0;
133 while ((in[i] != 91) &&
134 (in[i] != 44) && (in[i] != 41) && (in[i] != 40) &&
138 asprintf(&tmp,
"%c", in[i]); tmpn++;
140 Sasprintf(tmp,
"%s%c", tmp, in[i]); tmpn++;
144 p.
bl[node] = atof(tmp);
152 while ((in[i] != 44) && (in[i] != 41) && (in[i] != 40) &&
203 double ageToRootStem = 0;
208 for (
int i = 0; i < p.
nnodes; i++)
212 while (p.
parent[node] != -1) {
217 if (!ageToRootStem) ageToRootStem = tmp;
218 else if (tmp != ageToRootStem)
error(
"tree is not ultrametric");
221 p.
age[0] = ageToRootStem;
222 ageToRootStem += p.
bl[0];
226 error(
"tree stem not old enough for geo age");
232 double periodOld, periodYng, edgeOld, edgeYng;
233 for (
int i = 0; i < p.
nnodes; i++)
235 for (
int j = 0; j <
Times; j++)
239 periodYng = (j < Times-1) ?
RealTime[j+1] : 0.0 ;
240 edgeOld = p.
age[i] + p.
bl[i];
246 if ((edgeOld >= periodOld) &&
247 ((edgeYng <= periodYng) ||
248 ((edgeYng >= periodYng) && (edgeYng < periodOld))))
264 for (
int t =
Times - 1; t > 0; t--)
283 for (
int x = 0; x <
Taxa; x++) {
284 for (i = 0; i < p.
nnodes; i++)
287 for (
int t = 0; t <
Times; t++)
288 for (
int s = 0; s <
Spaces; s++)