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

TTQuanti_diallelic_var_pleio : variable pleiotropic di-allelic loci, max PD = 2. More...

#include <ttquanti.h>

+ Inheritance diagram for TTQuanti_diallelic_var_pleio:
+ Collaboration diagram for TTQuanti_diallelic_var_pleio:

Public Member Functions

 TTQuanti_diallelic_var_pleio ()
 
 TTQuanti_diallelic_var_pleio (const TTQuanti_diallelic_var_pleio &TT)
 
virtual ~TTQuanti_diallelic_var_pleio ()
 
unsigned int get_sequence_block_size (unsigned int from, unsigned int to)
 
virtual void init_sequence ()
 
virtual TTQuanti_diallelic_var_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 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)
 
- 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
 
TProtoQuanti_myProto
 

Detailed Description

TTQuanti_diallelic_var_pleio : variable pleiotropic di-allelic loci, max PD = 2.

Constructor & Destructor Documentation

◆ TTQuanti_diallelic_var_pleio() [1/2]

TTQuanti_diallelic_var_pleio::TTQuanti_diallelic_var_pleio ( )
inline
380 : TTQuanti_diallelic() {}
TTQuanti_diallelic()
Definition: ttquanti.h:280

Referenced by clone().

◆ TTQuanti_diallelic_var_pleio() [2/2]

TTQuanti_diallelic_var_pleio::TTQuanti_diallelic_var_pleio ( const TTQuanti_diallelic_var_pleio TT)
inline
382 : TTQuanti_diallelic(TT) {}

◆ ~TTQuanti_diallelic_var_pleio()

virtual TTQuanti_diallelic_var_pleio::~TTQuanti_diallelic_var_pleio ( )
inlinevirtual
384 {}

Member Function Documentation

◆ clone()

virtual TTQuanti_diallelic_var_pleio* TTQuanti_diallelic_var_pleio::clone ( )
inlinevirtual

Implements TTrait.

390 {return new TTQuanti_diallelic_var_pleio(*this);}
TTQuanti_diallelic_var_pleio()
Definition: ttquanti.h:380

References TTQuanti_diallelic_var_pleio().

◆ copy_sequence_1locus()

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

Implements TTQuanti.

4348 {
4349  const unsigned char *orig = (const unsigned char*)parent->get_sequence()[strand];
4350  unsigned char *seq = _sequence[SEX];
4351  unsigned int from_pos = _myProto->get_locus_start_pos(at);
4352  size_t size = _myProto->get_locus_PD(at) * _myProto->get_size_locus_type();
4353 
4354  memcpy(&seq[from_pos], &orig[from_pos], size);
4355 
4356 }
unsigned int get_locus_PD(unsigned int locus)
Definition: ttquanti.h:444
size_t get_size_locus_type()
Definition: ttquanti.h:422
unsigned int get_locus_start_pos(unsigned int locus)
Definition: ttquanti.h:445
unsigned char ** _sequence
Definition: ttquanti.h:316
TProtoQuanti * _myProto
Definition: ttquanti.h:103
virtual void ** get_sequence() const =0
sequence accessor.

References TTQuanti::_myProto, TTQuanti_diallelic::_sequence, TProtoQuanti::get_locus_PD(), TProtoQuanti::get_locus_start_pos(), TTrait::get_sequence(), and TProtoQuanti::get_size_locus_type().

◆ copy_sequence_block()

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

Implements TTQuanti.

4331 {
4332  assert(to_locus >= from_locus);
4333 
4334  const unsigned char *orig = (const unsigned char*)parent->get_sequence()[strand];
4335  unsigned char *seq = _sequence[SEX];
4336  unsigned int from_pos = _myProto->get_locus_start_pos(from_locus);
4337 
4338  size_t block_size = get_sequence_block_size(from_locus, to_locus);
4339 
4340  memcpy(&seq[from_pos], &orig[from_pos], block_size);
4341 
4342 }
unsigned int get_sequence_block_size(unsigned int from, unsigned int to)
Definition: ttquanti.cc:4314

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

◆ get_additive_genotype()

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

Implements TTQuanti.

4276 {
4277  double genotype = 0;
4278  unsigned int L = _myProto->get_num_locus(trait); //number of loci affecting this trait
4279  unsigned int pos;
4280 
4281  for(unsigned int j = 0; j < L; ++j) {
4282  pos = _myProto->get_locus_seq_pos(j, trait);
4283  genotype += _myProto->get_seq_diallele_value( pos, _sequence[0][pos] );
4284  genotype += _myProto->get_seq_diallele_value( pos, _sequence[1][pos] );
4285  }
4286 
4287  return genotype;
4288 }
double get_seq_diallele_value(unsigned int position, unsigned int allele)
Definition: ttquanti.h:432
unsigned int get_locus_seq_pos(unsigned int loc, unsigned int trait)
Definition: ttquanti.h:440
unsigned int get_num_locus()
Definition: ttquanti.h:418

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

◆ get_dominant_genotype()

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

Implements TTQuanti.

4294 {
4295  double genotype = 0;
4296  unsigned int L = _myProto->get_num_locus(trait); //number of loci affecting this trait
4297  unsigned int pos, locID;
4298 
4299  for(unsigned int j = 0; j < L; ++j) {
4300  pos = _myProto->get_locus_seq_pos(0, trait);
4301  locID = _myProto->get_locus_ID(j, trait);
4303  _myProto->get_seq_diallele_value( pos, _sequence[0][pos] ) ,
4304  _myProto->get_seq_diallele_value( pos, _sequence[1][pos] ),
4305  locID,
4306  trait);
4307  }
4308 
4309  return genotype;
4310 }
unsigned int get_locus_ID(unsigned int locus, unsigned int trait)
Definition: ttquanti.h:442
double get_genotype_with_dominance(const double a1, const double a2, const unsigned int locus, const unsigned int trait)
Definition: ttquanti.cc:2504

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().

◆ get_sequence_block_size()

unsigned int TTQuanti_diallelic_var_pleio::get_sequence_block_size ( unsigned int  from,
unsigned int  to 
)
inline
4315 {
4316  size_t size = 0;
4317  assert(to > from);
4318 
4319  for (unsigned int i = from; i < to; ++i) {
4320 
4321  size += _myProto->get_locus_PD(i) * _myProto->get_size_locus_type(); //multiply PD by size in byte of a locus
4322 
4323  }
4324  return size; //number of values to read in the sequence, each one is a byte
4325 }

References TTQuanti::_myProto, TProtoQuanti::get_locus_PD(), and TProtoQuanti::get_size_locus_type().

Referenced by copy_sequence_block().

◆ init_sequence()

void TTQuanti_diallelic_var_pleio::init_sequence ( )
inlinevirtual

Implements TTrait.

4361 {
4362  //options:
4363  //0: no variation, all alleles are set to 0
4364  //1: max variation, randomly set alleles at each locus
4365  //2: no variation and initialize with opposite effect alleles at alternating loci.
4366 
4367 
4368  if (_myProto->get_doInitMutation() == 0){
4369 
4370  memset(_sequence[0], 0, _myProto->get_seq_length());
4371  memset(_sequence[1], 0, _myProto->get_seq_length());
4372 
4373  } else if (_myProto->get_doInitMutation() == 1) {
4374 
4375  for(unsigned int i = 0; i < _myProto->get_seq_length(); ++i) {
4376 
4377  // randomly set the allelic values
4378  _sequence[0][ i ] = RAND::RandBool();
4379  _sequence[1][ i ] = RAND::RandBool();
4380 
4381  }
4382 
4383  } else {
4384  //option 2; polarized di-allelic values; even locus set to +a, odd locus set to -a
4385 
4386  for(unsigned int t = 0; t < _myProto->get_num_traits(); ++t) {
4387  for(unsigned int i = 0; i < _myProto->get_num_locus(t); i++) { // process trait-wise
4388  // no need to set to 0 since it was initialized that way
4389  if (i % 2 == 0){
4390  _sequence[0][ _myProto->get_locus_seq_pos(i, t) ] = 0; //_myProto->get_allele_value(i, 0); //set with the positive allele value
4391  _sequence[1][ _myProto->get_locus_seq_pos(i, t) ] = 0; //_myProto->get_allele_value(i, 0);
4392  }
4393  else { // odd locus
4394  _sequence[1][ _myProto->get_locus_seq_pos(i, t) ] = 1; // = _myProto->get_allele_value(i, 1); //set with the alternate/negative allele value
4395  _sequence[0][ _myProto->get_locus_seq_pos(i, t) ] = 1; // = _myProto->get_allele_value(i, 1);
4396  }
4397  }
4398  }
4399  }
4400 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:162
unsigned int get_seq_length()
Definition: ttquanti.h:421
unsigned int get_num_traits()
Definition: ttquanti.h:417
unsigned int get_doInitMutation()
Definition: ttquanti.h:436

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

◆ show_up()

void TTQuanti_diallelic_var_pleio::show_up ( )
virtual

Implements TTrait.

4405 {
4406  message("\
4407  Trait's type: QUANTI (diallelic, variable pleiotropy)\n\
4408  traits: %i\n\
4409  loci: %i\n\
4410  seq length: %i\n",_myProto->get_num_traits(),_myProto->get_num_locus()
4411  ,_myProto->get_seq_length());
4412 
4413  for(unsigned int i = 0; i < _myProto->get_num_traits(); i++)
4414  message("phenotype %i: %f\n",i+1,_phenotypes[i]);
4415 
4416  message("genotype:");
4417 
4418  for(unsigned int i = 0; i < _myProto->get_num_traits(); ++i) {
4419 
4420  message("\ntrait %i (%i loci):\nloci: ",i+1, _myProto->get_num_locus(i));
4421 
4422  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
4423  message("%i, ", _myProto->get_locus_ID(j, i));
4424  }
4425 
4426  message("\n[0]: ");
4427 
4428  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
4429  message("%.3f,",(double)_sequence[0][ _myProto->get_locus_seq_pos(j, i) ]);
4430  }
4431 
4432  message("\n[1]: ");
4433 
4434  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
4435  message("%.3f,",(double)_sequence[1][ _myProto->get_locus_seq_pos(j, i) ]);
4436  }
4437  }
4438 
4439  message("\n");
4440 
4441 }
double * _phenotypes
Definition: ttquanti.h:102
void message(const char *message,...)
Definition: output.cc:40

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.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR