Nemo  2.4.2
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
330 : TTQuanti_diallelic() {}
TTQuanti_diallelic()
Definition: ttquanti.h:283

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
332 : TTQuanti_diallelic(TT) {}

◆ ~TTQuanti_diallelic_no_pleio()

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

Member Function Documentation

◆ clone()

virtual TTQuanti_diallelic_no_pleio* TTQuanti_diallelic_no_pleio::clone ( )
inlinevirtual

Implements TTrait.

338 {return new TTQuanti_diallelic_no_pleio(*this);}
TTQuanti_diallelic_no_pleio()
Definition: ttquanti.h:330

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.

4126 {
4127  const unsigned char *orig = (const unsigned char*)parent->get_sequence()[strand];
4128 
4129  _sequence[SEX][at] = orig[at];
4130 }
unsigned char ** _sequence
Definition: ttquanti.h:320
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.

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

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.

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

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.

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

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.

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

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.

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

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.2 by  doxygen 1.9.1

Catalogued on GSR