Nemo  2.4.1
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.

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

4111 {
4112  const unsigned char *orig = (const unsigned char*)(parent->get_sequence()[strand]);
4113  unsigned char *seq = _sequence[SEX];
4114 
4115  assert(to_locus >= from_locus);
4116 
4117  size_t block_size = (to_locus - from_locus) * _myProto->get_locus_byte_size();
4118 
4119  memcpy(&seq[from_locus], &orig[from_locus], block_size);
4120 
4121 }
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.

4061 {
4062  double genotype = 0;
4063  unsigned int L = _myProto->get_num_locus(trait); //number of loci affecting this trait
4064  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position, all loci contiguous on the map
4065 
4066  if (_myProto->has_equal_effects()) {
4067  const unsigned char* __restrict__ s0 = _sequence[0] + pos;
4068  const unsigned char* __restrict__ s1 = _sequence[1] + pos;
4069  unsigned int n0 = 0, n1 = 0;
4070  for (unsigned int j = 0; j < L; ++j) {
4071  n0 += s0[j]; n1 += s1[j];
4072  }
4073  return 2.0 * L * _myProto->get_equal_val_0()
4074  + (n0 + n1) * _myProto->get_equal_val_diff();
4075  }
4076 
4077  for(unsigned int j = 0; j < L; ++j, ++pos) {
4078  genotype += _myProto->get_seq_diallele_value( pos, _sequence[0][pos] );
4079  genotype += _myProto->get_seq_diallele_value( pos, _sequence[1][pos] );
4080  }
4081 
4082  return genotype;
4083 }
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.

4089 {
4090  double genotype = 0;
4091  unsigned int L = _myProto->get_num_locus(trait); //number of loci affecting this trait
4092  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position, all loci contiguous on the map
4093  unsigned int locID;
4094 
4095  for(unsigned int j = 0; j < L; ++j, ++pos) {
4096  locID = _myProto->get_locus_ID(j, trait);
4098  _myProto->get_seq_diallele_value( pos, _sequence[0][pos] ) ,
4099  _myProto->get_seq_diallele_value( pos, _sequence[1][pos] ),
4100  locID,
4101  trait);
4102  }
4103 
4104  return genotype;
4105 }
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.

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

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

Catalogued on GSR