Skip to content

Commit

Permalink
create src/predict_drug_target folder for importing from other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Apr 10, 2024
1 parent 1edd4d5 commit ace2287
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Prepare data and train the model
run: |
./prepare.sh
python src/train.py
python src/predict_drug_target/train.py
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ RUN pip3 install -r requirements.txt
ADD . .
RUN pip3 install -e .

CMD [ "gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "--workers", "4", "src.api:app" ]
CMD [ "gunicorn", "-k", "uvicorn.workers.UvicornWorker", "-b", "0.0.0.0:8000", "--workers", "4", "src.predict_drug_target.api:app" ]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Query the Bio2RDF endpoint to get drugs and their smiles, targets and their prot

Process the Bio2RDF data to generate the inputs needed for the two embeddings methods
```bash
python src/prepare.py
python src/predict_drug_target/prepare.py
```

Install the ESM library
Expand Down Expand Up @@ -84,7 +84,7 @@ export CUDA_VISIBLE_DEVICES=1
Train the model:

```bash
python src/train.py
python src/predict_drug_target/train.py
```

> Results are in the `results/` folder, model pickle goes to the `models/` folder
Expand All @@ -94,7 +94,7 @@ python src/train.py
Run the prediction workflow for 2 entities:

```bash
python src/predict.py
python src/predict_drug_target/predict.py
```

Users provides drugs and targets using their CHEMBL or Ensembl IDs, the script will test all provided drugs against all provided targets, and return a prediction score (how confident we are that the drug interacts with the target) for each drug-target pair.
Expand Down
6 changes: 3 additions & 3 deletions archive/old_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from sklearn import ensemble, metrics
from sklearn.model_selection import StratifiedKFold

from src.embeddings import compute_drug_embedding, compute_target_embedding
from src.utils import COLLECTIONS, log
from src.vectordb import init_vectordb
from predict_drug_target.embeddings import compute_drug_embedding, compute_target_embedding
from predict_drug_target.utils import COLLECTIONS, log
from predict_drug_target.vectordb import init_vectordb

vectordb = init_vectordb(recreate=False)

Expand Down
4 changes: 2 additions & 2 deletions archive/prepare_opentargets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pandas as pd
from tqdm import tqdm

from src.utils import ACCEPTED_NAMESPACES, COLLECTIONS, get_pref_ids, get_seq_for_target, get_smiles_for_drug, log
from src.vectordb import init_vectordb
from predict_drug_target.utils import ACCEPTED_NAMESPACES, COLLECTIONS, get_pref_ids, get_seq_for_target, get_smiles_for_drug, log
from predict_drug_target.vectordb import init_vectordb

# NOTE: Download opentargets before running this script
# ./scripts/download_opentargets.sh
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
shm_size: '4g'
# ports:
# - 8000:8000
command: uvicorn --host 0.0.0.0 src.api:app
command: uvicorn --host 0.0.0.0 src.predict_drug_target.api:app
# --reload
networks:
- nginx
Expand Down
2 changes: 1 addition & 1 deletion notebooks/get_similarities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"source": [
"from src.vectordb import init_vectordb\n",
"from predict_drug_target.vectordb import init_vectordb\n",
"\n",
"vectordb = init_vectordb(recreate=False)"
]
Expand Down
2 changes: 1 addition & 1 deletion prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ cd ..


echo "Generate list of known_drug_target pairs for OpenTargets"
python3 src/prepare.py
python3 src/predict_drug_target/prepare.py
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test = [
]

[project.scripts]
predict-dt = "src.__main__:cli"
predict-dt = "src.predict_drug_target.__main__:cli"


[project.urls]
Expand All @@ -87,9 +87,9 @@ features = [
]

[tool.hatch.envs.default.scripts]
train = "python3 src/train.py {args}"
predict = "python3 src/predict.py {args}"
api = "uvicorn src.api:app --host 0.0.0.0 --reload {args}"
train = "python3 src/predict_drug_target/train.py {args}"
predict = "python3 src/predict_drug_target/predict.py {args}"
api = "uvicorn src.predict_drug_target.api:app --host 0.0.0.0 --reload {args}"
fmt = [
"black src/",
"ruff src/ --fix",
Expand All @@ -109,7 +109,7 @@ requirements = "pip-compile -o requirements.txt pyproject.toml"

# TOOLS
[tool.hatch.build.targets.wheel]
packages = ["src"]
packages = ["src/predict_drug_target"]

[tool.hatch.metadata]
allow-direct-references = true
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/__main__.py → src/predict_drug_target/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typer

# from src.embeddings import compute
# from predict_drug_target.embeddings import compute

cli = typer.Typer()

Expand Down
8 changes: 4 additions & 4 deletions src/api.py → src/predict_drug_target/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

from trapi_predict_kit import TRAPI, settings

from src.predict import get_drug_target_predictions
from src.train import train
from src.utils import COLLECTIONS
from src.vectordb import init_vectordb
from predict_drug_target.predict import get_drug_target_predictions
from predict_drug_target.train import train
from predict_drug_target.utils import COLLECTIONS
from predict_drug_target.vectordb import init_vectordb

log_level = logging.INFO
logging.basicConfig(level=log_level)
Expand Down
4 changes: 2 additions & 2 deletions src/embeddings.py → src/predict_drug_target/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from smiles_transformer import get_smiles_embeddings
from tqdm import tqdm

from src.utils import (
from predict_drug_target.utils import (
ACCEPTED_NAMESPACES,
EMBEDDINGS_SIZE_DRUG,
EMBEDDINGS_SIZE_TARGET,
Expand All @@ -18,7 +18,7 @@
get_smiles_for_drug,
log,
)
from src.vectordb import VectorDB, init_vectordb
from predict_drug_target.vectordb import VectorDB, init_vectordb

VECTORDB = init_vectordb(recreate=False)

Expand Down
6 changes: 3 additions & 3 deletions src/predict.py → src/predict_drug_target/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import pandas as pd
from trapi_predict_kit import PredictInput, PredictOutput, trapi_predict

from src.embeddings import compute_drug_embedding, compute_target_embedding
from src.utils import (
from predict_drug_target.embeddings import compute_drug_embedding, compute_target_embedding
from predict_drug_target.utils import (
BOLD,
COLLECTIONS,
END,
log,
)
from src.vectordb import init_vectordb
from predict_drug_target.vectordb import init_vectordb

VECTORDB = init_vectordb(recreate=False)

Expand Down
8 changes: 4 additions & 4 deletions src/prepare.py → src/predict_drug_target/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from tqdm import tqdm
from src import vectordb

# from src.embeddings import compute_drug_embedding, compute_target_embedding
from src.embeddings import compute
from src.utils import COLLECTIONS, log, get_pref_ids
from src.vectordb import init_vectordb
# from predict_drug_target.embeddings import compute_drug_embedding, compute_target_embedding
from predict_drug_target.embeddings import compute
from predict_drug_target.utils import COLLECTIONS, log, get_pref_ids
from predict_drug_target.vectordb import init_vectordb

# NOTE: script to run the WHOLE pipeline on opentargets data
# it will automatically compute embeddings for all drugs and targets
Expand Down
4 changes: 2 additions & 2 deletions src/train.py → src/predict_drug_target/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import xgboost as xgb
from xgboost import XGBClassifier, DMatrix

from src.utils import log, TrainingConfig
from src.vectordb import init_vectordb
from predict_drug_target.utils import log, TrainingConfig
from predict_drug_target.vectordb import init_vectordb

vectordb = init_vectordb(recreate=False)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/vectordb.py → src/predict_drug_target/vectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SearchParams,
)

from src.utils import log, COLLECTIONS
from predict_drug_target.utils import log, COLLECTIONS


# Define an abstract class VectorDB
Expand Down
2 changes: 1 addition & 1 deletion tests/test_trapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from trapi_predict_kit import settings
from reasoner_validator.validator import TRAPIResponseValidator

from src.api import app, trapi_example
from predict_drug_target.api import app, trapi_example


client = TestClient(app)
Expand Down

0 comments on commit ace2287

Please sign in to comment.