Skip to content

Commit

Permalink
Vector Migration by Alleles (Genetics-based vector migration)
Browse files Browse the repository at this point in the history
Implemented Vector Migration by Alleles. Vectors can now have different migration rates depending on their alleles. Please see emodpy-malaria vector migration documentation for more details. 

Co-authored-by: Daniel Bridenbecker <[email protected]>
stitova-idm and Bridenbecker authored Dec 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 066bcfd commit ff0669f
Showing 212 changed files with 2,418,823 additions and 2,385,723 deletions.
49 changes: 27 additions & 22 deletions Eradication/GeneticProbability.cpp
Original file line number Diff line number Diff line change
@@ -242,6 +242,32 @@ namespace Kernel
return !operator==( rThat );
}

bool AlleleCombo::Compare( const AlleleCombo& rLeft, const AlleleCombo& rRight )
{
if( rLeft.GetNumLoci() < rRight.GetNumLoci() )
{
return true;
}
else if( rLeft.GetNumLoci() > rRight.GetNumLoci() )
{
return false;
}
else
{
if( rLeft.GetNumPossibleGenomes() == rRight.GetNumPossibleGenomes() )
{
// If they have the same number of possible genomes, we need some way to sort them so that the order
// is more consistent. For example, we always want (a1,*) to come after (a0,*).
return ( rLeft.GetPossibleGenome( 0 ) < rRight.GetPossibleGenome( 0 ) );
}
else
{
// more possible genomes means more options so less specificity
return ( rLeft.GetNumPossibleGenomes() > rRight.GetNumPossibleGenomes() );
}
}
}

bool AlleleCombo::IsNull() const
{
return (m_pAlleleCombo == nullptr);
@@ -1216,28 +1242,7 @@ namespace Kernel

bool GeneticProbability::compareACP( const AlleleComboProbability& rLeft, const AlleleComboProbability& rRight )
{
if( rLeft.GetAlleleCombo().GetNumLoci() < rRight.GetAlleleCombo().GetNumLoci() )
{
return true;
}
else if( rLeft.GetAlleleCombo().GetNumLoci() > rRight.GetAlleleCombo().GetNumLoci() )
{
return false;
}
else
{
if( rLeft.GetAlleleCombo().GetNumPossibleGenomes() == rRight.GetAlleleCombo().GetNumPossibleGenomes() )
{
// If they have the same number of possible genomes, we need some way to sort them so that the orde
// is more consistent. For example, we always want (a1,*) to come after (a0,*).
return (rLeft.GetAlleleCombo().GetPossibleGenome( 0 ) < rRight.GetAlleleCombo().GetPossibleGenome( 0 ));
}
else
{
// more possible genomes means more options so less specificity
return (rLeft.GetAlleleCombo().GetNumPossibleGenomes() > rRight.GetAlleleCombo().GetNumPossibleGenomes());
}
}
return rLeft.GetAlleleCombo().Compare( rLeft.GetAlleleCombo(), rRight.GetAlleleCombo());
}

float GeneticProbability::AdditionOperation( float lhs, float rhs )
3 changes: 2 additions & 1 deletion Eradication/GeneticProbability.h
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ namespace Kernel

bool operator==( const AlleleCombo& rThat ) const;
bool operator!=( const AlleleCombo& rThat ) const;
static bool Compare( const AlleleCombo& rLeft, const AlleleCombo& rRight );

bool IsNull() const;
int GetSpeciesIndex() const;
@@ -84,7 +85,7 @@ namespace Kernel
};

// AlleleComboProbability is the combination of an AlleleCombo and a single probability value.
// This is basically the collction of genomes with this specific probability.
// This is basically the collection of genomes with this specific probability.
class AlleleComboProbability
{
public:
8 changes: 4 additions & 4 deletions Eradication/IMigrationInfo.cpp
Original file line number Diff line number Diff line change
@@ -51,9 +51,8 @@ namespace Kernel
// --- We have to get these via the global because we are now creating this
// --- when we are creating VectorSpeciesParameters
// -------------------------------------------------------------------------
bool use_default_demog = false;
int default_torus_size = 0;
bool enable_vector_migration = true; // true so we create the factor with the schema parameters
bool use_default_demog = false;
int default_torus_size = 0;

if( GET_CONFIGURABLE( SimulationConfig ) != nullptr )
{
@@ -65,11 +64,12 @@ namespace Kernel
if( use_default_demog )
{
release_assert( default_torus_size >= 3 ); // 3 is minimum allowabled Default_Geography_Torus_Size
bool enable_vector_migration = true; // true so we create the factor with the schema parameters
p_mifv = new MigrationInfoFactoryVectorDefault( enable_vector_migration, default_torus_size );
}
else
{
p_mifv = new MigrationInfoFactoryVector( enable_vector_migration );
p_mifv = new MigrationInfoFactoryVector();
}
p_mifv->ReadConfiguration( pParent, config );
return p_mifv;
10 changes: 9 additions & 1 deletion Eradication/IMigrationInfoVector.h
Original file line number Diff line number Diff line change
@@ -5,11 +5,14 @@
#include "IMigrationInfo.h"
#include "SimulationEnums.h"
#include "VectorEnums.h"
#include "VectorGenome.h"
#include "IVectorCohort.h"


namespace Kernel
{
struct IVectorSimulationContext;
class VectorGeneCollection;

// Extend the IMigrationInfo interface to support migrating vectors
struct IMigrationInfoVector : virtual IMigrationInfo
@@ -22,6 +25,9 @@ namespace Kernel
const std::string& rSpeciesID,
IVectorSimulationContext* pivsc ) = 0;
virtual Gender::Enum ConvertVectorGender( VectorGender::Enum vector_gender ) const = 0;
virtual const std::vector<float>* GetFractionTraveling( const IVectorCohort* this_vector ) = 0;
virtual bool MightTravel( VectorGender::Enum vector_gender ) = 0;
virtual bool IsMigrationByAlleles() = 0;
};

struct IMigrationInfoFactoryVector
@@ -32,6 +38,8 @@ namespace Kernel
const ::Configuration* config ) = 0;
virtual IMigrationInfoVector* CreateMigrationInfoVector( const std::string& idreference,
INodeContext *parent_node,
const boost::bimap<ExternalNodeId_t, suids::suid>& rNodeIdSuidMap ) = 0;
const boost::bimap<ExternalNodeId_t, suids::suid>& rNodeIdSuidMap,
int speciesIndex,
const VectorGeneCollection* pGenes ) = 0;
};
}
2 changes: 1 addition & 1 deletion Eradication/Insecticides.cpp
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ namespace Kernel
float modifier_blocking = 1.0f;
float modifier_killing = 1.0f;

initConfigTypeMap( "Allele_Combinations", &combo_strings, Insecticide_Allele_Combinations_DESC_TEXT, constraint_schema, allowed_values );
initConfigTypeMap( "Allele_Combinations", &combo_strings, Insecticide_Allele_Combinations_DESC_TEXT, constraint_schema, allowed_values );
initConfigTypeMap( "Larval_Killing_Modifier", &modifier_larval, Insecticide_Larval_Killing_Modifier_DESC_TEXT, 0.0f, FLT_MAX, 1.0f );
initConfigTypeMap( "Repelling_Modifier", &modifier_repelling, Insecticide_Repelling_Modifier_DESC_TEXT, 0.0f, FLT_MAX, 1.0f );
initConfigTypeMap( "Blocking_Modifier", &modifier_blocking, Insecticide_Blocking_Modifier_DESC_TEXT, 0.0f, FLT_MAX, 1.0f );
Loading

0 comments on commit ff0669f

Please sign in to comment.