Skip to content

Commit

Permalink
updated schema to have correct references (update schema 13/10/2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrdossan committed Oct 13, 2023
1 parent a96cc18 commit 1784edf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
39 changes: 19 additions & 20 deletions caimira/apps/calculator/global_store/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
},
}

viable_to_RNA_ratio = {
viable_to_RNA_ratio_distribution = {
'low': 0.01,
'high': 0.6,
}

infectious_dose = {
infectious_dose_distribution = {
'low': 10,
'high': 100,
}
Expand All @@ -82,45 +82,45 @@

virus_distributions = {
'SARS_CoV_2_OMICRON': {
'infectious_dose': 'Ref: Infectious dose - infectious_dose',
'infectious_dose': 'Ref: Infectious dose - infectious_dose_distribution',
'infectiousness_days': 14,
'transmissibility_factor': 0.2,
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio',
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio_distribution',
'viral_load_in_sputum': 'Ref: Viral load - covid_overal_vl_data',
},
'SARS_CoV_2': {
'infectious_dose': 'Ref: Infectious dose - infectious_dose',
'infectious_dose': 'Ref: Infectious dose - infectious_dose_distribution',
'infectiousness_days': 14,
'transmissibility_factor': 1,
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio',
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio_distribution',
'viral_load_in_sputum': 'Ref: Viral load - covid_overal_vl_data',
},
'SARS_CoV_2_ALPHA': {
'infectious_dose': 'Ref: Infectious dose - infectious_dose',
'infectious_dose': 'Ref: Infectious dose - infectious_dose_distribution',
'infectiousness_days': 14,
'transmissibility_factor': 0.78,
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio',
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio_distribution',
'viral_load_in_sputum': 'Ref: Viral load - covid_overal_vl_data',
},
'SARS_CoV_2_BETA': {
'infectious_dose': 'Ref: Infectious dose - infectious_dose',
'infectious_dose': 'Ref: Infectious dose - infectious_dose_distribution',
'infectiousness_days': 14,
'transmissibility_factor': 0.8,
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio',
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio_distribution',
'viral_load_in_sputum': 'Ref: Viral load - covid_overal_vl_data',
},
'SARS_CoV_2_DELTA': {
'infectious_dose': 'Ref: Infectious dose - infectious_dose',
'infectious_dose': 'Ref: Infectious dose - infectious_dose_distribution',
'infectiousness_days': 14,
'transmissibility_factor': 0.51,
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio',
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio_distribution',
'viral_load_in_sputum': 'Ref: Viral load - covid_overal_vl_data'
},
'SARS_CoV_2_GAMMA': {
'infectious_dose': 'Ref: Infectious dose - infectious_dose',
'infectious_dose': 'Ref: Infectious dose - infectious_dose_distribution',
'infectiousness_days': 14,
'transmissibility_factor': 0.72,
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio',
'viable_to_RNA_ratio': 'Ref: Viable to RNA ratio - viable_to_RNA_ratio_distribution',
'viral_load_in_sputum': 'Ref: Viral load - covid_overal_vl_data',
},
}
Expand All @@ -141,7 +141,7 @@ def update_local_reference(local_data, api_data):


async def populate_data():
global data_fetched, covid_overal_vl_data, infectious_dose, viable_to_RNA_ratio, virus_distributions, activity_distributions
global data_fetched, covid_overal_vl_data, infectious_dose_distribution, viable_to_RNA_ratio_distribution, virus_distributions, activity_distributions

if not data_fetched and os.environ.get('DATA_SERVICE_ENABLED', 'False').lower() == 'true':
# Fetch data if it hasn't been fetched yet
Expand All @@ -150,12 +150,11 @@ async def populate_data():
await GlobalStore.populate_from_api()
data = GlobalStore.get_data()['data']

infectious_dose = update_local_reference(infectious_dose, data['infectious_dose'])
infectious_dose_distribution = update_local_reference(infectious_dose_distribution, data['infectious_dose_distribution'])
covid_overal_vl_data = update_local_reference(covid_overal_vl_data, data['covid_overal_vl_data'])
viable_to_RNA_ratio = update_local_reference(viable_to_RNA_ratio, data['viable_to_RNA_ratio_distribution'])
# TODO: reverse (error in schema)
virus_distributions = update_local_reference(data['virus_distributions'], virus_distributions)
activity_distributions = update_local_reference(data['activity_distributions'], activity_distributions)
viable_to_RNA_ratio_distribution = update_local_reference(viable_to_RNA_ratio_distribution, data['viable_to_RNA_ratio_distribution'])
virus_distributions = update_local_reference(virus_distributions, data['virus_distributions'])
activity_distributions = update_local_reference(activity_distributions, data['activity_distributions'])

data_fetched = True

Expand Down
4 changes: 2 additions & 2 deletions caimira/monte_carlo/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ def integrate(self, dmin, dmax):

# Derived from data in doi.org/10.1016/j.ijid.2020.09.025 and
# https://iosh.com/media/8432/aerosol-infection-risk-hospital-patient-care-full-report.pdf (page 60)
viable_to_RNA_ratio = Uniform(constants.viable_to_RNA_ratio['low'], constants.viable_to_RNA_ratio['high'])
viable_to_RNA_ratio_distribution = Uniform(constants.viable_to_RNA_ratio_distribution['low'], constants.viable_to_RNA_ratio_distribution['high'])


# From discussion with virologists
infectious_dose = Uniform(constants.infectious_dose['low'], constants.infectious_dose['high'])
infectious_dose_distribution = Uniform(constants.infectious_dose_distribution['low'], constants.infectious_dose_distribution['high'])


# From https://doi.org/10.1101/2021.10.14.21264988 and refererences therein
Expand Down
10 changes: 5 additions & 5 deletions caimira/tests/test_monte_carlo_full_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import caimira.monte_carlo as mc
from caimira import models,data
from caimira.monte_carlo.data import activity_distributions, virus_distributions, expiration_distributions, infectious_dose, viable_to_RNA_ratio
from caimira.monte_carlo.data import activity_distributions, virus_distributions, expiration_distributions, infectious_dose_distribution, viable_to_RNA_ratio_distribution
from caimira.apps.calculator.model_generator import build_expiration

SAMPLE_SIZE = 500_000
Expand Down Expand Up @@ -173,8 +173,8 @@ def skagit_chorale_mc():
presence=models.SpecificInterval(((0, 2.5), )),
virus=mc.SARSCoV2(
viral_load_in_sputum=10**9,
infectious_dose=infectious_dose,
viable_to_RNA_ratio=viable_to_RNA_ratio,
infectious_dose=infectious_dose_distribution,
viable_to_RNA_ratio=viable_to_RNA_ratio_distribution,
transmissibility_factor=1.,
),
mask=models.Mask.types['No mask'],
Expand Down Expand Up @@ -214,8 +214,8 @@ def bus_ride_mc():
presence=models.SpecificInterval(((0, 1.67), )),
virus=mc.SARSCoV2(
viral_load_in_sputum=5*10**8,
infectious_dose=infectious_dose,
viable_to_RNA_ratio=viable_to_RNA_ratio,
infectious_dose=infectious_dose_distribution,
viable_to_RNA_ratio=viable_to_RNA_ratio_distribution,
transmissibility_factor=1.,
),
mask=models.Mask.types['No mask'],
Expand Down

0 comments on commit 1784edf

Please sign in to comment.