Source code for sbmlsim.examples.experiments.covid.omex.download_covid_models

"""Helper module for downloading COVID-19 biomodels."""
import json
from pathlib import Path
from pprint import pprint
from typing import Dict, List

import requests
from sbmlutils.biomodels import download_biomodel_omex

[docs]def query_covid19_biomodels() -> List[str]: """Query the COVID-19 biomodels. :return List of biomodel identifiers """ url = "" response = requests.get(url) response.raise_for_status() json = response.json() biomodel_ids = [model["id"] for model in json["models"]] return sorted(biomodel_ids)
[docs]def get_covid19_model(output_dir: Path) -> Dict[str, Path]: """Get all manually curated COVID-19 models. :return dictionary of model ids to Paths. """ if not output_dir.exists(): output_dir.mkdir(parents=True, exist_ok=True) biomodel_ids = query_covid19_biomodels() pprint(biomodel_ids) omex_paths = {} for biomodel_id in biomodel_ids: omex_path = output_dir / f"{biomodel_id}.omex" path = download_biomodel_omex(biomodel_id, omex_path=omex_path) omex_paths[biomodel_id] = str(path) return omex_paths
if __name__ == "__main__":
[docs] omex_paths = get_covid19_model(output_dir=Path(__file__).parent / "results")
# store json with open(Path(__file__).parent / "models.json", "w") as f_json: json.dump(omex_paths, f_json, indent=2)