Skip to content

Commit

Permalink
add elimination support for nUncomp
Browse files Browse the repository at this point in the history
  • Loading branch information
acavelan committed Jun 26, 2024
1 parent 5489678 commit a3a8194
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 33 deletions.
9 changes: 9 additions & 0 deletions model/Clinical/Episode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Clinical/Episode.h"
#include "Clinical/ClinicalModel.h"
#include "Host/Human.h"
#include "Host/WithinHost/WHInterface.h"

namespace OM {
namespace Clinical {
Expand All @@ -40,6 +41,8 @@ void Episode::flush() {
void Episode::update (const Host::Human& human, Episode::State newState)
{
if( time + ClinicalModel::hsMemory() <= sim::ts0() ){
infectionType = human.withinHostModel->getInfectionType();

report ();

time = sim::ts0();
Expand All @@ -66,6 +69,12 @@ void Episode::report () {
}
} else { // UC or UC2
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES, surveyPeriod, ageGroup, cohortSet, 1 );
if(infectionType == WithinHost::InfectionOrigin::Indigenous)
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES_INDIGENOUS, surveyPeriod, ageGroup, cohortSet, 1 );
else if(infectionType == WithinHost::InfectionOrigin::Introduced)
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES_INTRODUCED, surveyPeriod, ageGroup, cohortSet, 1 );
else
mon::reportMSACI( mon::MHE_UNCOMPLICATED_EPISODES_IMPORTED, surveyPeriod, ageGroup, cohortSet, 1 );
}

// Report outcomes of malarial fevers
Expand Down
3 changes: 3 additions & 0 deletions model/Clinical/Episode.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "Global.h"
#include "Host/WithinHost/Pathogenesis/State.h"
#include "Host/WithinHost/Infection/Infection.h"
#include "mon/AgeGroup.h"
#include "mon/info.h"
#include <ostream>
Expand Down Expand Up @@ -112,6 +113,8 @@ class Episode{
/// Descriptor of state, containing reporting info. Not all information will
/// be reported (e.g. indirect deaths are reported independantly).
Episode::State state;

WithinHost::InfectionOrigin infectionType = WithinHost::InfectionOrigin::Indigenous;

private:
/** Report a clinical episode.
Expand Down
25 changes: 16 additions & 9 deletions model/Host/WithinHost/CommonWithinHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,30 @@ void CommonWithinHost::update(Host::Human &human, LocalRng& rng, int &nNewInfs_i
m_y_lag_l[y_lag_i * Genotypes::N() + g] = 0.0;
}

int nImported = 0, nIntroduced = 0, nIndigenous = 0;
for( auto inf = infections.begin(); inf != infections.end(); ++inf )
{
if((*inf)->origin() == InfectionOrigin::Imported)
m_y_lag_i[y_lag_i * Genotypes::N() + (*inf)->genotype()] += (*inf)->getDensity();
else
m_y_lag_l[y_lag_i * Genotypes::N() + (*inf)->genotype()] += (*inf)->getDensity();

if((*inf)->origin() == InfectionOrigin::Indigenous) nIndigenous++;
else if((*inf)->origin() == InfectionOrigin::Introduced) nIntroduced++;
else nImported++;
}

/* The rules are:
- Imported only if all infections are imported
- Introduced if at least one Introduced
- Indigenous otherwise (Imported + Indigenous or just Indigenous infections) */
if(nIntroduced > 0)
infectionType = InfectionOrigin::Introduced;
else if(nIndigenous > 0)
infectionType = InfectionOrigin::Indigenous;
else
infectionType = InfectionOrigin::Imported;

// This is a bug, we keep it this way to be consistent with old simulations
if(nNewInfsIgnored > 0)
nNewInfs_l += nNewInfsIgnored;
Expand All @@ -294,16 +310,7 @@ bool CommonWithinHost::summarize( Host::Human& human )const{
pkpdModel.summarize( human );

// If the number of infections is 0 and parasite density is positive we default to Indigenous
InfectionOrigin infectionType = InfectionOrigin::Indigenous;
if( infections.size() > 0 ){
int nImported = 0, nIntroduced = 0, nIndigenous = 0;
for(const auto infection : infections)
{
if(infection->origin() == InfectionOrigin::Indigenous) nIndigenous++;
else if(infection->origin() == InfectionOrigin::Introduced) nIntroduced++;
else nImported++;
}

mon::reportStatMHI( mon::MHR_INFECTED_HOSTS, human, 1 );
if(infectionType == InfectionOrigin::Indigenous)
mon::reportStatMHI( mon::MHR_INFECTED_HOSTS_INDIGENOUS, human, 1 );
Expand Down
46 changes: 25 additions & 21 deletions model/Host/WithinHost/DescriptiveWithinHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void DescriptiveWithinHostModel::update(Host::Human &human, LocalRng& rng, int &

bool treatmentLiver = treatExpiryLiver > sim::ts0();
bool treatmentBlood = treatExpiryBlood > sim::ts0();

for(auto inf = infections.begin(); inf != infections.end();) {
//NOTE: it would be nice to combine this code with that in
// CommonWithinHost.cpp, but a few changes would be needed:
Expand Down Expand Up @@ -207,14 +207,30 @@ void DescriptiveWithinHostModel::update(Host::Human &human, LocalRng& rng, int &
m_y_lag_l[y_lag_i * Genotypes::N() + g] = 0.0;
}

int nImported = 0, nIntroduced = 0, nIndigenous = 0;
for( auto inf = infections.begin(); inf != infections.end(); ++inf )
{
if(inf->origin() == InfectionOrigin::Imported)
m_y_lag_i[y_lag_i * Genotypes::N() + inf->genotype()] += inf->getDensity();
else
m_y_lag_l[y_lag_i * Genotypes::N() + inf->genotype()] += inf->getDensity();

if(inf->origin() == InfectionOrigin::Indigenous) nIndigenous++;
else if(inf->origin() == InfectionOrigin::Introduced) nIntroduced++;
else nImported++;
}

/* The rules are:
- Imported only if all infections are imported
- Introduced if at least one Introduced
- Indigenous otherwise (Imported + Indigenous or just Indigenous infections) */
if(nIntroduced > 0)
infectionType = InfectionOrigin::Introduced;
else if(nIndigenous > 0)
infectionType = InfectionOrigin::Indigenous;
else
infectionType = InfectionOrigin::Imported;

// This is a bug, we keep it this way to be consistent with old simulations
if(opt_vaccine_genotype == false)
{
Expand All @@ -230,27 +246,7 @@ bool DescriptiveWithinHostModel::summarize( Host::Human& human )const{
pathogenesisModel->summarize( human );

// If the number of infections is 0 and parasite density is positive we default to Indigenous
InfectionOrigin infectionType = InfectionOrigin::Indigenous;
if( infections.size() > 0 ){
int nImported = 0, nIntroduced = 0, nIndigenous = 0;
for(const auto& infection : infections)
{
if(infection.origin() == InfectionOrigin::Indigenous) nIndigenous++;
else if(infection.origin() == InfectionOrigin::Introduced) nIntroduced++;
else nImported++;
}

/* The rules are:
- Imported only if all infections are imported
- Introduced if at least one Introduced
- Indigenous otherwise (Imported + Indigenous or just Indigenous infections) */
if(nIntroduced > 0)
infectionType = InfectionOrigin::Introduced;
else if(nIndigenous > 0)
infectionType = InfectionOrigin::Indigenous;
else
infectionType = InfectionOrigin::Imported;

mon::reportStatMHI( mon::MHR_INFECTED_HOSTS, human, 1 );
if(infectionType == InfectionOrigin::Indigenous)
mon::reportStatMHI( mon::MHR_INFECTED_HOSTS_INDIGENOUS, human, 1 );
Expand All @@ -259,6 +255,14 @@ bool DescriptiveWithinHostModel::summarize( Host::Human& human )const{
else
reportStatMHI( mon::MHR_INFECTED_HOSTS_IMPORTED, human, 1 );

int nImported = 0, nIntroduced = 0, nIndigenous = 0;
for( auto inf = infections.begin(); inf != infections.end(); ++inf )
{
if(inf->origin() == InfectionOrigin::Indigenous) nIndigenous++;
else if(inf->origin() == InfectionOrigin::Introduced) nIntroduced++;
else nImported++;
}

// (patent) infections are reported by genotype, even though we don't have
// genotype in this model
mon::reportStatMHGI( mon::MHR_INFECTIONS, human, 0, infections.size() );
Expand Down
6 changes: 6 additions & 0 deletions model/Host/WithinHost/WHFalciparum.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class WHFalciparum : public WHInterface {

virtual Pathogenesis::StatePair determineMorbidity( Host::Human& human, double ageYears, bool isDoomed );

virtual InfectionOrigin getInfectionType() const {
return infectionType;
}

inline double getCumulative_h() const {
return m_cumulative_h;
}
Expand Down Expand Up @@ -136,6 +140,8 @@ class WHFalciparum : public WHInterface {

/// End of step on which treatment expires = start of first step after expiry
SimTime treatExpiryLiver, treatExpiryBlood;

InfectionOrigin infectionType = InfectionOrigin::Indigenous;

virtual void checkpoint (istream& stream);
virtual void checkpoint (ostream& stream);
Expand Down
4 changes: 4 additions & 0 deletions model/Host/WithinHost/WHInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "util/random.h"
#include "Host/WithinHost/Diagnostic.h"
#include "Host/WithinHost/Pathogenesis/State.h"
#include "Host/WithinHost/Infection/Infection.h"

#include "Parameters.h"

using namespace std;
Expand Down Expand Up @@ -192,6 +194,8 @@ class WHInterface {
virtual double getCumulative_h() const =0;
virtual double getCumulative_Y() const =0;

virtual InfectionOrigin getInfectionType() const =0;

/** The maximum number of infections a human can have. The only real reason
* for this limit is to prevent incase bad input from causing the number of
* infections to baloon stupidly.
Expand Down
4 changes: 4 additions & 0 deletions model/Host/WithinHost/WHVivax.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class WHVivax : public WHInterface {
virtual Pathogenesis::StatePair determineMorbidity( Host::Human& human, double ageYears, bool );

virtual void clearImmunity();

virtual InfectionOrigin getInfectionType() const {
return InfectionOrigin::Indigenous;
}

protected:
virtual void treatment( Host::Human& human, TreatmentId treatId );
Expand Down
6 changes: 4 additions & 2 deletions model/mon/OutputMeasures.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,10 @@ void defineOutMeasures(){
/// number of blood-stage treatments (inpatient)
namedOutMeasures["nTreatments3"] = OutMeasure::humanAC( 13, MHT_TREATMENTS_3, false );
/// number of episodes (uncomplicated)
namedOutMeasures["nUncomp"] =
OutMeasure::humanAC( 14, MHE_UNCOMPLICATED_EPISODES, false );
namedOutMeasures["nUncomp"] = OutMeasure::humanAC( 14, MHE_UNCOMPLICATED_EPISODES, false );
namedOutMeasures["nUncomp_Imported"] = OutMeasure::humanAC( 1014, MHE_UNCOMPLICATED_EPISODES_IMPORTED, false );
namedOutMeasures["nUncomp_Introduced"] = OutMeasure::humanAC( 2014, MHE_UNCOMPLICATED_EPISODES_INTRODUCED, false );
namedOutMeasures["nUncomp_Indigenous"] = OutMeasure::humanAC( 3014, MHE_UNCOMPLICATED_EPISODES_INDIGENOUS, false );
/// Number of severe episodes (severe malaria or malaria + coinfection)
namedOutMeasures["nSevere"] =
OutMeasure::humanAC( 15, MHE_SEVERE_EPISODES, false );
Expand Down
2 changes: 1 addition & 1 deletion model/mon/reporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum Measure{

// ——— MHE: measures for human episodes (integers) ———
// Number of uncomplicated fever episodes in humans. Units: cases
MHE_UNCOMPLICATED_EPISODES,
MHE_UNCOMPLICATED_EPISODES, MHE_UNCOMPLICATED_EPISODES_IMPORTED, MHE_UNCOMPLICATED_EPISODES_INTRODUCED, MHE_UNCOMPLICATED_EPISODES_INDIGENOUS,
// Number of severe fever episodes in humans. Units: cases
MHE_SEVERE_EPISODES,
// Number of severe fever episodes without counting episodes due to comorbidities in humans. Units: cases
Expand Down
4 changes: 4 additions & 0 deletions unittest/WHMock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ double WHMock::getCumulative_Y() const{
throw util::unimplemented_exception( "not needed in unit test" );
}

InfectionOrigin WHMock::getInfectionType() const{
return InfectionOrigin::Indigenous;
}

void WHMock::checkpoint (istream& stream){
throw util::unimplemented_exception( "not needed in unit test" );
}
Expand Down
1 change: 1 addition & 0 deletions unittest/WHMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class WHMock : public WHInterface {
virtual void clearImmunity();
virtual double getCumulative_h() const;
virtual double getCumulative_Y() const;
virtual InfectionOrigin getInfectionType() const;

// This mock class does not have actual infections. Just set this as you please.
double totalDensity;
Expand Down

0 comments on commit a3a8194

Please sign in to comment.