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

TTQuanti_diallelic_no_pleio : single or multiple non-pleiotropic traits, di-allelic. More...

#include <ttquanti.h>

+ Inheritance diagram for TTQuanti_diallelic_no_pleio:
+ Collaboration diagram for TTQuanti_diallelic_no_pleio:

Public Member Functions

 TTQuanti_diallelic_no_pleio ()
 
 TTQuanti_diallelic_no_pleio (const TTQuanti_diallelic_no_pleio &TT)
 
virtual ~TTQuanti_diallelic_no_pleio ()
 
virtual void init_sequence ()
 
virtual TTQuanti_diallelic_no_pleioclone ()
 
virtual void show_up ()
 
virtual double get_additive_genotype (const unsigned int trait) const
 
virtual double get_dominant_genotype (const unsigned int trait) const
 
virtual void copy_sequence_block (sex_t SEX, unsigned int strand, unsigned int from_locus, unsigned int to_locus, const TTQuanti *parent)
 
virtual void copy_sequence_1locus (sex_t SEX, unsigned int strand, unsigned int at, const TTQuanti *parent)
 
- Public Member Functions inherited from TTQuanti_diallelic
 TTQuanti_diallelic ()
 
 TTQuanti_diallelic (const TTQuanti &T)
 
virtual ~TTQuanti_diallelic ()
 
virtual bool get_allele_bit (unsigned int position, unsigned int allele) const
 
virtual void set_allele_bit (unsigned int position, unsigned int allele, bool value)
 
void inherit_free (const TTrait *mother, const TTrait *father)
 
virtual void reset ()
 
virtual void init ()
 
virtual void set_sequence (void **seq)
 
virtual void ** get_sequence () const
 
virtual unsigned int get_allele (int loc, int all) const
 
virtual double get_allele_value (int locus, int allele) const
 
virtual void set_allele_value (unsigned int locus, unsigned int allele, double value)
 
virtual TTQuanti_diallelicoperator= (const TTrait &T)
 
virtual bool operator== (const TTrait &T)
 
virtual bool operator!= (const TTrait &T)
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
virtual double get_full_genotype (unsigned int trait)
 
virtual void set_allele (int locus, int allele, double value)
 
virtual void mutate_add (unsigned int position, unsigned int allele, double value)
 
virtual void mutate_inplace (unsigned int position, unsigned int allele, double value)
 
- Public Member Functions inherited from TTQuanti
 TTQuanti ()
 
 TTQuanti (const TTQuanti &T)
 
virtual ~TTQuanti ()
 
virtual trait_t get_type () const
 
virtual void mutate ()
 
virtual void inherit (const TTrait *mother, const TTrait *father)
 
virtual void * set_trait (void *value)
 
virtual void set_value ()
 
virtual void * getValue () const
 
void set_proto (TProtoQuanti *proto)
 
TProtoQuantiget_proto ()
 
double get_phenotype (unsigned int trai)
 
void set_phenotype (unsigned int trait, double value)
 
void reset_phenotype_to_genotypic_value ()
 
- Public Member Functions inherited from TTrait
virtual ~TTrait ()
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 

Additional Inherited Members

- Protected Attributes inherited from TTQuanti_diallelic
unsigned char ** _sequence
 
- Protected Attributes inherited from TTQuanti
double * _phenotypes
 
double * _genotypic_values
 
TProtoQuanti_myProto
 

Detailed Description

TTQuanti_diallelic_no_pleio : single or multiple non-pleiotropic traits, di-allelic.

Constructor & Destructor Documentation

◆ TTQuanti_diallelic_no_pleio() [1/2]

TTQuanti_diallelic_no_pleio::TTQuanti_diallelic_no_pleio ( )
inline
331 : TTQuanti_diallelic() {}
TTQuanti_diallelic()
Definition: ttquanti.h:284

Referenced by clone().

+ Here is the caller graph for this function:

◆ TTQuanti_diallelic_no_pleio() [2/2]

TTQuanti_diallelic_no_pleio::TTQuanti_diallelic_no_pleio ( const TTQuanti_diallelic_no_pleio TT)
inline
333 : TTQuanti_diallelic(TT) {}

◆ ~TTQuanti_diallelic_no_pleio()

virtual TTQuanti_diallelic_no_pleio::~TTQuanti_diallelic_no_pleio ( )
inlinevirtual
335 {}

Member Function Documentation

◆ clone()

virtual TTQuanti_diallelic_no_pleio* TTQuanti_diallelic_no_pleio::clone ( )
inlinevirtual

Implements TTrait.

339 {return new TTQuanti_diallelic_no_pleio(*this);}
TTQuanti_diallelic_no_pleio()
Definition: ttquanti.h:331

References TTQuanti_diallelic_no_pleio().

◆ copy_sequence_1locus()

void TTQuanti_diallelic_no_pleio::copy_sequence_1locus ( sex_t  SEX,
unsigned int  strand,
unsigned int  at,
const TTQuanti parent 
)
inlinevirtual

Implements TTQuanti.

4129 {
4130  const unsigned char *orig = (const unsigned char*)parent->get_sequence()[strand];
4131 
4132  _sequence[SEX][at] = orig[at];
4133 }
unsigned char ** _sequence
Definition: ttquanti.h:321
virtual void ** get_sequence() const =0
sequence accessor.

References TTQuanti_diallelic::_sequence, and TTrait::get_sequence().

◆ copy_sequence_block()

void TTQuanti_diallelic_no_pleio::copy_sequence_block ( sex_t  SEX,
unsigned int  strand,
unsigned int  from_locus,
unsigned int  to_locus,
const TTQuanti parent 
)
inlinevirtual

Implements TTQuanti.

4113 {
4114  const unsigned char *orig = (const unsigned char*)(parent->get_sequence()[strand]);
4115  unsigned char *seq = _sequence[SEX];
4116 
4117  assert(to_locus >= from_locus);
4118 
4119  size_t block_size = (to_locus - from_locus) * _myProto->get_locus_byte_size();
4120 
4121  memcpy(&seq[from_locus], &orig[from_locus], block_size);
4122 
4123 }
size_t get_locus_byte_size()
Definition: ttquanti.h:428
TProtoQuanti * _myProto
Definition: ttquanti.h:106

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_locus_byte_size(), and TTrait::get_sequence().

◆ get_additive_genotype()

double TTQuanti_diallelic_no_pleio::get_additive_genotype ( const unsigned int  trait) const
inlinevirtual

Implements TTQuanti.

4063 {
4064  double genotype = 0;
4065  unsigned int L = _myProto->get_num_locus(trait); //number of loci affecting this trait
4066  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position, all loci contiguous on the map
4067 
4068  if (_myProto->has_equal_effects()) {
4069  const unsigned char* __restrict__ s0 = _sequence[0] + pos;
4070  const unsigned char* __restrict__ s1 = _sequence[1] + pos;
4071  unsigned int n0 = 0, n1 = 0;
4072  for (unsigned int j = 0; j < L; ++j) {
4073  n0 += s0[j]; n1 += s1[j];
4074  }
4075  return 2.0 * L * _myProto->get_equal_val_0()
4076  + (n0 + n1) * _myProto->get_equal_val_diff();
4077  }
4078 
4079  for(unsigned int j = 0; j < L; ++j, ++pos) {
4080  genotype += _myProto->get_seq_diallele_value( pos, _sequence[0][pos] );
4081  genotype += _myProto->get_seq_diallele_value( pos, _sequence[1][pos] );
4082  }
4083 
4084  return genotype;
4085 }
double get_equal_val_diff()
Definition: ttquanti.h:443
double get_seq_diallele_value(unsigned int position, unsigned int allele)
Definition: ttquanti.h:437
bool has_equal_effects()
Definition: ttquanti.h:440
unsigned int get_locus_seq_pos(unsigned int loc, unsigned int trait)
Definition: ttquanti.h:452
double get_equal_val_0()
Definition: ttquanti.h:441
unsigned int get_num_locus()
Definition: ttquanti.h:423

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_equal_val_0(), TProtoQuanti::get_equal_val_diff(), TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_seq_diallele_value(), and TProtoQuanti::has_equal_effects().

◆ get_dominant_genotype()

double TTQuanti_diallelic_no_pleio::get_dominant_genotype ( const unsigned int  trait) const
inlinevirtual

Implements TTQuanti.

4091 {
4092  double genotype = 0;
4093  unsigned int L = _myProto->get_num_locus(trait); //number of loci affecting this trait
4094  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position, all loci contiguous on the map
4095  unsigned int locID;
4096 
4097  for(unsigned int j = 0; j < L; ++j, ++pos) {
4098  locID = _myProto->get_locus_ID(j, trait);
4100  _myProto->get_seq_diallele_value( pos, _sequence[0][pos] ) ,
4101  _myProto->get_seq_diallele_value( pos, _sequence[1][pos] ),
4102  locID,
4103  trait);
4104  }
4105 
4106  return genotype;
4107 }
unsigned int get_locus_ID(unsigned int locus, unsigned int trait)
Definition: ttquanti.h:454
double get_genotype_with_dominance(const double a1, const double a2, const unsigned int locus, const unsigned int trait)
Definition: ttquanti.cc:2538

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_genotype_with_dominance(), TProtoQuanti::get_locus_ID(), TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), and TProtoQuanti::get_seq_diallele_value().

◆ init_sequence()

void TTQuanti_diallelic_no_pleio::init_sequence ( )
inlinevirtual

Implements TTrait.

4138 {
4139  //options:
4140  //0: no variation, all allele are set to allele 0
4141  //1: max variation, randomly set alleles at each locus
4142  //2: no variation and initialize with opposite effect alleles at alternating loci.
4143 
4144 
4145  if (_myProto->get_doInitMutation() == 0){
4146 
4147  // initialize with ancestral allele
4148  memset(_sequence[0], 0, _myProto->get_seq_length()*sizeof(unsigned char));
4149  memset(_sequence[1], 0, _myProto->get_seq_length()*sizeof(unsigned char));
4150 
4151  } else if (_myProto->get_doInitMutation() == 1) {
4152 
4153  for(unsigned int i = 0; i < _myProto->get_num_locus(); ++i) {
4154 
4155  // randomly set the allelic values
4156  _sequence[0][ i ] = RAND::RandBool();
4157  _sequence[1][ i ] = RAND::RandBool();
4158 
4159  }
4160 
4161  } else {
4162  //option 2; polarized di-allelic values; even locus set to +a, odd locus set to -a
4163 
4164  for(unsigned int i = 0; i < _myProto->get_num_locus(); i++) {
4165 
4166  // no need to set to 0 since it was initialized that way
4167  if (i % 2 == 0){
4168  _sequence[0][ i ] = 0;
4169  _sequence[1][ i ] = 0;
4170  }
4171  else { // odd locus
4172  _sequence[1][ i ] = 1;
4173  _sequence[0][ i ] = 1;
4174  }
4175  }
4176  }
4177 
4178 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:164
unsigned int get_seq_length()
Definition: ttquanti.h:426
unsigned int get_doInitMutation()
Definition: ttquanti.h:448

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_doInitMutation(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_seq_length(), and RAND::RandBool().

◆ show_up()

void TTQuanti_diallelic_no_pleio::show_up ( )
virtual

Implements TTrait.

4183 {
4184  message("\
4185  Trait's type: QUANTI (diallelic, no pleiotropy)\n\
4186  traits: %i\n\
4187  loci: %i\n\
4188  seq length: %i\n",_myProto->get_num_traits(),_myProto->get_num_locus()
4189  ,_myProto->get_seq_length());
4190 
4191  for(unsigned int i = 0; i < _myProto->get_num_traits(); i++)
4192  message("phenotype %i: %f\n",i+1,_phenotypes[i]);
4193 
4194  message("genotype:");
4195 
4196  for(unsigned int i = 0; i < _myProto->get_num_traits(); ++i) {
4197 
4198  message("\ntrait %i (%i loci):\nloci: ",i+1, _myProto->get_num_locus(i));
4199 
4200  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
4201  message("%i, ", _myProto->get_locus_ID(j, i));
4202  }
4203 
4204  message("\n[0]: ");
4205 
4206  for(unsigned int j = 0; j < _myProto->get_num_locus(i) && j < 50; ++j) {
4207  message("%.3f,",(double)_sequence[0][ _myProto->get_locus_seq_pos(j, i) ]);
4208  }
4209 
4210  message("\n[1]: ");
4211 
4212  for(unsigned int j = 0; j < _myProto->get_num_locus(i) && j < 50; ++j) {
4213  message("%.3f,",(double)_sequence[1][ _myProto->get_locus_seq_pos(j, i) ]);
4214  }
4215  }
4216 
4217  message("\n");
4218 
4219 }
unsigned int get_num_traits()
Definition: ttquanti.h:422
double * _phenotypes
Definition: ttquanti.h:104
void message(const char *message,...)
Definition: output.cc:39

References TTQuanti::_myProto, TTQuanti::_phenotypes, TTQuanti_diallelic::_sequence, TProtoQuanti::get_locus_ID(), TProtoQuanti::get_locus_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_num_traits(), TProtoQuanti::get_seq_length(), and message().


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

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

Locations of visitors to this page
Catalogued on GSR