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

A class to read a pedigree from a file. More...

#include <LCEmisc.h>

+ Inheritance diagram for FHPedigreeReader:
+ Collaboration diagram for FHPedigreeReader:

Public Member Functions

 FHPedigreeReader (LCE_Cross *event)
 
virtual ~FHPedigreeReader ()
 
virtual void FHwrite ()
 
virtual void FHread (string &filename)
 
vector< unsigned long * > & getPedigree ()
 
- Public Member Functions inherited from EventFileHandler< LCE_Cross >
 EventFileHandler (LCE_Cross *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_Cross *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 ()
 

Private Attributes

vector< unsigned long * > _pedigree
 

Additional Inherited Members

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

Detailed Description

A class to read a pedigree from a file.

Constructor & Destructor Documentation

◆ FHPedigreeReader()

FHPedigreeReader::FHPedigreeReader ( LCE_Cross event)
723 :
724 EventFileHandler< LCE_Cross > (event, ".ped")
725{
726
727}

◆ ~FHPedigreeReader()

virtual FHPedigreeReader::~FHPedigreeReader ( )
inlinevirtual
206{}

Member Function Documentation

◆ FHread()

void FHPedigreeReader::FHread ( string &  filename)
virtual

Implements FileHandler.

729{
730 ifstream FILE(filename.c_str(),ios::in);
731
732 if(!FILE) fatal("could not open pedigree input file \"%s\"\n",filename.c_str());
733
734 string ID, sire, dam;
735
736 unsigned int line = 0;
737
738 unsigned long * record = 0;
739
740 _pedigree.clear();
741
742 message("\n++++ reading pedigree file: %s\n",filename.c_str());
743
744 while(FILE){
745
746 line++;
747
748 FILE >> ID >> sire >> dam;
749
750 if(!FILE || FILE.eof()) break;
751
752 record = new unsigned long [3];
753
754 if(tstring::isanumber(ID)) record[0] = tstring::str2ulong(ID);
755 else if(tstring::isNA(ID)) record[0] = 0;
756 else {
757 error("%s: ID on line %i is not a number\n",filename.c_str(),line);
758 delete [] record; record = 0;
759 continue;
760 }
761
762 if(tstring::isanumber(sire)) record[1] = tstring::str2ulong(sire);
763 else if(tstring::isNA(sire)) record[1] = 0;
764 else {
765 error("%s: 'sire' on line %i is not a number\n",filename.c_str(),line);
766 delete [] record; record = 0;
767 continue;
768 }
769
770 if(tstring::isanumber(dam)) record[2] = tstring::str2ulong(dam);
771 else if(tstring::isNA(dam)) record[2] = 0;
772 else {
773 error("%s: 'dam' on line %i is not a number\n",filename.c_str(),line);
774 delete [] record; record = 0;
775 continue;
776 }
777// cout<<line<<": "<<ID<<" "<<sire<<" "<<dam<<endl;
778
779 _pedigree.push_back(record);
780 }
781
782 if(FILE) FILE.close();
783
784 message("++++ pedigree has %i valid records\n", _pedigree.size());
785}
vector< unsigned long * > _pedigree
Definition: LCEmisc.h:214
static unsigned long str2ulong(const string &str)
Converts a string into an unsigned integer.
Definition: tstring.h:62
static bool isNA(const string &str)
Check whether the string is NA | NaN.
Definition: tstring.h:397
static bool isanumber(const string &str)
Check whether the string is a number.
Definition: tstring.h:381
void fatal(const char *str,...)
Definition: output.cc:96
int error(const char *str,...)
Definition: output.cc:77
void message(const char *message,...)
Definition: output.cc:40

References _pedigree, error(), fatal(), tstring::isanumber(), tstring::isNA(), message(), and tstring::str2ulong().

Referenced by LCE_Cross::generatePedigree().

+ Here is the caller graph for this function:

◆ FHwrite()

virtual void FHPedigreeReader::FHwrite ( )
inlinevirtual

Implements EventFileHandler< LCE_Cross >.

208{}

◆ getPedigree()

vector< unsigned long * > & FHPedigreeReader::getPedigree ( )
inline
211{return _pedigree;}

References _pedigree.

Referenced by LCE_Cross::generatePedigree().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _pedigree

vector< unsigned long * > FHPedigreeReader::_pedigree
private

Referenced by FHread(), and getPedigree().


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