Loading [MathJax]/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GeneticMaterial256_16 Class Reference

#include <GeneticMaterial.h>

Public Member Functions

 GeneticMaterial256_16 ()
 
void SetAllele (unsigned int locus, uint32 value, unsigned int Chromo)
 
uint32 GetAllele (unsigned int locus, unsigned int Chromo)
 
void Mutation_3 ()
 
void SetGeneticFlag ()
 
void SetDirectFlag ()
 
int HomozygosityCount ()
 
int HeterozygosityCount ()
 
void UnsetGeneticFlag ()
 
void UnsetDirectFlag ()
 
uint32 GetGeneticFlag ()
 
uint32 GetDirectFlag ()
 
void PrintGenes ()
 
void Recombine (GeneticMaterial256_16 *Gene1, GeneticMaterial256_16 *Gene2)
 
void Initiation (AlleleFreq256_16 *Al)
 

Protected Attributes

unsigned char Chromosome [32]
 

Constructor & Destructor Documentation

◆ GeneticMaterial256_16()

GeneticMaterial256_16::GeneticMaterial256_16 ( )
873  {
874  // ensure zeros in all loci
875  for ( int i = 0; i < 32; i++ ) Chromosome[ i ] = 0;
876 }

References Chromosome.

Member Function Documentation

◆ GetAllele()

uint32 GeneticMaterial256_16::GetAllele ( unsigned int  locus,
unsigned int  Chromo 
)
886  {
887  if (Chromo==1) locus +=16;
888  return (uint32) Chromosome[ locus ];
889 }

References Chromosome.

Referenced by GetDirectFlag(), GetGeneticFlag(), Mutation_3(), and Recombine().

◆ GetDirectFlag()

uint32 GeneticMaterial256_16::GetDirectFlag ( )
936  {
937  return GetAllele(0,1);
938 }

References GetAllele().

◆ GetGeneticFlag()

uint32 GeneticMaterial256_16::GetGeneticFlag ( )
932  {
933  return GetAllele(0,0);
934 }

References GetAllele().

◆ HeterozygosityCount()

int GeneticMaterial256_16::HeterozygosityCount ( )
inline
204 { return 0; } // To add if needed

◆ HomozygosityCount()

int GeneticMaterial256_16::HomozygosityCount ( )
inline
203 { return 0; } // To add if needed

◆ Initiation()

void GeneticMaterial256_16::Initiation ( AlleleFreq256_16 Al)

The method called to intialise genes on initiation of the simulation.
Gene frequencies are based on an external text file input read in on construction.

962  {
963  uint32 value; //, c;
964  for ( int l = 0; l < 16; l++ ) {
965  int chance = g_random_fnc( 1000 );
966  uint32 index = 0;
967  while ( chance >= Al->SupplyAN( l, index ) ) {
968  index++;
969  }
970  value = index;
971  // set the value
972  SetAllele( l, value, 0 );
973  chance = g_random_fnc( 1000 );
974  index = 0;
975  while ( chance >= Al->SupplyAN( l, index ) ) {
976  index++;
977  }
978  value = index;
979  // set the value
980  SetAllele( l, value, 1 );
981  }
982 }

References g_random_fnc(), SetAllele(), and AlleleFreq256_16::SupplyAN().

◆ Mutation_3()

void GeneticMaterial256_16::Mutation_3 ( )

Move one allele one up or down

896 {
897  if (MutationChance != 0){
898  for ( int i = 0; i < 16; i++ ) {
899  if ( g_rand_uni_fnc() < MutationChance ) // one chance in Mutation Chance for the locus
900  {
901  unsigned strand = g_random_fnc( 2 ); // kromosom 0 or 1
902  int allele = GetAllele( i, strand );
903  if ( g_random_fnc( 2 ) == 1 ) allele++; else allele--;
904  //For mutations less than 0 and more than 256 the mutation should result in 1 or g_MaxAllele-1
905  if (allele > g_MaxAllele) allele-=2;
906  else if (allele < 0) allele = 1;
907  SetAllele( i, (uint32) allele, strand );
908  }
909  }
910  }
911 }

References g_MaxAllele, g_rand_uni_fnc(), g_random_fnc(), GetAllele(), MutationChance, and SetAllele().

◆ PrintGenes()

void GeneticMaterial256_16::PrintGenes ( )

◆ Recombine()

void GeneticMaterial256_16::Recombine ( GeneticMaterial256_16 Gene1,
GeneticMaterial256_16 Gene2 
)
941  {
942  // Is called with hers and his genes
943  for ( int i = 0; i < 16; i++ ) {
944  // For each locus
945  // Choose which chromosome for each parent
946  int g0 = g_random_fnc(2);
947  int g1 = g_random_fnc(2);
948  // get the two alleles
949  uint32 a0 = Gene1->GetAllele( i, g0 );
950  uint32 a1 = Gene2->GetAllele( i, g1 );
951  // put a0 into chromo0 & a1 to chromo1 & vice versa
952  SetAllele( i, a0, 0 );
953  SetAllele( i, a1, 1 );
954  }
955 }

References g_random_fnc(), GetAllele(), and SetAllele().

◆ SetAllele()

void GeneticMaterial256_16::SetAllele ( unsigned int  locus,
uint32  value,
unsigned int  Chromo 
)
880  {
881  if (Chromo==1) locus +=16;
882  Chromosome[ locus ] = (unsigned char) value;
883 }

References Chromosome.

Referenced by Initiation(), Mutation_3(), Recombine(), SetDirectFlag(), SetGeneticFlag(), UnsetDirectFlag(), and UnsetGeneticFlag().

◆ SetDirectFlag()

void GeneticMaterial256_16::SetDirectFlag ( )
918  {
919  SetAllele(0,1,1);
920 }

References SetAllele().

◆ SetGeneticFlag()

void GeneticMaterial256_16::SetGeneticFlag ( )
914  {
915  SetAllele(0,1,0);
916 }

References SetAllele().

◆ UnsetDirectFlag()

void GeneticMaterial256_16::UnsetDirectFlag ( )
927  {
928  SetAllele(0,0,1);
929 }

References SetAllele().

◆ UnsetGeneticFlag()

void GeneticMaterial256_16::UnsetGeneticFlag ( )
923  {
924  SetAllele(0,0,0);
925 }

References SetAllele().

Member Data Documentation

◆ Chromosome

unsigned char GeneticMaterial256_16::Chromosome[32]
protected

The documentation for this class was generated from the following files:
g_rand_uni_fnc
double g_rand_uni_fnc()
Definition: ALMaSS_Random.cpp:56
uint32
unsigned int uint32
Definition: ALMaSS_Setup.h:34
AlleleFreq256_16::SupplyAN
int SupplyAN(int loc, int al)
Definition: GeneticMaterial.h:189
GeneticMaterial256_16::SetAllele
void SetAllele(unsigned int locus, uint32 value, unsigned int Chromo)
Definition: GeneticMaterial.cpp:880
GeneticMaterial256_16::Chromosome
unsigned char Chromosome[32]
Definition: GeneticMaterial.h:195
g_MaxAllele
unsigned char g_MaxAllele
Definition: GeneticMaterial.cpp:50
MutationChance
double MutationChance
Definition: GeneticMaterial.cpp:49
GeneticMaterial256_16::GetAllele
uint32 GetAllele(unsigned int locus, unsigned int Chromo)
Definition: GeneticMaterial.cpp:886
g_random_fnc
int g_random_fnc(const int a_range)
Definition: ALMaSS_Random.cpp:74