ALMaSS Vole ODDox  1.1
The vole model description following ODdox protocol
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]
 

Detailed Description

Definition at line 192 of file GeneticMaterial.h.

Constructor & Destructor Documentation

◆ GeneticMaterial256_16()

GeneticMaterial256_16::GeneticMaterial256_16 ( )

Definition at line 876 of file GeneticMaterial.cpp.

876  {
877  // ensure zeros in all loci
878  for ( int i = 0; i < 32; i++ ) Chromosome[ i ] = 0;
879 }

References Chromosome.

Member Function Documentation

◆ GetAllele()

uint32 GeneticMaterial256_16::GetAllele ( unsigned int  locus,
unsigned int  Chromo 
)

Definition at line 889 of file GeneticMaterial.cpp.

889  {
890  if (Chromo==1) locus +=16;
891  return (uint32) Chromosome[ locus ];
892 }

References Chromosome.

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

◆ GetDirectFlag()

uint32 GeneticMaterial256_16::GetDirectFlag ( )

Definition at line 939 of file GeneticMaterial.cpp.

939  {
940  return GetAllele(0,1);
941 }

References GetAllele().

◆ GetGeneticFlag()

uint32 GeneticMaterial256_16::GetGeneticFlag ( )

Definition at line 935 of file GeneticMaterial.cpp.

935  {
936  return GetAllele(0,0);
937 }

References GetAllele().

◆ HeterozygosityCount()

int GeneticMaterial256_16::HeterozygosityCount ( )
inline

Definition at line 204 of file GeneticMaterial.h.

204 { return 0; } // To add if needed

◆ HomozygosityCount()

int GeneticMaterial256_16::HomozygosityCount ( )
inline

Definition at line 203 of file GeneticMaterial.h.

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.

Definition at line 965 of file GeneticMaterial.cpp.

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

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

◆ Mutation_3()

void GeneticMaterial256_16::Mutation_3 ( )

Move one allele one up or down

Definition at line 898 of file GeneticMaterial.cpp.

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

References g_MaxAllele, g_rand_uni, GetAllele(), MutationChance, and SetAllele().

◆ PrintGenes()

void GeneticMaterial256_16::PrintGenes ( )

◆ Recombine()

void GeneticMaterial256_16::Recombine ( GeneticMaterial256_16 Gene1,
GeneticMaterial256_16 Gene2 
)

Definition at line 944 of file GeneticMaterial.cpp.

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

References GetAllele(), and SetAllele().

◆ SetAllele()

void GeneticMaterial256_16::SetAllele ( unsigned int  locus,
uint32  value,
unsigned int  Chromo 
)

Definition at line 883 of file GeneticMaterial.cpp.

883  {
884  if (Chromo==1) locus +=16;
885  Chromosome[ locus ] = (unsigned char) value;
886 }

References Chromosome.

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

◆ SetDirectFlag()

void GeneticMaterial256_16::SetDirectFlag ( )

Definition at line 921 of file GeneticMaterial.cpp.

921  {
922  SetAllele(0,1,1);
923 }

References SetAllele().

◆ SetGeneticFlag()

void GeneticMaterial256_16::SetGeneticFlag ( )

Definition at line 917 of file GeneticMaterial.cpp.

917  {
918  SetAllele(0,1,0);
919 }

References SetAllele().

◆ UnsetDirectFlag()

void GeneticMaterial256_16::UnsetDirectFlag ( )

Definition at line 930 of file GeneticMaterial.cpp.

930  {
931  SetAllele(0,0,1);
932 }

References SetAllele().

◆ UnsetGeneticFlag()

void GeneticMaterial256_16::UnsetGeneticFlag ( )

Definition at line 926 of file GeneticMaterial.cpp.

926  {
927  SetAllele(0,0,0);
928 }

References SetAllele().

Member Data Documentation

◆ Chromosome

unsigned char GeneticMaterial256_16::Chromosome[32]
protected

Definition at line 195 of file GeneticMaterial.h.

Referenced by GeneticMaterial256_16(), GetAllele(), and SetAllele().


The documentation for this class was generated from the following files:
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:883
GeneticMaterial256_16::Chromosome
unsigned char Chromosome[32]
Definition: GeneticMaterial.h:195
g_MaxAllele
unsigned char g_MaxAllele
Definition: GeneticMaterial.cpp:53
MutationChance
double MutationChance
Definition: GeneticMaterial.cpp:52
g_rand_uni
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
GeneticMaterial256_16::GetAllele
uint32 GetAllele(unsigned int locus, unsigned int Chromo)
Definition: GeneticMaterial.cpp:889