{"id":23370052,"url":"https://github.com/maastrichtu-ids/translator-openpredict","last_synced_at":"2025-06-19T20:37:31.309Z","repository":{"id":38455557,"uuid":"277174439","full_name":"MaastrichtU-IDS/translator-openpredict","owner":"MaastrichtU-IDS","description":"🔮🐍 A package to help serve predictions of biomedical concepts associations as Translator Reasoner API","archived":false,"fork":false,"pushed_at":"2025-02-25T08:21:36.000Z","size":72201,"stargazers_count":12,"open_issues_count":17,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-24T14:04:19.983Z","etag":null,"topics":["biomedical-concepts-associations","openapi","predict","translator-api","trapi"],"latest_commit_sha":null,"homepage":"https://openpredict.semanticscience.org","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaastrichtU-IDS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-04T19:38:07.000Z","updated_at":"2025-02-25T08:21:42.000Z","dependencies_parsed_at":"2023-10-16T20:39:17.848Z","dependency_job_id":"a3bbb8ee-d951-490b-a92f-da7eecf9448a","html_url":"https://github.com/MaastrichtU-IDS/translator-openpredict","commit_stats":{"total_commits":791,"total_committers":8,"mean_commits":98.875,"dds":0.05689001264222504,"last_synced_commit":"5b1a8e9669c76ff14d27d6ab2719a3e0c2fa3aa3"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaastrichtU-IDS%2Ftranslator-openpredict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaastrichtU-IDS%2Ftranslator-openpredict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaastrichtU-IDS%2Ftranslator-openpredict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaastrichtU-IDS%2Ftranslator-openpredict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaastrichtU-IDS","download_url":"https://codeload.github.com/MaastrichtU-IDS/translator-openpredict/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248251421,"owners_count":21072689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biomedical-concepts-associations","openapi","predict","translator-api","trapi"],"created_at":"2024-12-21T15:33:06.850Z","updated_at":"2025-04-10T16:13:14.094Z","avatar_url":"https://github.com/MaastrichtU-IDS.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🔮🐍 Translator OpenPredict\n\n[![Python versions](https://img.shields.io/pypi/pyversions/openpredict)](https://pypi.org/project/openpredict)\n\n\u003c!-- [![Test the production API](https://github.com/MaastrichtU-IDS/translator-openpredict/actions/workflows/test-prod.yml/badge.svg)](https://github.com/MaastrichtU-IDS/translator-openpredict/actions/workflows/test-prod.yml) [![Run integration tests for TRAPI](https://github.com/MaastrichtU-IDS/translator-openpredict/actions/workflows/test-integration.yml/badge.svg)](https://github.com/MaastrichtU-IDS/translator-openpredict/actions/workflows/test-integration.yml)\n--\u003e\n\nThis repository contains the code for the **OpenPredict Translator API** available at **[openpredict.semanticscience.org](https://openpredict.semanticscience.org)**, which serves a few prediction models developed at the Institute of Data Science.\n\n* various folders for **different prediction models** served by the OpenPredict API are available under `src/`:\n  * the OpenPredict drug-disease prediction model in `src/openpredict_model/`\n  * a model to compile the evidence path between a drug and a disease explaining the predictions of the OpenPredict model in `src/openpredict_evidence_path/`\n  * a prediction model trained from the Drug Repurposing Knowledge Graph (aka. DRKG) in `src/drkg_model/`\n* the code for the OpenPredict API endpoints in  `src/trapi/` defines:\n  *  a TRAPI endpoint returning predictions for the loaded models\n\nThe data used by the models in this repository is downloaded into the `data/` folder, and stored **on HuggingFace at https://huggingface.co/datasets/um-ids/translator-openpredict**\n\n### Deploy the OpenPredict API locally\n\nRequirements: Python 3.8+ and `pip` installed\n\n1. Clone the repository with submodule:\n\n   ```bash\n   git clone --recursive https://github.com/MaastrichtU-IDS/translator-openpredict.git\n   cd translator-openpredict\n   ```\n\n\n2. Start the API in development mode with docker on http://localhost:8808, the API will automatically reload when you make changes in the code:\n\n```bash\ndocker compose up api\n```\n\n[Note regarding the data files: The docker container should download the data automatically from the huggingface repo into the ```data``` subfolder. If, for any reason, you need to download separately, you can do this from the commandline using [`huggingface_cli`](https://huggingface.co/docs/huggingface_hub/main/en/guides/cli):\n\n   ```bash\n   huggingface-cli download um-ids/translator-openpredict \\\n    --local-dir ./data/ --repo-type dataset\n   ```\nThe data can also be downloaded manually from the repo if needed.\n\n]\n\n\u003e Contributions are welcome! If you wish to help improve OpenPredict, see the [instructions to contribute :woman_technologist:](/CONTRIBUTING.md) for more details on the development workflow\n\n### Test the OpenPredict API\n\nRun the tests locally with docker:\n\n```bash\ndocker compose run tests\n```\n\n\u003e See the [`TESTING.md`](/TESTING.md) file for more details on testing the API.\n\nYou can change the entrypoint of the test container to run other commands, such as training a model:\n\n```bash\ndocker compose run --entrypoint \"python src/openpredict_model/train.py train-model\" tests\n# Or with the helper script:\n./resources/run.sh python src/openpredict_model/train.py train-model\n```\n\n### Use the OpenPredict API\n\n\nThe user provides a drug or a disease identifier as a CURIE (e.g. `DRUGBANK:DB00394`, or `OMIM:246300`), and choose a prediction model (only the `Predict OMIM-DrugBank` classifier is currently implemented).\n\nThe API will return predicted targets for the given drug or disease:\n\n* The **potential drugs treating a given disease** :pill:\n* The **potential diseases a given drug could treat** :microbe:\n\n\u003e Feel free to try the API at **[openpredict.semanticscience.org](https://openpredict.semanticscience.org)**\n\n#### TRAPI operations\n\nOperations to query OpenPredict using the [Translator Reasoner API](https://github.com/NCATSTranslator/ReasonerAPI) standards.\n\n##### Query operation\n\nThe `/query` operation will return the same predictions as the `/predict` operation, using the [ReasonerAPI](https://github.com/NCATSTranslator/ReasonerAPI) format, used within the [Translator project](https://ncats.nih.gov/translator/about).\n\nThe user sends a [ReasonerAPI](https://github.com/NCATSTranslator/ReasonerAPI) query asking for the predicted targets given: a source, and the relation to predict. The query is a graph with nodes and edges defined in JSON, and uses classes from the [BioLink model](https://biolink.github.io/biolink-model).\n\nYou can use the default TRAPI query of OpenPredict `/query` operation to try a working example.\n\nExample of TRAPI query to retrieve drugs similar to a specific drug:\n\n```json\n{\n    \"message\": {\n        \"query_graph\": {\n        \"edges\": {\n            \"e01\": {\n            \"object\": \"n1\",\n            \"predicates\": [\n                \"biolink:similar_to\"\n            ],\n            \"subject\": \"n0\"\n            }\n        },\n        \"nodes\": {\n            \"n0\": {\n            \"categories\": [\n                \"biolink:Drug\"\n            ],\n            \"ids\": [\n                \"DRUGBANK:DB00394\"\n            ]\n            },\n            \"n1\": {\n            \"categories\": [\n                \"biolink:Drug\"\n            ]\n            }\n        }\n        }\n    },\n    \"query_options\": {\n        \"n_results\": 3\n    }\n}\n```\n\n##### Predicates operation\n\nThe `/predicates` operation will return the entities and relations provided by this API in a JSON object (following the [ReasonerAPI](https://github.com/NCATSTranslator/ReasonerAPI) specifications).\n\n\u003e Try it at [https://openpredict.semanticscience.org/predicates](https://openpredict.semanticscience.org/predicates)\n\n#### Notebooks examples :notebook_with_decorative_cover:\n\nWe provide [Jupyter Notebooks](https://jupyter.org/) with examples to use the OpenPredict API:\n\n1. [Query the OpenPredict API](https://github.com/MaastrichtU-IDS/translator-openpredict/blob/master/resources/openpredict-examples.ipynb)\n2. [Generate embeddings with pyRDF2Vec](https://github.com/MaastrichtU-IDS/translator-openpredict/blob/master/resources/openpredict-pyrdf2vec-embeddings.ipynb), and import them in the OpenPredict API\n\n#### Add embedding :station:\n\nThe default baseline model is `openpredict_baseline`. You can choose the base model when you post a new embeddings using the `/embeddings` call. Then the OpenPredict API will:\n\n1. add embeddings to the provided model\n2. train the model with the new embeddings\n3. store the features and model using a unique ID for the run (e.g. `7621843c-1f5f-11eb-85ae-48a472db7414`)\n\nOnce the embedding has been added you can find the existing models previously generated (including `openpredict_baseline`), and use them as base model when you ask the model for prediction or add new embeddings.\n\n#### Predict operation :crystal_ball:\n\nUse this operation if you just want to easily retrieve predictions for a given entity. The `/predict` operation takes 4 parameters (1 required):\n\n* A `drug_id` to get predicted diseases it could treat (e.g. `DRUGBANK:DB00394`)\n  * **OR** a `disease_id` to get predicted drugs it could be treated with (e.g. `OMIM:246300`)\n* The prediction model to use (default to `Predict OMIM-DrugBank`)\n* The minimum score of the returned predictions, from 0 to 1 (optional)\n* The limit of results to return, starting from the higher score, e.g. 42 (optional)\n\nThe API will return the list of predicted target for the given entity, the labels are resolved using the [Translator Name Resolver API](https://nodenormalization-sri.renci.org)\n\n\u003e Try it at [https://openpredict.semanticscience.org/predict?drug_id=DRUGBANK:DB00394](https://openpredict.semanticscience.org/predict?drug_id=DRUGBANK:DB00394)\n\n---\n\n### More about the data model :minidisc:\n\n* The gold standard for drug-disease indications has been retrieved from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3159979\n* Metadata about runs, models evaluations, features are stored as RDF using the [ML Schema ontology](http://ml-schema.github.io/documentation/ML%20Schema.html).\n  * See the [ML Schema documentation](http://ml-schema.github.io/documentation/ML%20Schema.html) for more details on the data model.\n\nDiagram of the data model used for OpenPredict, based on the ML Schema ontology (`mls`):\n\n![OpenPredict datamodel](https://raw.githubusercontent.com/MaastrichtU-IDS/translator-openpredict/master/resources/OpenPREDICT_datamodel.jpg)\n\n---\n\n## Translator application\n\n### Service Summary\nQuery for drug-disease pairs predicted from pre-computed sets of graphs embeddings.\n\nAdd new embeddings to improve the predictive models, with versioning and scoring of the models.\n\n### Component List\n**API component**\n\n1. Component Name: **OpenPredict API**\n\n2. Component Description: **Python API to serve pre-computed set of drug-disease pair predictions from graphs embeddings**\n\n3. GitHub Repository URL: https://github.com/MaastrichtU-IDS/translator-openpredict\n\n4. Component Framework: **Knowledge Provider**\n\n5. System requirements\n\n    5.1. Specific OS and version if required: **python 3.8**\n\n    5.2. CPU/Memory (for CI, TEST and PROD):  **32 CPUs and 32 Go memory ?**\n\n    5.3. Disk size/IO throughput (for CI, TEST and PROD): **20 Go ?**\n\n    5.4. Firewall policies: does the team need access to infrastructure components?\n    **The NodeNormalization API https://nodenormalization-sri.renci.org**\n\n\n6. External Dependencies (any components other than current one)\n\n    6.1. External storage solution: **Models and database are stored in `/data/openpredict` in the Docker container**\n\n7. Docker application:\n\n    7.1. Path to the Dockerfile: **`Dockerfile`**\n\n    7.2. Docker build command:\n\n    ```bash\n    docker build ghcr.io/maastrichtu-ids/openpredict-api .\n    ```\n\n    7.3. Docker run command:\n\n\t**Replace `${PERSISTENT_STORAGE}` with the path to persistent storage on host:**\n\n    ```bash\n    docker run -d -v ${PERSISTENT_STORAGE}:/data/openpredict -p 8808:8808 ghcr.io/maastrichtu-ids/openpredict-api\n    ```\n\n9. Logs of the application\n\n    9.2. Format of the logs: **TODO**\n\n# Acknowledgments​\n\n* This service has been built from the [fair-workflows/openpredict](https://github.com/fair-workflows/openpredict) project.\n* Predictions made using the [PREDICT method](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3159979/).\n* Service funded by the [NIH NCATS Translator project](https://ncats.nih.gov/translator/about).\n\n![Funded the the NIH NCATS Translator project](https://ncats.nih.gov/files/TranslatorGraphic2020_1100x420.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaastrichtu-ids%2Ftranslator-openpredict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaastrichtu-ids%2Ftranslator-openpredict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaastrichtu-ids%2Ftranslator-openpredict/lists"}