1228{
1232
1233 ifstream FILE(filename.c_str(),ios::in);
1234
1235 if(!FILE)
fatal(
"could not open DELET input file \"%s\"\n",filename.c_str());
1236
1237 unsigned int genot, age, sex, ped, origin, xline = 0;
1238 unsigned long ID;
1239 int pop;
1242 unsigned char all0, all1;
1246
1247 double* effects[2];
1248 int lnbr = 3;
1249
1250 effects[0] = new double [nb_locus];
1251 effects[1] = new double [nb_locus];
1252
1253 string str;
1254 for (unsigned int i = 0; i < nb_locus + 6; ++i) {
1255 FILE>>str;
1256 }
1257
1258 if(!FILE)
1259 fatal(
"reading delet genotypes from \"%s\" failed (expecting %i elements per line)\n",
1260 filename.c_str(), nb_locus + 6);
1261
1262
1263
1264 xline = 0;
1265 while(FILE>>pop) {
1266
1267 if(pop > (int)patchNbr)
1268 fatal(
"Patch number found in file exceeds number of patches in the population.\n");
1269
1270 if(pop == -1) {
1271
1272
1273
1274 assert(xline <= 1);
1275
1276 for(unsigned int i = 0; i < nb_locus; ++i) {
1277 FILE>>effects[xline][i];
1278 }
1279
1280 for(unsigned int i = 0; i < 5; ++i)
1281 FILE>>str;
1282
1283 if(!FILE)
1284 fatal(
"reading delet genotypes from \"%s\" failed (expecting %i elements per line)\n",
1285 filename.c_str(), nb_locus + 6);
1286
1287 xline++;
1288 }
1289 else {
1290
1291 for(unsigned int i = 0; i < nb_locus; ++i) {
1292
1293 FILE>>genot;
1294
1295 all0 = (unsigned char) genot/10;
1296 all1 = (unsigned char) genot%10;
1297
1298 if(all0 <= 1) {
1299
1300 if(all0) seq[0]->
set(i);
1301
1302 } else {
1303 error(
"in DELET input file at line %i, locus %i : \
1304 first allele value %d is greater than 1!\n", lnbr, i+1, all0);
1305 fatal(
"Please check the input file.\n");
1306 }
1307
1308 if(all1 <= 1){
1309
1310 if(all1) seq[1]->
set(i);
1311
1312 } else {
1313 error(
"in DELET input file at line %i, locus %i : \
1314 second allele value %i is greater than 1!\n", lnbr, i+1, all1);
1315 fatal(
"Please check the input file.\n");
1316 }
1317 }
1318
1319 FILE >> age >> sex >> ped >> origin >> ID;
1320
1321 if(!FILE)
1322 fatal(
"reading delet genotypes from \"%s\" failed (expecting %i elements per line)\n",
1323 filename.c_str(), nb_locus + 6);
1324
1326
1334
1336
1339
1340 }
1341
1342 lnbr++;
1343
1344 }
1345
1346 FILE.close();
1347
1348
1349 if(xline == 2) {
1351
1352 for(unsigned int i = 0; i < nb_locus; ++i) {
1355 }
1356 }
1357 delete seq[0];
1358 delete seq[1];
1359 delete [] effects[0];
1360 delete [] effects[1];
1361}
Metapop * _pop
Pointer to the current metapop, set during initialization within the init function.
Definition: filehandler.h:103
Individual * makeNewIndividual(Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Creates an individual with pointers to parents, sex and home ID set but no genetic data.
Definition: indfactory.cc:152
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
void setPedigreeClass(Individual *mother, Individual *father)
Definition: individual.h:115
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
void setHome(unsigned short value)
Definition: individual.h:111
void setAge(unsigned short value)
Definition: individual.h:105
void add(sex_t SEX, age_idx AGE, Individual *ind)
Adds an individual to the appropriate container, increments its size, eventually resizing it.
Definition: metapop.h:549
Prototype class of the bitstring-deleterious mutations trait class.
Definition: ttdeletmutations_bitstring.h:171
int get_nb_locus()
Definition: ttdeletmutations_bitstring.h:179
void set_effect(unsigned int at, unsigned int loc, float val)
Definition: ttdeletmutations_bitstring.h:197
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
virtual void set_value()
Definition: ttdeletmutations_bitstring.cc:842
void set_sequence(bitstring **seq)
Definition: ttdeletmutations_bitstring.cc:670
int _FHLinkedTraitIndex
Definition: filehandler.h:220
TProtoDeletMutations_bitstring * _FHLinkedTrait
Definition: filehandler.h:219
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
void reset()
Set all bits to 0.
Definition: bitstring.h:256
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:240
void fatal(const char *str,...)
Definition: output.cc:96
int error(const char *str,...)
Definition: output.cc:77
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:41
@ OFFSx
Definition: types.h:42
@ ADLTx
Definition: types.h:42