-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathegsubs.c
More file actions
137 lines (125 loc) · 2.73 KB
/
Copy pathegsubs.c
File metadata and controls
137 lines (125 loc) · 2.73 KB
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
#include "mcio.h"
#include "egsubs.h"
int
makeeglist (char **eglist, int maxnumeg, Indiv ** indivmarkers, int numindivs)
// old routine mkeglist
{
Indiv *indx;
int i, k, numeg = 0;
for (i = 0; i < numindivs; i++) {
indx = indivmarkers[i];
if (indx->ignore)
continue;
k = indxindex (eglist, numeg, indx->egroup);
if (k < 0) {
if (numeg >= maxnumeg) {
printf
("number of populations too large. Increase maxpops if you wish\n");
fatalx
("(makeeglist) You really want to analyse more than %d populations?\n",
maxnumeg);
}
eglist[numeg] = strdup (indx->egroup);
++numeg;
}
}
return numeg;
}
int
mkeglist (Indiv ** indm, int numindivs, char **eglist)
{
Indiv *indx;
int i, k, numeg = 0;
for (i = 0; i < numindivs; i++) {
indx = indm[i];
if (indx->ignore)
continue;
k = indxindex (eglist, numeg, indx->egroup);
if (k < 0) {
eglist[numeg] = strdup (indx->egroup);
++numeg;
}
}
return numeg;
}
int
loadlist_type (char **list, char *listname, int *ztypes, int off)
// listname is just a list of names ...
{
FILE *lfile;
char line[MAXSTR];
char *spt[MAXFF];
char *sx;
Indiv *indx;
int nsplit, i, n = 0, tt;
if (listname == NULL)
return 0;
openit (listname, &lfile, "r");
while (fgets (line, MAXSTR, lfile) != NULL) {
nsplit = splitup (line, spt, MAXFF);
if (nsplit == 0)
continue;
sx = spt[0];
if (sx[0] == '#') {
freeup (spt, nsplit);
continue;
}
if (nsplit < 2)
fatalx ("bad listname: %s\n", sx);
list[n] = strdup (sx);
tt = atoi (spt[1]);
ztypes[n] = tt + off;
++n;
freeup (spt, nsplit);
}
return n;
}
void
seteglist (Indiv ** indm, int nindiv, char *eglistname)
{
FILE *egfile;
char line[MAXSTR];
char *spt[MAXFF];
char *sx;
Indiv *indx;
int nsplit, i;
if (eglistname == NULL)
return;
openit (eglistname, &egfile, "r");
while (fgets (line, MAXSTR, egfile) != NULL) {
nsplit = splitup (line, spt, MAXFF);
if (nsplit == 0)
continue;
sx = spt[0];
if (sx[0] == '#')
continue;
setstatus (indm, nindiv, sx);
freeup (spt, nsplit);
}
fclose (egfile);
}
void
seteglistv (Indiv ** indm, int nindiv, char *eglistname, int val)
{
FILE *egfile;
char line[MAXSTR];
char *spt[MAXFF];
char *sx = NULL;
Indiv *indx;
int nsplit, i;
if (eglistname == NULL) {
setstatusv (indm, nindiv, NULL, val);
}
openit (eglistname, &egfile, "r");
while (fgets (line, MAXSTR, egfile) != NULL) {
nsplit = splitup (line, spt, MAXFF);
if (nsplit == 0)
continue;
sx = spt[0];
if (sx[0] == '#')
continue;
setstatusv (indm, nindiv, sx, val);
freeup (spt, nsplit);
}
fclose (egfile);
}