Nemo  2.4.0b
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 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 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 ~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
369 {}

Member Function Documentation

◆ FHread()

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

Implements FileHandler.

373 {}

◆ FHwrite()

void LCE_SelectionFH::FHwrite ( )
virtual

Implements EventFileHandler< LCE_Selection_base >.

1612 {
1613  unsigned int num_traits = _FHLinkedEvent->_TraitIndices.size();
1614 
1615  std::string filename = get_filename();
1616 
1617  std::ofstream FILE (filename.c_str(), ios::out);
1618 
1619  if(!FILE) fatal("could not open \"%s\" output file!!\n",filename.c_str());
1620 
1621  FILE<<"pop";
1622 
1623  for (unsigned int i = 0; i < num_traits; ++i) {
1624  FILE<<" trait"<< tstring::int2str(i+1);
1625  }
1626 
1627  FILE<< " age isMigrant"<<endl;
1628 
1629 
1630  Patch* patch;
1631 
1632  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i ) {
1633 
1634  patch = _pop->getPatch(i);
1635 
1636  if (patch->size(FEM, OFFSx) != 0) print(FILE, FEM, OFFSx, i, patch, num_traits);
1637  if (patch->size(MAL, OFFSx) != 0) print(FILE, MAL, OFFSx, i, patch, num_traits);
1638 
1639  if (patch->size(FEM, ADLTx) != 0) print(FILE, FEM, ADLTx, i, patch, num_traits);
1640  if (patch->size(MAL, ADLTx) != 0) print(FILE, MAL, ADLTx, i, patch, num_traits);
1641 
1642  }
1643 
1644 
1645  FILE.close();
1646 }
LCE_Selection_base * _FHLinkedEvent
Definition: filehandler.h:256
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:1650
vector< unsigned int > _TraitIndices
The indices of the traits under selection.
Definition: LCEselection.h:125
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:432
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
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 
)
1651 {
1652  Individual* ind = 0;
1653 
1654  for (unsigned int i = 0; i < patch->size(SEX, AGE); ++i) {
1655 
1656  ind = patch->get(SEX, AGE, i);
1657 
1658  FH<<p+1;
1659 
1660  for(unsigned int j = 0; j < ntraits; ++j)
1662 
1663  FH<<" "<<ind->getAge()<< " "<< (p == ind->getHome() ? 0 : 1) <<endl;
1664  }
1665 }
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:133
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:534

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().


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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR