refactoring
This commit is contained in:
@@ -467,93 +467,81 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "4ad05656",
|
||||
"id": "f38924ec",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrByVaccineAndSymptom = pd.read_csv(\n",
|
||||
" 'data/prrByDrugAndSymptom-EudraVigilance.csv',\n",
|
||||
" index_col = 'DRUG')\n",
|
||||
"prrByVaccineAndSymptom"
|
||||
"def saveProportionalReportingRatios4PrrByVaccineBySymptomWithoutZeroPrrs(prrByVaccineAndSymptom, webAppBaseDir):\n",
|
||||
" prrByVaccineBySymptom = PrrSeriesFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
||||
"\n",
|
||||
" prrByVaccineBySymptomWithoutZeroPrrs = PrrSeriesTransformer.filterByNonZeroPrrs(prrByVaccineBySymptom)\n",
|
||||
" del prrByVaccineBySymptom\n",
|
||||
" gc.collect()\n",
|
||||
"\n",
|
||||
" filenameBySymptom = saveProportionalReportingRatios(\n",
|
||||
" prrByVaccineBySymptomWithoutZeroPrrs,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/symptoms'))\n",
|
||||
"\n",
|
||||
" del prrByVaccineBySymptomWithoutZeroPrrs\n",
|
||||
" gc.collect()\n",
|
||||
" return filenameBySymptom"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7aed1621",
|
||||
"id": "e1237c0b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrByVaccineAndSymptom = DataFrameFilter.withoutZeroRowsAndZeroColumns(prrByVaccineAndSymptom)\n",
|
||||
"prrByVaccineAndSymptom"
|
||||
"def saveProportionalReportingRatios4PrrBySymptomByVaccineWithHighPrrs(prrByVaccineAndSymptom, webAppBaseDir):\n",
|
||||
" prrBySymptomByVaccine = PrrSeriesFactory.getPrrBySymptomByVaccine(prrByVaccineAndSymptom)\n",
|
||||
" prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)\n",
|
||||
" del prrBySymptomByVaccine\n",
|
||||
" gc.collect()\n",
|
||||
"\n",
|
||||
" filenameByDrug = saveProportionalReportingRatios(\n",
|
||||
" prrBySymptomByVaccineWithHighPrrs,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/vaccines'))\n",
|
||||
"\n",
|
||||
" del prrBySymptomByVaccineWithHighPrrs\n",
|
||||
" gc.collect()\n",
|
||||
" return filenameByDrug"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "b41b60c7",
|
||||
"id": "64ccf3c9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByDrugs'"
|
||||
"def saveProportionalReportingRatiosAndUpdateHtmlFile(prrByVaccineAndSymptom, webAppBaseDir):\n",
|
||||
" prrByVaccineAndSymptom = DataFrameFilter.withoutZeroRowsAndZeroColumns(prrByVaccineAndSymptom)\n",
|
||||
" filenameBySymptom = saveProportionalReportingRatios4PrrByVaccineBySymptomWithoutZeroPrrs(prrByVaccineAndSymptom, webAppBaseDir)\n",
|
||||
" filenameByDrug = saveProportionalReportingRatios4PrrBySymptomByVaccineWithHighPrrs(prrByVaccineAndSymptom, webAppBaseDir)\n",
|
||||
" updateHtmlFile(\n",
|
||||
" symptomsDescr = {\n",
|
||||
" 'symptoms': list(prrByVaccineAndSymptom.columns),\n",
|
||||
" 'filenameBySymptom': filenameBySymptom },\n",
|
||||
" vaccinesDescr = {\n",
|
||||
" 'vaccines': list(prrByVaccineAndSymptom.index),\n",
|
||||
" 'filenameByDrug': filenameByDrug },\n",
|
||||
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "26f72e75",
|
||||
"id": "3db1a115",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrByVaccineBySymptom = PrrSeriesFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
||||
"\n",
|
||||
"prrByVaccineBySymptomWithoutZeroPrrs = PrrSeriesTransformer.filterByNonZeroPrrs(prrByVaccineBySymptom)\n",
|
||||
"del prrByVaccineBySymptom\n",
|
||||
"gc.collect()\n",
|
||||
"\n",
|
||||
"filenameBySymptom = saveProportionalReportingRatios(\n",
|
||||
" prrByVaccineBySymptomWithoutZeroPrrs,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/symptoms'))\n",
|
||||
"\n",
|
||||
"del prrByVaccineBySymptomWithoutZeroPrrs\n",
|
||||
"gc.collect()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5bfdcbdd",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrBySymptomByVaccine = PrrSeriesFactory.getPrrBySymptomByVaccine(prrByVaccineAndSymptom)\n",
|
||||
"prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)\n",
|
||||
"del prrBySymptomByVaccine\n",
|
||||
"gc.collect()\n",
|
||||
"\n",
|
||||
"filenameByDrug = saveProportionalReportingRatios(\n",
|
||||
" prrBySymptomByVaccineWithHighPrrs,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/vaccines'))\n",
|
||||
"\n",
|
||||
"del prrBySymptomByVaccineWithHighPrrs\n",
|
||||
"gc.collect()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "cc97b8d4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"updateHtmlFile(\n",
|
||||
" symptomsDescr = {\n",
|
||||
" 'symptoms': list(prrByVaccineAndSymptom.columns),\n",
|
||||
" 'filenameBySymptom': filenameBySymptom },\n",
|
||||
" vaccinesDescr = {\n",
|
||||
" 'vaccines': list(prrByVaccineAndSymptom.index),\n",
|
||||
" 'filenameByDrug': filenameByDrug },\n",
|
||||
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))"
|
||||
"saveProportionalReportingRatiosAndUpdateHtmlFile(\n",
|
||||
" prrByVaccineAndSymptom = pd.read_csv(\n",
|
||||
" 'data/prrByDrugAndSymptom-EudraVigilance-10.csv',\n",
|
||||
" index_col = 'DRUG'),\n",
|
||||
" webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByDrugs')"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -567,22 +555,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5cd9935f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from SymptomsCausedByVaccines.DataFrameFilter import DataFrameFilter\n",
|
||||
"from SymptomsCausedByVaccines.HtmlUpdater import updateHtmlFile, updateHtmlFile4SymptomsCausedByCOVIDLots\n",
|
||||
"from SymptomsCausedByVaccines.PrrSeriesFactory import PrrSeriesFactory\n",
|
||||
"from SymptomsCausedByVaccines.PrrSeriesTransformer import PrrSeriesTransformer\n",
|
||||
"from SymptomsCausedByVaccines.ProportionalReportingRatiosPersister import saveProportionalReportingRatios\n",
|
||||
"import os\n",
|
||||
"import pandas as pd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0974c307",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -597,101 +570,13 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "dfa98cd9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrByVaccineAndSymptom = DataFrameFilter.withoutZeroRowsAndZeroColumns(prrByVaccineAndSymptom)\n",
|
||||
"prrByVaccineAndSymptom"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "640868c7",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrByVaccineBySymptom = PrrSeriesFactory.getPrrByVaccineBySymptom(prrByVaccineAndSymptom)\n",
|
||||
"prrByVaccineBySymptom"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0f247c64",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrBySymptomByVaccine = PrrSeriesFactory.getPrrBySymptomByVaccine(prrByVaccineAndSymptom)\n",
|
||||
"prrBySymptomByVaccine"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "760ac423",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrByVaccineBySymptomWithoutZeroPrrs = PrrSeriesTransformer.filterByNonZeroPrrs(prrByVaccineBySymptom)\n",
|
||||
"prrByVaccineBySymptomWithoutZeroPrrs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f07203e4",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"prrBySymptomByVaccineWithHighPrrs = PrrSeriesTransformer.filterPrrs(prrBySymptomByVaccine, lambda prr: prr >= 2)\n",
|
||||
"prrBySymptomByVaccineWithHighPrrs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByVaccines'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0b40071c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"saveProportionalReportingRatios(\n",
|
||||
" prrByVaccineBySymptomWithoutZeroPrrs,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/symptoms'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "fac4b34f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"saveProportionalReportingRatios(\n",
|
||||
" prrBySymptomByVaccineWithHighPrrs,\n",
|
||||
" directory = os.path.normpath(webAppBaseDir + '/data/ProportionalReportingRatios/vaccines'))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "803dfbef",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"updateHtmlFile(\n",
|
||||
" symptoms = list(prrByVaccineAndSymptom.columns),\n",
|
||||
" vaccines = list(prrByVaccineAndSymptom.index),\n",
|
||||
" htmlFile = os.path.normpath(webAppBaseDir + '/index.html'))"
|
||||
"saveProportionalReportingRatiosAndUpdateHtmlFile(\n",
|
||||
" prrByVaccineAndSymptom = prrByVaccineAndSymptom,\n",
|
||||
" webAppBaseDir = os.getcwd() + '/../docs/SymptomsCausedByVaccines')"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user