From 1784edf85c5c2b42c50836ae835be51d25d752fe Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Fri, 13 Oct 2023 17:56:30 +0200 Subject: [PATCH] updated schema to have correct references (update schema 13/10/2023) --- .../apps/calculator/global_store/constants.py | 39 +++++++++---------- caimira/monte_carlo/data.py | 4 +- caimira/tests/test_monte_carlo_full_models.py | 10 ++--- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/caimira/apps/calculator/global_store/constants.py b/caimira/apps/calculator/global_store/constants.py index a1027c1b..ff470d9e 100644 --- a/caimira/apps/calculator/global_store/constants.py +++ b/caimira/apps/calculator/global_store/constants.py @@ -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, } @@ -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', }, } @@ -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 @@ -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 diff --git a/caimira/monte_carlo/data.py b/caimira/monte_carlo/data.py index a8ce44e9..7749ae3f 100644 --- a/caimira/monte_carlo/data.py +++ b/caimira/monte_carlo/data.py @@ -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 diff --git a/caimira/tests/test_monte_carlo_full_models.py b/caimira/tests/test_monte_carlo_full_models.py index 4fb4c1fd..b6e3948c 100644 --- a/caimira/tests/test_monte_carlo_full_models.py +++ b/caimira/tests/test_monte_carlo_full_models.py @@ -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 @@ -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'], @@ -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'],