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

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

#include <ttquanti.h>

+ Inheritance diagram for TTQuanti_diallelic_full_pleio:
+ Collaboration diagram for TTQuanti_diallelic_full_pleio:

Public Member Functions

 TTQuanti_diallelic_full_pleio ()
 
 TTQuanti_diallelic_full_pleio (const TTQuanti_diallelic_full_pleio &TT)
 
virtual ~TTQuanti_diallelic_full_pleio ()
 
virtual void init_sequence ()
 
virtual TTQuanti_diallelic_full_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_full_pleio : pleiotropic di-allelic loci, max PD = 2.

Constructor & Destructor Documentation

◆ TTQuanti_diallelic_full_pleio() [1/2]

TTQuanti_diallelic_full_pleio::TTQuanti_diallelic_full_pleio ( )
inline
353 : TTQuanti_diallelic() {}
TTQuanti_diallelic()
Definition: ttquanti.h:280

Referenced by clone().

◆ TTQuanti_diallelic_full_pleio() [2/2]

TTQuanti_diallelic_full_pleio::TTQuanti_diallelic_full_pleio ( const TTQuanti_diallelic_full_pleio TT)
inline
355 : TTQuanti_diallelic(TT) {}

◆ ~TTQuanti_diallelic_full_pleio()

virtual TTQuanti_diallelic_full_pleio::~TTQuanti_diallelic_full_pleio ( )
inlinevirtual
357 {}

Member Function Documentation

◆ clone()

virtual TTQuanti_diallelic_full_pleio* TTQuanti_diallelic_full_pleio::clone ( )
inlinevirtual

Implements TTrait.

361 {return new TTQuanti_diallelic_full_pleio(*this);}
TTQuanti_diallelic_full_pleio()
Definition: ttquanti.h:353

References TTQuanti_diallelic_full_pleio().

◆ copy_sequence_1locus()

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

Implements TTQuanti.

4181 {
4182  const unsigned char *orig = (const unsigned char*)parent->get_sequence()[strand];
4183  unsigned char *seq = _sequence[SEX];
4184  unsigned int from_pos = at * _myProto->get_num_traits();
4185 
4186  memcpy(&seq[from_pos], &orig[from_pos], _myProto->get_locus_byte_size());
4187 }
size_t get_locus_byte_size()
Definition: ttquanti.h:423
unsigned int get_num_traits()
Definition: ttquanti.h:417
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_byte_size(), TProtoQuanti::get_num_traits(), and TTrait::get_sequence().

◆ copy_sequence_block()

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

Implements TTQuanti.

4165 {
4166  assert(to_locus >= from_locus);
4167 
4168  const unsigned char* orig = (const unsigned char*)parent->get_sequence()[strand];
4169  unsigned char* seq = _sequence[SEX];
4170  unsigned int from_pos = from_locus * _myProto->get_num_traits();
4171 
4172  size_t block_size = (to_locus - from_locus) * _myProto->get_locus_byte_size();
4173 
4174  memcpy(&seq[from_pos], &orig[from_pos], block_size);
4175 }

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

◆ get_additive_genotype()

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

Implements TTQuanti.

4125 {
4126  double genotype = 0;
4127  unsigned int L = _myProto->get_num_locus(); //number of loci
4128  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position, all loci contiguous on the map
4129 
4130  for(unsigned int j = 0; j < L; ++j) {
4131  genotype += _myProto->get_seq_diallele_value( pos, _sequence[0][pos] );
4132  genotype += _myProto->get_seq_diallele_value( pos, _sequence[1][pos] );
4133  pos += _myProto->get_num_traits(); // stride size on the genome (all loci affect each trait)
4134  }
4135 
4136  return genotype;
4137 }
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(), TProtoQuanti::get_num_traits(), and TProtoQuanti::get_seq_diallele_value().

◆ get_dominant_genotype()

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

Implements TTQuanti.

4143 {
4144  double genotype = 0;
4145  unsigned int L = _myProto->get_num_locus(); //number of loci
4146  unsigned int pos = _myProto->get_locus_seq_pos(0, trait); //starting position,
4147 
4148 
4149  for(unsigned int j = 0; j < L; ++j) {
4151  _myProto->get_seq_diallele_value( pos, _sequence[0][pos] ),
4152  _myProto->get_seq_diallele_value( pos, _sequence[1][pos] ),
4153  j,
4154  trait);
4155  pos += _myProto->get_num_traits(); // stride size on the genome (all loci affect each trait)
4156  }
4157 
4158  return genotype;
4159 }
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_seq_pos(), TProtoQuanti::get_num_locus(), TProtoQuanti::get_num_traits(), and TProtoQuanti::get_seq_diallele_value().

◆ init_sequence()

void TTQuanti_diallelic_full_pleio::init_sequence ( )
inlinevirtual

Implements TTrait.

4192 {
4193  //options:
4194  //0: no variation, all alleles set to 0
4195  //1: max variation, randomly set alleles at each locus
4196  //2: no variation and initialize with opposite effect alleles at alternating loci.
4197 
4198  // option 0; check which allele index needs to be set from init value matrix
4199  if (_myProto->get_doInitMutation() == 0){
4200 
4201  memset(_sequence[0], 0, _myProto->get_seq_length());
4202  memset(_sequence[1], 0, _myProto->get_seq_length());
4203 
4204  // option 1: random allele at each position
4205  } else if (_myProto->get_doInitMutation() == 1) {
4206 
4207  for(unsigned int i = 0; i < _myProto->get_seq_length(); ++i) {
4208 
4209  // randomly set the allelic values
4210  _sequence[0][ i ] = RAND::RandBool();
4211  _sequence[1][ i ] = RAND::RandBool();
4212 
4213  }
4214 
4215  } else {
4216  //option 2; polarized di-allelic values; even locus set to +a, odd locus set to -a
4217 
4218  for(unsigned int t = 0; t < _myProto->get_num_traits(); ++t) {
4219  for(unsigned int i = 0; i < _myProto->get_num_locus(t); i++) { // process trait-wise
4220  // even locus
4221  if (i % 2 == 0){
4222  _sequence[0][ _myProto->get_locus_seq_pos(i, t) ] = 0; //_myProto->get_allele_value(i, 0); //set with the positive allele value
4223  _sequence[1][ _myProto->get_locus_seq_pos(i, t) ] = 0; //_myProto->get_allele_value(i, 0);
4224  }
4225  else { // odd locus
4226  _sequence[1][ _myProto->get_locus_seq_pos(i, t) ] = 1; // = _myProto->get_allele_value(i, 1); //set with the alternate/negative allele value
4227  _sequence[0][ _myProto->get_locus_seq_pos(i, t) ] = 1; // = _myProto->get_allele_value(i, 1);
4228  }
4229  }
4230 
4231  }
4232  }
4233 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:162
unsigned int get_seq_length()
Definition: ttquanti.h:421
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_full_pleio::show_up ( )
virtual

Implements TTrait.

4238 {
4239  message("\
4240  Trait's type: QUANTI (diallelic, full pleiotropy)\n\
4241  traits: %i\n\
4242  loci: %i\n\
4243  seq length: %i\n",_myProto->get_num_traits(),_myProto->get_num_locus()
4244  ,_myProto->get_seq_length());
4245 
4246  for(unsigned int i = 0; i < _myProto->get_num_traits(); i++)
4247  message("phenotype %i: %f\n",i+1,_phenotypes[i]);
4248 
4249  message("_sequence:");
4250 
4251  for(unsigned int i = 0; i < _myProto->get_num_traits(); ++i) {
4252 
4253  message("\nt%i (%i loci):\n[0]: ",i+1, _myProto->get_num_locus(i));
4254 
4255  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
4256  message("%.3f,",(double)_sequence[0][ _myProto->get_locus_seq_pos(j, i) ]);
4257  }
4258 
4259  message("\n[1]: ");
4260 
4261  for(unsigned int j = 0; j < _myProto->get_num_locus(i); ++j) {
4262  message("%.3f,",(double)_sequence[1][ _myProto->get_locus_seq_pos(j, i) ]);
4263  }
4264  }
4265 
4266  message("\n");
4267 
4268 }
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_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