Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LCE_SelectionFH Class Reference

#include <LCEselection.h>

+ Inheritance diagram for LCE_SelectionFH:
+ Collaboration diagram for LCE_SelectionFH:

Public Member Functions

 LCE_SelectionFH (LCE_Selection_base *event)
 
virtual ~LCE_SelectionFH ()
 
virtual void FHwrite ()
 
virtual void FHread (string &filename)
 
void print (ofstream &FH, sex_t SEX, age_idx AGE, unsigned int i, Patch *patch, unsigned int ntraits)
 
- Public Member Functions inherited from EventFileHandler< LCE_Selection_base >
 EventFileHandler (LCE_Selection_base *event, const char *ext)
 
virtual ~EventFileHandler ()
 
virtual void FHwrite ()=0
 
virtual void FHread (string &filename)=0
 
virtual void set (bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, LCE_Selection_base *event)
 
- Public Member Functions inherited from FileHandler
 FileHandler (const char *ext)
 
virtual ~FileHandler ()
 
virtual void init ()
 Called by notifier during simulation setup, performs file checking. More...
 
virtual vector< string > ifExist ()
 Checks if any file associated with the current file name already exists on disk. More...
 
virtual void set (bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path)
 Sets the hanlder parameters. More...
 
virtual void set_multi (bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path)
 
virtual void FHwrite ()=0
 Default behavior of the class, called by Handler::update(). More...
 
virtual void FHread (string &filename)=0
 Default input function. More...
 
virtual void update ()
 Updates the inner replicate and generation counters and calls FHwrite if needed by the the periodicity of the file. More...
 
Metapopget_pop_ptr ()
 Returns the pointer to the current metapop through the FileServices interface. More...
 
void set_pop_ptr (Metapop *pop_ptr)
 
FileServicesget_service ()
 Returns pointer to the FileServices. More...
 
void set_service (FileServices *srv)
 
std::string & get_path ()
 
void set_path ()
 
std::string & get_extension ()
 
void set_extension (const char *ext)
 
std::string & get_filename ()
 Builds and returns the current file name depending on the periodicity of the file. More...
 
bool get_isInputHandler ()
 
void set_isInputHandler (bool val)
 
bool get_isReplicatePeriodic ()
 
void set_isReplicatePeriodic (bool val)
 
unsigned int get_ReplicateOccurrence ()
 
void set_ReplicateOccurrence (unsigned int val)
 
bool get_isGenerationPeriodic ()
 
void set_isGenerationPeriodic (bool val)
 
unsigned int get_GenerationOccurrence ()
 
void set_GenerationOccurrence (unsigned int val)
 
unsigned int get_ExecRank ()
 unused yet... More...
 
void set_ExecRank (int val)
 
TMatrixget_OccMatrix ()
 
void set_OccMatrix (TMatrix *occ)
 
bool get_isMasterExec ()
 
void set_isMasterExec (bool is)
 
- Public Member Functions inherited from Handler
virtual void init ()=0
 Inits state. More...
 
virtual void update ()=0
 Updates the handler state. More...
 
virtual ~Handler ()
 

Additional Inherited Members

- Protected Attributes inherited from EventFileHandler< LCE_Selection_base >
LCE_Selection_base_FHLinkedEvent
 
- Protected Attributes inherited from FileHandler
Metapop_pop
 Pointer to the current metapop, set during initialization within the init function. More...
 

Constructor & Destructor Documentation

◆ LCE_SelectionFH()

LCE_SelectionFH::LCE_SelectionFH ( LCE_Selection_base event)
inline

◆ ~LCE_SelectionFH()

virtual LCE_SelectionFH::~LCE_SelectionFH ( )
inlinevirtual
334{}

Member Function Documentation

◆ FHread()

virtual void LCE_SelectionFH::FHread ( string &  filename)
inlinevirtual

Implements FileHandler.

338{}

◆ FHwrite()

void LCE_SelectionFH::FHwrite ( )
virtual

Implements EventFileHandler< LCE_Selection_base >.

1392{
1393 unsigned int num_traits = _FHLinkedEvent->_TraitIndices.size();
1394
1395 std::string filename = get_filename();
1396
1397 std::ofstream FILE (filename.c_str(), ios::out);
1398
1399 if(!FILE) fatal("could not open \"%s\" output file!!\n",filename.c_str());
1400
1401 FILE<<"pop";
1402
1403 for (unsigned int i = 0; i < num_traits; ++i) {
1404 FILE<<" trait"<< tstring::int2str(i+1);
1405 }
1406
1407 FILE<< " age isMigrant"<<endl;
1408
1409
1410 Patch* patch;
1411
1412 for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i ) {
1413
1414 patch = _pop->getPatch(i);
1415
1416 if (patch->size(FEM, OFFSx) != 0) print(FILE, FEM, OFFSx, i, patch, num_traits);
1417 if (patch->size(MAL, OFFSx) != 0) print(FILE, MAL, OFFSx, i, patch, num_traits);
1418
1419 if (patch->size(FEM, ADLTx) != 0) print(FILE, FEM, ADLTx, i, patch, num_traits);
1420 if (patch->size(MAL, ADLTx) != 0) print(FILE, MAL, ADLTx, i, patch, num_traits);
1421
1422 }
1423
1424
1425 FILE.close();
1426}
LCE_Selection_base * _FHLinkedEvent
Definition: filehandler.h:249
std::string & get_filename()
Builds and returns the current file name depending on the periodicity of the file.
Definition: filehandler.cc:151
Metapop * _pop
Pointer to the current metapop, set during initialization within the init function.
Definition: filehandler.h:103
void print(ofstream &FH, sex_t SEX, age_idx AGE, unsigned int i, Patch *patch, unsigned int ntraits)
Definition: LCEselection.cc:1430
vector< unsigned int > _TraitIndices
The indices of the traits under selection.
Definition: LCEselection.h:111
unsigned int getPatchNbr()
Definition: metapop.h:276
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
static string int2str(const int i)
Writes an integer value into a string.
Definition: tstring.h:95
void fatal(const char *str,...)
Definition: output.cc:96
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
@ OFFSx
Definition: types.h:42
@ ADLTx
Definition: types.h:42

References EventFileHandler< LCE_Selection_base >::_FHLinkedEvent, FileHandler::_pop, LCE_Selection_base::_TraitIndices, ADLTx, fatal(), FEM, FileHandler::get_filename(), Metapop::getPatch(), Metapop::getPatchNbr(), tstring::int2str(), MAL, OFFSx, print(), and Patch::size().

◆ print()

void LCE_SelectionFH::print ( ofstream &  FH,
sex_t  SEX,
age_idx  AGE,
unsigned int  i,
Patch patch,
unsigned int  ntraits 
)
1431{
1432 Individual* ind = 0;
1433
1434 for (unsigned int i = 0; i < patch->size(SEX, AGE); ++i) {
1435
1436 ind = patch->get(SEX, AGE, i);
1437
1438 FH<<p+1;
1439
1440 for(unsigned int j = 0; j < ntraits; ++j)
1442
1443 FH<<" "<<ind->getAge()<< " "<< (p == ind->getHome() ? 0 : 1) <<endl;
1444 }
1445}
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
unsigned short getHome()
Definition: individual.h:128
unsigned short getAge()
Definition: individual.h:123
vector< double(LCE_Selection_base::*)(Individual *, unsigned int, unsigned int) > _getRawFitness
A vector containing pointers to fitness function related to each trait under selection.
Definition: LCEselection.h:119
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:532

References EventFileHandler< LCE_Selection_base >::_FHLinkedEvent, LCE_Selection_base::_getRawFitness, LCE_Selection_base::_TraitIndices, Patch::get(), Individual::getAge(), Individual::getHome(), and Patch::size().

Referenced by FHwrite().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files:

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR