Nemo  2.3.46
TTBDMI_FH Class Reference

FileHandler for the DBMI trait. More...

#include <ttbdmi.h>

+ Inheritance diagram for TTBDMI_FH:
+ Collaboration diagram for TTBDMI_FH:

Public Member Functions

 TTBDMI_FH (TProtoBDMI *TP)
 
virtual ~TTBDMI_FH ()
 
void write_haplo (Patch *patch, sex_t SEX, age_idx AGE, ofstream &FH)
 
void write_diplo (Patch *patch, sex_t SEX, age_idx AGE, ofstream &FH)
 
virtual void FHwrite ()
 
virtual void FHread (string &filename)
 
- Public Member Functions inherited from TraitFileHandler< TProtoBDMI >
 TraitFileHandler (TProtoBDMI *trait_proto, const char *ext)
 
virtual ~TraitFileHandler ()
 
virtual void set (bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, TProtoBDMI *trait_proto)
 
- 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 ()
 

Additional Inherited Members

- Protected Attributes inherited from TraitFileHandler< TProtoBDMI >
TProtoBDMI_FHLinkedTrait
 
int _FHLinkedTraitIndex
 
- Protected Attributes inherited from FileHandler
Metapop_pop
 Pointer to the current metapop, set during initialization within the init function. More...
 

Detailed Description

FileHandler for the DBMI trait.

Records the complete genotype in a text file.

Constructor & Destructor Documentation

TTBDMI_FH::TTBDMI_FH ( TProtoBDMI TP)
inline
virtual TTBDMI_FH::~TTBDMI_FH ( )
inlinevirtual
241 { }

Member Function Documentation

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

Implements TraitFileHandler< TProtoBDMI >.

247 {}
void TTBDMI_FH::FHwrite ( )
virtual

Implements TraitFileHandler< TProtoBDMI >.

References TraitFileHandler< TProtoBDMI >::_FHLinkedTrait, ADLTx, fatal(), FEM, FileHandler::get_filename(), TProtoBDMI::get_nb_locus(), FileHandler::get_pop_ptr(), Metapop::getPatch(), Metapop::getPatchNbr(), TProtoBDMI::isHaploid(), MAL, OFFSx, write_diplo(), and write_haplo().

526 {
527  if(!get_pop_ptr()->isAlive()) return;
528 
529  string filename = get_filename();
530 
531  ofstream FILE (filename.c_str(), ios::out);
532 
533  if(!FILE) fatal("could not open DMI output file\n");
534 
535 
536  Patch* current_patch;
537  int patchNbr = get_pop_ptr()->getPatchNbr();
538 
539  FILE<<"pop ";
540 
541  for(int i = 0; i < _FHLinkedTrait->get_nb_locus(); i++)
542  FILE<<"loc"<<i+1<<" ";
543 
544  FILE<<"age sex ped origin"<<endl;
545 
546  for (int i = 0; i < patchNbr; ++i) {
547 
548  current_patch = get_pop_ptr()->getPatch(i);
549  if(_FHLinkedTrait->isHaploid()) {
550  write_haplo(current_patch, FEM, OFFSx, FILE);
551  write_haplo(current_patch, MAL, OFFSx, FILE);
552  write_haplo(current_patch, FEM, ADLTx, FILE);
553  write_haplo(current_patch, MAL, ADLTx, FILE);
554  } else {
555  write_diplo(current_patch, FEM, OFFSx, FILE);
556  write_diplo(current_patch, MAL, OFFSx, FILE);
557  write_diplo(current_patch, FEM, ADLTx, FILE);
558  write_diplo(current_patch, MAL, ADLTx, FILE);
559  }
560  }
561 }
TProtoBDMI * _FHLinkedTrait
Definition: filehandler.h:219
std::string & get_filename()
Builds and returns the current file name depending on the periodicity of the file.
Definition: filehandler.cc:148
void fatal(const char *str,...)
Definition: output.cc:90
void write_diplo(Patch *patch, sex_t SEX, age_idx AGE, ofstream &FH)
Definition: ttbdmi.cc:586
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
bool isHaploid()
Definition: ttbdmi.h:79
unsigned int getPatchNbr()
Definition: metapop.h:270
Definition: types.h:42
Metapop * get_pop_ptr()
Returns the pointer to the current metapop through the FileServices interface.
Definition: filehandler.h:131
int get_nb_locus()
Definition: ttbdmi.h:77
Definition: types.h:37
Definition: types.h:42
void write_haplo(Patch *patch, sex_t SEX, age_idx AGE, ofstream &FH)
Definition: ttbdmi.cc:565
Definition: types.h:37
void TTBDMI_FH::write_diplo ( Patch patch,
sex_t  SEX,
age_idx  AGE,
ofstream &  FH 
)

References TraitFileHandler< TProtoBDMI >::_FHLinkedTrait, TraitFileHandler< TProtoBDMI >::_FHLinkedTraitIndex, ADULTS, Patch::get(), TProtoBDMI::get_nb_locus(), TTrait::get_sequence(), Individual::getHome(), Patch::getID(), Individual::getPedigreeClass(), Individual::getTrait(), OFFSPRG, OFFSx, and Patch::size().

Referenced by FHwrite().

587 {
588  bitstring** seq;
589  Individual *ind;
590  for (unsigned int j = 0, size = patch->size(SEX, AGE); j < size; ++j) {
591 
592  FH<<patch->getID()+1<<" ";
593  ind = patch->get(SEX, AGE, j);
595 
596  for(int k = 0; k < _FHLinkedTrait->get_nb_locus(); ++k)
597  FH<<(int)((*seq[0])[k])<<(int)((*seq[1])[k])<<" ";
598 
599  FH << (AGE == OFFSx ? OFFSPRG : ADULTS) << " " << SEX << " "
600  << ind->getPedigreeClass() << " " << ind->getHome()+1<<endl;
601  }
602 
603 }
TProtoBDMI * _FHLinkedTrait
Definition: filehandler.h:219
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
unsigned int getID()
Definition: metapop.h:469
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
virtual void ** get_sequence() const =0
sequence accessor.
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179
int get_nb_locus()
Definition: ttbdmi.h:77
unsigned short getHome()
Definition: individual.h:128
Definition: types.h:42
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:523
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
int _FHLinkedTraitIndex
Definition: filehandler.h:220
void TTBDMI_FH::write_haplo ( Patch patch,
sex_t  SEX,
age_idx  AGE,
ofstream &  FH 
)

References TraitFileHandler< TProtoBDMI >::_FHLinkedTrait, TraitFileHandler< TProtoBDMI >::_FHLinkedTraitIndex, ADULTS, Patch::get(), TProtoBDMI::get_nb_locus(), TTrait::get_sequence(), Individual::getHome(), Patch::getID(), Individual::getPedigreeClass(), Individual::getTrait(), OFFSPRG, OFFSx, and Patch::size().

Referenced by FHwrite().

566 {
567  bitstring** seq;
568  Individual *ind;
569  for (unsigned int j = 0, size = patch->size(SEX, AGE); j < size; ++j) {
570 
571  FH<<patch->getID()+1<<" ";
572  ind = patch->get(SEX, AGE, j);
574 
575  for(int k = 0; k < _FHLinkedTrait->get_nb_locus(); ++k)
576  FH<<(int)((*seq[0])[k])<<" ";
577 
578  FH << (AGE == OFFSx ? OFFSPRG : ADULTS) << " " << SEX << " "
579  << ind->getPedigreeClass() << " " << ind->getHome()+1<<endl;
580  }
581 
582 }
TProtoBDMI * _FHLinkedTrait
Definition: filehandler.h:219
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
unsigned int getID()
Definition: metapop.h:469
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
virtual void ** get_sequence() const =0
sequence accessor.
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179
int get_nb_locus()
Definition: ttbdmi.h:77
unsigned short getHome()
Definition: individual.h:128
Definition: types.h:42
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:523
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
int _FHLinkedTraitIndex
Definition: filehandler.h:220

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