Nemo  2.3.46
TTQuantiFH Class Reference

TTQuantiFH. More...

#include <ttquanti.h>

+ Inheritance diagram for TTQuantiFH:
+ Collaboration diagram for TTQuantiFH:

Public Member Functions

 TTQuantiFH (TProtoQuanti *T)
 
virtual ~TTQuantiFH ()
 
void setOutputOption (string opt)
 
virtual void FHwrite ()
 
void print (ofstream &FH, age_idx Ax, bool print_gene, bool print_genotype)
 
virtual void FHread (string &filename)
 
- Public Member Functions inherited from TraitFileHandler< TProtoQuanti >
 TraitFileHandler (TProtoQuanti *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, TProtoQuanti *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 ()
 

Private Attributes

string _output_option
 

Additional Inherited Members

- Protected Attributes inherited from TraitFileHandler< TProtoQuanti >
TProtoQuanti_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

Constructor & Destructor Documentation

TTQuantiFH::TTQuantiFH ( TProtoQuanti T)
inline
virtual TTQuantiFH::~TTQuantiFH ( )
inlinevirtual
311 {}

Member Function Documentation

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

Implements TraitFileHandler< TProtoQuanti >.

317 {}
void TTQuantiFH::FHwrite ( )
virtual

Implements TraitFileHandler< TProtoQuanti >.

References TraitFileHandler< TProtoQuanti >::_FHLinkedTrait, _output_option, ADLTx, ADULTS, fatal(), TProtoQuanti::get_env_var(), FileHandler::get_filename(), TProtoQuanti::get_nb_locus(), TProtoQuanti::get_nb_traits(), FileHandler::get_pop_ptr(), Metapop::getCurrentAge(), Metapop::isAlive(), OFFSPRG, OFFSx, and print().

1994 {
1995 
1996  Metapop* pop = get_pop_ptr();
1997 
1998  if (!pop->isAlive()) return;
1999 
2000  std::string filename = get_filename();
2001 
2002  std::ofstream FILE (filename.c_str(), ios::out);
2003 
2004  if(!FILE) fatal("could not open \"%s\" output file!!\n",filename.c_str());
2005 
2006  bool print_gene = (_output_option == "genotypes" || _output_option == "genotype");
2007  bool print_genotype = (_FHLinkedTrait->get_env_var() != 0);
2008 
2009  FILE<<"pop ";
2010  if(print_gene) {
2011  for(unsigned int k = 0; k < _FHLinkedTrait->get_nb_traits(); k++)
2012  for(unsigned int l = 0; l < _FHLinkedTrait->get_nb_locus(); l++)
2013  FILE<<"t"<<k+1<<".l"<<l+1<<".1 "<<"t"<<k+1<<".l"<<l+1<<".2 ";
2014  }
2015 
2016  for(unsigned int k = 0; k < _FHLinkedTrait->get_nb_traits(); k++) {
2017  FILE<<"P"<<k+1<< " ";
2018  if(print_genotype) FILE<<"G"<<k+1<< " ";
2019  }
2020 
2021  FILE<<"age sex home ped isMigrant father mother ID\n";
2022 
2023  age_t pop_age = pop->getCurrentAge(); //flag telling which age class should contain individuals
2024 
2025  //we print anything that is present in the pop:
2026  if( (pop_age & OFFSPRG) != 0) print(FILE, OFFSx, print_gene, print_genotype);
2027  if( (pop_age & ADULTS) != 0) print(FILE, ADLTx, print_gene, print_genotype);
2028 
2029  FILE.close();
2030 }
TProtoQuanti * _FHLinkedTrait
Definition: filehandler.h:219
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
unsigned int get_nb_traits()
Definition: ttquanti.h:155
unsigned int age_t
Age class flags.
Definition: types.h:46
Top class of the metapopulation structure, contains the patches.
Definition: metapop.h:79
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
bool isAlive()
Checks if the population still contains at least one individual in any sex or age class...
Definition: metapop.h:299
void print(ofstream &FH, age_idx Ax, bool print_gene, bool print_genotype)
Definition: ttquanti.cc:2034
double get_env_var()
Definition: ttquanti.h:158
Definition: types.h:42
Metapop * get_pop_ptr()
Returns the pointer to the current metapop through the FileServices interface.
Definition: filehandler.h:131
string _output_option
Definition: ttquanti.h:307
Definition: types.h:42
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
age_t getCurrentAge()
Definition: metapop.h:289
unsigned int get_nb_locus()
Definition: ttquanti.h:156
void TTQuantiFH::print ( ofstream &  FH,
age_idx  Ax,
bool  print_gene,
bool  print_genotype 
)

References TraitFileHandler< TProtoQuanti >::_FHLinkedTrait, TraitFileHandler< TProtoQuanti >::_FHLinkedTraitIndex, FEM, Patch::get(), TTQuanti::get_genotype(), TProtoQuanti::get_nb_locus(), TProtoQuanti::get_nb_traits(), FileHandler::get_pop_ptr(), TTQuanti::get_sequence(), Individual::getFather(), Individual::getFatherID(), Individual::getHome(), Individual::getID(), Individual::getMother(), Individual::getMotherID(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getPedigreeClass(), Individual::getSex(), Individual::getTrait(), TTQuanti::getValue(), MAL, and Patch::size().

Referenced by FHwrite().

2035 {
2036  Metapop* pop = get_pop_ptr();
2037  int patchNbr = pop->getPatchNbr();
2038  Patch* current_patch;
2039  Individual* ind;
2040  TTQuanti* trait;
2041  double* Tval;
2042  double **genes;
2043  unsigned int loc, nb_trait=_FHLinkedTrait->get_nb_traits(), nb_locus = _FHLinkedTrait->get_nb_locus();
2044 
2045  for(int i = 0; i < patchNbr; i++) {
2046 
2047  current_patch = pop->getPatch(i);
2048 
2049  for(unsigned int j = 0, size = current_patch->size(FEM, Ax); j < size; j++) {
2050 
2051  ind = current_patch->get(FEM, Ax, j);
2052  trait = dynamic_cast<TTQuanti*> (ind->getTrait(_FHLinkedTraitIndex));
2053 
2054  FH<<i+1<<" ";
2055  Tval = (double*)trait->getValue();
2056 
2057  if(print_gene){
2058  genes = (double**)trait->get_sequence();
2059 
2060  FH.precision(6);
2061 
2062  for(unsigned int k = 0; k < nb_trait; k++) {
2063  for(unsigned int l = 0; l < nb_locus; l++) {
2064  loc = l * nb_trait + k;
2065 
2066  FH<<genes[0][loc]<<" "<<genes[1][loc]<<" ";
2067  }
2068  }
2069  }
2070 
2071  FH.precision(4);
2072  for(unsigned int k = 0; k < nb_trait; k++) {
2073  FH<<Tval[k]<<" ";
2074  if(print_genotype) FH << trait->get_genotype(k) << " ";
2075  }
2076 
2077  FH<<Ax<<" "<<ind->getSex()<<" "<<ind->getHome()+1<<" "<<ind->getPedigreeClass()<<" "
2078  << (ind->getFather() && ind->getMother() ?
2079  (ind->getFather()->getHome()!=i) + (ind->getMother()->getHome()!=i) : 0)
2080  <<" "<<ind->getFatherID()<<" "<<ind->getMotherID()<<" "<<ind->getID()<<std::endl;
2081  }
2082 
2083  for(unsigned int j = 0, size = current_patch->size(MAL, Ax); j < size; j++) {
2084 
2085  ind = current_patch->get(MAL, Ax, j);
2086  trait = dynamic_cast<TTQuanti*> (ind->getTrait(_FHLinkedTraitIndex));
2087 
2088  FH<<i+1<<" ";
2089 
2090  Tval = (double*)trait->getValue();
2091 
2092  if(print_gene){
2093  genes = (double**)trait->get_sequence();
2094 
2095  FH.precision(6);
2096 
2097  for(unsigned int k = 0; k < nb_trait; k++) {
2098  for(unsigned int l = 0; l < nb_locus; l++) {
2099  loc = l * nb_trait + k;
2100 
2101  FH<<genes[0][loc]<<" "<<genes[1][loc]<<" ";
2102  }
2103  }
2104  }
2105 
2106  FH.precision(4);
2107  for(unsigned int k = 0; k < nb_trait; k++) {
2108  FH<<Tval[k]<<" ";
2109  if(print_genotype) FH << trait->get_genotype(k) << " ";
2110  }
2111 
2112  FH<<Ax<<" "<<ind->getSex()<<" "<<ind->getHome()+1<<" "<<ind->getPedigreeClass()<<" "
2113  << (ind->getFather() && ind->getMother() ?
2114  (ind->getFather()->getHome()!=i) + (ind->getMother()->getHome()!=i) : 0)<<" "<<ind->getFatherID()<<" "<<ind->getMotherID()<<" "<<ind->getID()<<std::endl;
2115  }
2116  }
2117 }
TTQuanti.
Definition: ttquanti.h:55
TProtoQuanti * _FHLinkedTrait
Definition: filehandler.h:219
double get_genotype(unsigned int trait)
Definition: ttquanti.cc:1105
virtual void ** get_sequence() const
Definition: ttquanti.h:88
virtual void * getValue() const
Definition: ttquanti.h:86
unsigned long getID()
Definition: individual.h:122
unsigned int get_nb_traits()
Definition: ttquanti.h:155
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
Individual * getFather()
Definition: individual.h:126
unsigned long getMotherID()
Definition: individual.h:125
Top class of the metapopulation structure, contains the patches.
Definition: metapop.h:79
Individual * getMother()
Definition: individual.h:127
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
unsigned long getFatherID()
Definition: individual.h:124
unsigned int getPatchNbr()
Definition: metapop.h:270
Metapop * get_pop_ptr()
Returns the pointer to the current metapop through the FileServices interface.
Definition: filehandler.h:131
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179
unsigned short getHome()
Definition: individual.h:128
Definition: types.h:37
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
sex_t getSex()
Definition: individual.h:129
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
Definition: types.h:37
unsigned int get_nb_locus()
Definition: ttquanti.h:156
int _FHLinkedTraitIndex
Definition: filehandler.h:220
void TTQuantiFH::setOutputOption ( string  opt)
inline

Referenced by TProtoQuanti::loadFileServices().

313 {_output_option = opt;}
string _output_option
Definition: ttquanti.h:307

Member Data Documentation

string TTQuantiFH::_output_option
private

Referenced by FHwrite().


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