Nemo  2.3.46
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 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 bool 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 ()
 

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 ( LCE_Cross event)
731  :
732  EventFileHandler< LCE_Cross > (event, ".ped")
733 {
734 
735 }
virtual FHPedigreeReader::~FHPedigreeReader ( )
inlinevirtual
202 {}

Member Function Documentation

void FHPedigreeReader::FHread ( string &  filename)
virtual

Implements EventFileHandler< LCE_Cross >.

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

Referenced by LCE_Cross::generatePedigree().

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

Implements EventFileHandler< LCE_Cross >.

204 {}
vector< unsigned long * >& FHPedigreeReader::getPedigree ( )
inline

References _pedigree.

Referenced by LCE_Cross::generatePedigree().

207 {return _pedigree;}
vector< unsigned long * > _pedigree
Definition: LCEmisc.h:210

Member Data Documentation

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.0 by  doxygen 1.8.8 --
Catalogued on GSR