scigantic-deeppk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scigantic_deeppk-0.1.0/LICENSE +16 -0
- scigantic_deeppk-0.1.0/PKG-INFO +100 -0
- scigantic_deeppk-0.1.0/README.md +67 -0
- scigantic_deeppk-0.1.0/pyproject.toml +56 -0
- scigantic_deeppk-0.1.0/setup.cfg +4 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk/__init__.py +117 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk/__main__.py +8 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk/cli.py +58 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk/py.typed +0 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk.egg-info/PKG-INFO +100 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk.egg-info/SOURCES.txt +16 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk.egg-info/dependency_links.txt +1 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk.egg-info/entry_points.txt +2 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk.egg-info/requires.txt +10 -0
- scigantic_deeppk-0.1.0/src/scigantic_deeppk.egg-info/top_level.txt +1 -0
- scigantic_deeppk-0.1.0/tests/test_cli.py +22 -0
- scigantic_deeppk-0.1.0/tests/test_cyp_reference.py +49 -0
- scigantic_deeppk-0.1.0/tests/test_predict.py +33 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT No Attribution
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Scigantic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
6
|
+
software and associated documentation files (the "Software"), to deal in the Software
|
|
7
|
+
without restriction, including without limitation the rights to use, copy, modify,
|
|
8
|
+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
12
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
13
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
14
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
15
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
|
16
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scigantic-deeppk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Client for Deep-PK's small-molecule ADMET/toxicity prediction API, plus a mirrored CYP450 inhibitor/substrate reference dataset.
|
|
5
|
+
Author: Scigantic
|
|
6
|
+
License: MIT-0
|
|
7
|
+
Project-URL: Homepage, https://scigantic.com
|
|
8
|
+
Project-URL: Repository, https://github.com/Scigantic/scigantic-deeppk
|
|
9
|
+
Project-URL: Issues, https://github.com/Scigantic/scigantic-deeppk/issues
|
|
10
|
+
Keywords: deep-pk,admet,cheminformatics,drug-discovery,cytochrome-p450,pharmacokinetics
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT No Attribution License (MIT-0)
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests<3,>=2.28
|
|
24
|
+
Requires-Dist: pandas<3,>=1.5
|
|
25
|
+
Requires-Dist: pyarrow<20,>=14
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
29
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
30
|
+
Requires-Dist: pandas-stubs; extra == "dev"
|
|
31
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
<h1 align="center">scigantic-deeppk</h1>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://github.com/Scigantic/scigantic-deeppk/actions/workflows/ci.yml">
|
|
38
|
+
<img alt="CI" src="https://github.com/Scigantic/scigantic-deeppk/actions/workflows/ci.yml/badge.svg" /></a>
|
|
39
|
+
<a href="https://pypi.org/project/scigantic-deeppk/">
|
|
40
|
+
<img alt="PyPI" src="https://img.shields.io/pypi/v/scigantic-deeppk" /></a>
|
|
41
|
+
<a href="https://pypi.org/project/scigantic-deeppk/">
|
|
42
|
+
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/scigantic-deeppk" /></a>
|
|
43
|
+
<a href="https://github.com/Scigantic/scigantic-deeppk/blob/main/LICENSE">
|
|
44
|
+
<img alt="License" src="https://img.shields.io/github/license/Scigantic/scigantic-deeppk" /></a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
Client for [Deep-PK](https://biosig.lab.uq.edu.au/deeppk) (small-molecule pharmacokinetic and toxicity prediction across 73 endpoints), plus a mirrored copy of its CYP450 inhibitor/substrate reference data.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import scigantic_deeppk as deeppk
|
|
51
|
+
|
|
52
|
+
df = deeppk.predict("CC(=O)OC1=CC=CC=C1C(=O)O", pred_type="metabolism") # aspirin
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
$ pip install scigantic-deeppk
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Live predictions
|
|
62
|
+
|
|
63
|
+
Deep-PK ships no downloadable model or pip package, only a free async job API: POST submits SMILES, GET polls by `job_id` until the job finishes. `predict()` wraps that round trip and blocks until the result is ready:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
df = deeppk.predict("CC(=O)OC1=CC=CC=C1C(=O)O", pred_type="admet")
|
|
67
|
+
|
|
68
|
+
# Batch
|
|
69
|
+
df = deeppk.predict(["CCO", "CC(=O)OC1=CC=CC=C1C(=O)O"], pred_type="metabolism")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`pred_type` is one of `absorption`, `distribution`, `excretion`, `metabolism`, `toxicity`, `admet` (default, all 73 endpoints). A single molecule typically takes 30-90s; there is no synchronous endpoint, no documented rate limit, and no SLA, so this is fine for exploration but not for anything that needs to run offline or reproducibly.
|
|
73
|
+
|
|
74
|
+
The API's own docs page names the POST field `SMILES_string`; the field that actually works, found by testing against the live server, is lowercase `smiles` (`smiles_file` for a batch). `predict()` already gets this right, this is only worth knowing if you're calling the API directly.
|
|
75
|
+
|
|
76
|
+
## CYP450 reference data
|
|
77
|
+
|
|
78
|
+
Deep-PK's [data page](https://biosig.lab.uq.edu.au/deeppk/data) also publishes ~80 static training datasets, including CYP1A2/2C9/2C19/2D6/3A4 inhibitor and substrate sets. `cyp_reference()` reads a small (~1.5MB, 105,695-row) parquet mirror of just those ten, useful for e.g. checking compound overlap against another CYP dataset before trusting a transfer or leakage number:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
df = deeppk.cyp_reference("cyp3a4", "inhibitor")
|
|
82
|
+
df = deeppk.cyp_reference() # every isoform and kind
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Columns: `isoform` (one of `cyp1a2`/`cyp2c9`/`cyp2c19`/`cyp2d6`/`cyp3a4`), `kind` (`inhibitor`/`substrate`), `split` (Deep-PK's own `training`/`val`/`test` split), `smiles`, `label` (0/1). Row counts per isoform+kind reproduce Deep-PK's own stated totals exactly.
|
|
86
|
+
|
|
87
|
+
## Command line
|
|
88
|
+
|
|
89
|
+
```console
|
|
90
|
+
$ scigantic-deeppk predict "CC(=O)OC1=CC=CC=C1C(=O)O" --pred-type metabolism
|
|
91
|
+
$ scigantic-deeppk cyp-reference --isoform cyp3a4 --kind inhibitor
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT-0. See [LICENSE](LICENSE). This covers the code in this package only.
|
|
97
|
+
|
|
98
|
+
## Data license
|
|
99
|
+
|
|
100
|
+
Deep-PK's data page states the CYP450 datasets are "Open Knowledge" but publishes no formal license file or terms beyond that. `cyp_reference()`'s mirror reproduces that data as-is; check with the Ascher lab (biosig.lab.uq.edu.au/deeppk) before redistributing it further if that matters for your use.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<h1 align="center">scigantic-deeppk</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://github.com/Scigantic/scigantic-deeppk/actions/workflows/ci.yml">
|
|
5
|
+
<img alt="CI" src="https://github.com/Scigantic/scigantic-deeppk/actions/workflows/ci.yml/badge.svg" /></a>
|
|
6
|
+
<a href="https://pypi.org/project/scigantic-deeppk/">
|
|
7
|
+
<img alt="PyPI" src="https://img.shields.io/pypi/v/scigantic-deeppk" /></a>
|
|
8
|
+
<a href="https://pypi.org/project/scigantic-deeppk/">
|
|
9
|
+
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/scigantic-deeppk" /></a>
|
|
10
|
+
<a href="https://github.com/Scigantic/scigantic-deeppk/blob/main/LICENSE">
|
|
11
|
+
<img alt="License" src="https://img.shields.io/github/license/Scigantic/scigantic-deeppk" /></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
Client for [Deep-PK](https://biosig.lab.uq.edu.au/deeppk) (small-molecule pharmacokinetic and toxicity prediction across 73 endpoints), plus a mirrored copy of its CYP450 inhibitor/substrate reference data.
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import scigantic_deeppk as deeppk
|
|
18
|
+
|
|
19
|
+
df = deeppk.predict("CC(=O)OC1=CC=CC=C1C(=O)O", pred_type="metabolism") # aspirin
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```console
|
|
25
|
+
$ pip install scigantic-deeppk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Live predictions
|
|
29
|
+
|
|
30
|
+
Deep-PK ships no downloadable model or pip package, only a free async job API: POST submits SMILES, GET polls by `job_id` until the job finishes. `predict()` wraps that round trip and blocks until the result is ready:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
df = deeppk.predict("CC(=O)OC1=CC=CC=C1C(=O)O", pred_type="admet")
|
|
34
|
+
|
|
35
|
+
# Batch
|
|
36
|
+
df = deeppk.predict(["CCO", "CC(=O)OC1=CC=CC=C1C(=O)O"], pred_type="metabolism")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`pred_type` is one of `absorption`, `distribution`, `excretion`, `metabolism`, `toxicity`, `admet` (default, all 73 endpoints). A single molecule typically takes 30-90s; there is no synchronous endpoint, no documented rate limit, and no SLA, so this is fine for exploration but not for anything that needs to run offline or reproducibly.
|
|
40
|
+
|
|
41
|
+
The API's own docs page names the POST field `SMILES_string`; the field that actually works, found by testing against the live server, is lowercase `smiles` (`smiles_file` for a batch). `predict()` already gets this right, this is only worth knowing if you're calling the API directly.
|
|
42
|
+
|
|
43
|
+
## CYP450 reference data
|
|
44
|
+
|
|
45
|
+
Deep-PK's [data page](https://biosig.lab.uq.edu.au/deeppk/data) also publishes ~80 static training datasets, including CYP1A2/2C9/2C19/2D6/3A4 inhibitor and substrate sets. `cyp_reference()` reads a small (~1.5MB, 105,695-row) parquet mirror of just those ten, useful for e.g. checking compound overlap against another CYP dataset before trusting a transfer or leakage number:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
df = deeppk.cyp_reference("cyp3a4", "inhibitor")
|
|
49
|
+
df = deeppk.cyp_reference() # every isoform and kind
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Columns: `isoform` (one of `cyp1a2`/`cyp2c9`/`cyp2c19`/`cyp2d6`/`cyp3a4`), `kind` (`inhibitor`/`substrate`), `split` (Deep-PK's own `training`/`val`/`test` split), `smiles`, `label` (0/1). Row counts per isoform+kind reproduce Deep-PK's own stated totals exactly.
|
|
53
|
+
|
|
54
|
+
## Command line
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
$ scigantic-deeppk predict "CC(=O)OC1=CC=CC=C1C(=O)O" --pred-type metabolism
|
|
58
|
+
$ scigantic-deeppk cyp-reference --isoform cyp3a4 --kind inhibitor
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT-0. See [LICENSE](LICENSE). This covers the code in this package only.
|
|
64
|
+
|
|
65
|
+
## Data license
|
|
66
|
+
|
|
67
|
+
Deep-PK's data page states the CYP450 datasets are "Open Knowledge" but publishes no formal license file or terms beyond that. `cyp_reference()`'s mirror reproduces that data as-is; check with the Ascher lab (biosig.lab.uq.edu.au/deeppk) before redistributing it further if that matters for your use.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scigantic-deeppk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Client for Deep-PK's small-molecule ADMET/toxicity prediction API, plus a mirrored CYP450 inhibitor/substrate reference dataset."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT-0" }
|
|
12
|
+
authors = [{ name = "Scigantic" }]
|
|
13
|
+
keywords = ["deep-pk", "admet", "cheminformatics", "drug-discovery", "cytochrome-p450", "pharmacokinetics"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"License :: OSI Approved :: MIT No Attribution License (MIT-0)",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
"Typing :: Typed",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Chemistry",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
dependencies = [
|
|
27
|
+
"requests>=2.28,<3",
|
|
28
|
+
"pandas>=1.5,<3",
|
|
29
|
+
"pyarrow>=14,<20",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
dev = ["pytest>=7", "pytest-cov>=5", "mypy>=1.10", "pandas-stubs", "types-requests"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://scigantic.com"
|
|
37
|
+
Repository = "https://github.com/Scigantic/scigantic-deeppk"
|
|
38
|
+
Issues = "https://github.com/Scigantic/scigantic-deeppk/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
scigantic-deeppk = "scigantic_deeppk.cli:main"
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["src"]
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.package-data]
|
|
47
|
+
scigantic_deeppk = ["py.typed"]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
testpaths = ["tests"]
|
|
51
|
+
|
|
52
|
+
[tool.coverage.run]
|
|
53
|
+
source = ["scigantic_deeppk"]
|
|
54
|
+
|
|
55
|
+
[tool.mypy]
|
|
56
|
+
strict = true
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Thin client for Deep-PK (biosig.lab.uq.edu.au/deeppk) plus a mirrored
|
|
2
|
+
CYP450 reference dataset.
|
|
3
|
+
|
|
4
|
+
Deep-PK ships no downloadable model or pip package, only a free async job
|
|
5
|
+
API (verified live: POST submits `smiles` or `smiles_file`, GET polls by
|
|
6
|
+
`job_id` until the job stops reporting `{"status": "running"}`) -- so
|
|
7
|
+
`predict()` always makes a network call, there is no local/offline mode.
|
|
8
|
+
|
|
9
|
+
`cyp_reference()` reads a small (~1.5MB, 105,695-row) parquet mirror of
|
|
10
|
+
Deep-PK's own CYP1A2/2C9/2C19/2D6/3A4 inhibitor+substrate training data,
|
|
11
|
+
hosted at MIRROR_URL -- useful for checking compound overlap against
|
|
12
|
+
another CYP dataset before trusting a transfer/leakage number.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import time
|
|
19
|
+
from typing import Optional, Sequence, Union
|
|
20
|
+
|
|
21
|
+
import pandas as pd
|
|
22
|
+
import requests
|
|
23
|
+
|
|
24
|
+
__version__ = "0.1.0"
|
|
25
|
+
|
|
26
|
+
API_URL = "https://biosig.lab.uq.edu.au/deeppk/api/predict"
|
|
27
|
+
MIRROR_URL = "https://groq-seq-align.s3.amazonaws.com/deeppk/cyp_reference.parquet"
|
|
28
|
+
|
|
29
|
+
PRED_TYPES = ("absorption", "distribution", "excretion", "metabolism", "toxicity", "admet")
|
|
30
|
+
ISOFORMS = ("cyp1a2", "cyp2c9", "cyp2c19", "cyp2d6", "cyp3a4")
|
|
31
|
+
KINDS = ("inhibitor", "substrate")
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
"predict",
|
|
35
|
+
"cyp_reference",
|
|
36
|
+
"DeepPKError",
|
|
37
|
+
"PRED_TYPES",
|
|
38
|
+
"ISOFORMS",
|
|
39
|
+
"KINDS",
|
|
40
|
+
"API_URL",
|
|
41
|
+
"MIRROR_URL",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class DeepPKError(RuntimeError):
|
|
46
|
+
"""Deep-PK's API rejected a submission or a job failed."""
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def predict(
|
|
50
|
+
smiles: Union[str, Sequence[str]],
|
|
51
|
+
pred_type: str = "admet",
|
|
52
|
+
poll_interval: float = 5.0,
|
|
53
|
+
timeout: float = 300.0,
|
|
54
|
+
) -> pd.DataFrame:
|
|
55
|
+
"""Submit one SMILES string or a list of them to Deep-PK, one row per molecule.
|
|
56
|
+
|
|
57
|
+
Blocks until the job completes or `timeout` seconds pass -- Deep-PK has
|
|
58
|
+
no synchronous endpoint, so there is no way to avoid the wait. A single
|
|
59
|
+
molecule typically takes 30-90s; batches are not much slower per molecule.
|
|
60
|
+
"""
|
|
61
|
+
if pred_type not in PRED_TYPES:
|
|
62
|
+
raise ValueError(f"pred_type must be one of {PRED_TYPES}, got {pred_type!r}")
|
|
63
|
+
|
|
64
|
+
if isinstance(smiles, str):
|
|
65
|
+
resp = requests.post(API_URL, data={"smiles": smiles, "pred_type": pred_type}, timeout=30)
|
|
66
|
+
else:
|
|
67
|
+
csv_body = "smiles\n" + "\n".join(smiles) + "\n"
|
|
68
|
+
resp = requests.post(
|
|
69
|
+
API_URL,
|
|
70
|
+
data={"pred_type": pred_type},
|
|
71
|
+
files={"smiles_file": ("smiles.csv", csv_body, "text/csv")},
|
|
72
|
+
timeout=30,
|
|
73
|
+
)
|
|
74
|
+
resp.raise_for_status()
|
|
75
|
+
submission = resp.json()
|
|
76
|
+
if "job_id" not in submission:
|
|
77
|
+
raise DeepPKError(f"Deep-PK rejected the submission: {submission}")
|
|
78
|
+
job_id = submission["job_id"]
|
|
79
|
+
|
|
80
|
+
deadline = time.monotonic() + timeout
|
|
81
|
+
while True:
|
|
82
|
+
resp = requests.get(API_URL, data={"job_id": job_id}, timeout=30)
|
|
83
|
+
resp.raise_for_status()
|
|
84
|
+
result = resp.json()
|
|
85
|
+
if isinstance(result, str):
|
|
86
|
+
result = json.loads(result)
|
|
87
|
+
if isinstance(result, dict) and result.get("status") == "running":
|
|
88
|
+
if time.monotonic() > deadline:
|
|
89
|
+
raise TimeoutError(f"Deep-PK job {job_id} still running after {timeout}s")
|
|
90
|
+
time.sleep(poll_interval)
|
|
91
|
+
continue
|
|
92
|
+
if not isinstance(result, dict) or "message" in result:
|
|
93
|
+
raise DeepPKError(f"Deep-PK job {job_id} failed: {result}")
|
|
94
|
+
break
|
|
95
|
+
|
|
96
|
+
rows = [result[str(i)] for i in range(len(result))]
|
|
97
|
+
return pd.DataFrame(rows)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def cyp_reference(isoform: Optional[str] = None, kind: Optional[str] = None) -> pd.DataFrame:
|
|
101
|
+
"""Load Deep-PK's own CYP450 inhibitor/substrate training data.
|
|
102
|
+
|
|
103
|
+
`isoform` one of ISOFORMS, `kind` one of KINDS; leave either as None
|
|
104
|
+
for every isoform/kind. Columns: isoform, kind, split (Deep-PK's own
|
|
105
|
+
training/val/test), smiles, label (0/1).
|
|
106
|
+
"""
|
|
107
|
+
if isoform is not None and isoform not in ISOFORMS:
|
|
108
|
+
raise ValueError(f"isoform must be one of {ISOFORMS}, got {isoform!r}")
|
|
109
|
+
if kind is not None and kind not in KINDS:
|
|
110
|
+
raise ValueError(f"kind must be one of {KINDS}, got {kind!r}")
|
|
111
|
+
|
|
112
|
+
df = pd.read_parquet(MIRROR_URL)
|
|
113
|
+
if isoform is not None:
|
|
114
|
+
df = df[df["isoform"] == isoform]
|
|
115
|
+
if kind is not None:
|
|
116
|
+
df = df[df["kind"] == kind]
|
|
117
|
+
return df.reset_index(drop=True)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Command-line interface: `scigantic-deeppk predict` and `scigantic-deeppk cyp-reference`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from typing import Sequence, cast
|
|
8
|
+
|
|
9
|
+
from . import ISOFORMS, KINDS, PRED_TYPES
|
|
10
|
+
from . import cyp_reference as run_cyp_reference
|
|
11
|
+
from . import predict as run_predict
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _cmd_predict(args: argparse.Namespace) -> int:
|
|
15
|
+
df = run_predict(args.smiles, pred_type=args.pred_type, timeout=args.timeout)
|
|
16
|
+
print(df.to_csv(sep="\t", index=False), end="")
|
|
17
|
+
return 0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _cmd_cyp_reference(args: argparse.Namespace) -> int:
|
|
21
|
+
df = run_cyp_reference(isoform=args.isoform, kind=args.kind)
|
|
22
|
+
print(df.to_csv(sep="\t", index=False), end="")
|
|
23
|
+
return 0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
27
|
+
parser = argparse.ArgumentParser(prog="scigantic-deeppk")
|
|
28
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
29
|
+
|
|
30
|
+
predict_parser = subparsers.add_parser(
|
|
31
|
+
"predict", help="submit one or more SMILES to Deep-PK and print predictions"
|
|
32
|
+
)
|
|
33
|
+
predict_parser.add_argument("smiles", nargs="+")
|
|
34
|
+
predict_parser.add_argument("--pred-type", choices=PRED_TYPES, default="admet")
|
|
35
|
+
predict_parser.add_argument("--timeout", type=float, default=300.0)
|
|
36
|
+
predict_parser.set_defaults(
|
|
37
|
+
func=lambda a: _cmd_predict(
|
|
38
|
+
argparse.Namespace(
|
|
39
|
+
smiles=a.smiles[0] if len(a.smiles) == 1 else a.smiles,
|
|
40
|
+
pred_type=a.pred_type,
|
|
41
|
+
timeout=a.timeout,
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
ref_parser = subparsers.add_parser(
|
|
47
|
+
"cyp-reference", help="print Deep-PK's own mirrored CYP450 inhibitor/substrate data"
|
|
48
|
+
)
|
|
49
|
+
ref_parser.add_argument("--isoform", choices=ISOFORMS, default=None)
|
|
50
|
+
ref_parser.add_argument("--kind", choices=KINDS, default=None)
|
|
51
|
+
ref_parser.set_defaults(func=_cmd_cyp_reference)
|
|
52
|
+
|
|
53
|
+
args = parser.parse_args(argv)
|
|
54
|
+
return cast(int, args.func(args))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
sys.exit(main())
|
|
File without changes
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scigantic-deeppk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Client for Deep-PK's small-molecule ADMET/toxicity prediction API, plus a mirrored CYP450 inhibitor/substrate reference dataset.
|
|
5
|
+
Author: Scigantic
|
|
6
|
+
License: MIT-0
|
|
7
|
+
Project-URL: Homepage, https://scigantic.com
|
|
8
|
+
Project-URL: Repository, https://github.com/Scigantic/scigantic-deeppk
|
|
9
|
+
Project-URL: Issues, https://github.com/Scigantic/scigantic-deeppk/issues
|
|
10
|
+
Keywords: deep-pk,admet,cheminformatics,drug-discovery,cytochrome-p450,pharmacokinetics
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT No Attribution License (MIT-0)
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: requests<3,>=2.28
|
|
24
|
+
Requires-Dist: pandas<3,>=1.5
|
|
25
|
+
Requires-Dist: pyarrow<20,>=14
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
29
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
30
|
+
Requires-Dist: pandas-stubs; extra == "dev"
|
|
31
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
<h1 align="center">scigantic-deeppk</h1>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://github.com/Scigantic/scigantic-deeppk/actions/workflows/ci.yml">
|
|
38
|
+
<img alt="CI" src="https://github.com/Scigantic/scigantic-deeppk/actions/workflows/ci.yml/badge.svg" /></a>
|
|
39
|
+
<a href="https://pypi.org/project/scigantic-deeppk/">
|
|
40
|
+
<img alt="PyPI" src="https://img.shields.io/pypi/v/scigantic-deeppk" /></a>
|
|
41
|
+
<a href="https://pypi.org/project/scigantic-deeppk/">
|
|
42
|
+
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/scigantic-deeppk" /></a>
|
|
43
|
+
<a href="https://github.com/Scigantic/scigantic-deeppk/blob/main/LICENSE">
|
|
44
|
+
<img alt="License" src="https://img.shields.io/github/license/Scigantic/scigantic-deeppk" /></a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
Client for [Deep-PK](https://biosig.lab.uq.edu.au/deeppk) (small-molecule pharmacokinetic and toxicity prediction across 73 endpoints), plus a mirrored copy of its CYP450 inhibitor/substrate reference data.
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import scigantic_deeppk as deeppk
|
|
51
|
+
|
|
52
|
+
df = deeppk.predict("CC(=O)OC1=CC=CC=C1C(=O)O", pred_type="metabolism") # aspirin
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```console
|
|
58
|
+
$ pip install scigantic-deeppk
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Live predictions
|
|
62
|
+
|
|
63
|
+
Deep-PK ships no downloadable model or pip package, only a free async job API: POST submits SMILES, GET polls by `job_id` until the job finishes. `predict()` wraps that round trip and blocks until the result is ready:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
df = deeppk.predict("CC(=O)OC1=CC=CC=C1C(=O)O", pred_type="admet")
|
|
67
|
+
|
|
68
|
+
# Batch
|
|
69
|
+
df = deeppk.predict(["CCO", "CC(=O)OC1=CC=CC=C1C(=O)O"], pred_type="metabolism")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`pred_type` is one of `absorption`, `distribution`, `excretion`, `metabolism`, `toxicity`, `admet` (default, all 73 endpoints). A single molecule typically takes 30-90s; there is no synchronous endpoint, no documented rate limit, and no SLA, so this is fine for exploration but not for anything that needs to run offline or reproducibly.
|
|
73
|
+
|
|
74
|
+
The API's own docs page names the POST field `SMILES_string`; the field that actually works, found by testing against the live server, is lowercase `smiles` (`smiles_file` for a batch). `predict()` already gets this right, this is only worth knowing if you're calling the API directly.
|
|
75
|
+
|
|
76
|
+
## CYP450 reference data
|
|
77
|
+
|
|
78
|
+
Deep-PK's [data page](https://biosig.lab.uq.edu.au/deeppk/data) also publishes ~80 static training datasets, including CYP1A2/2C9/2C19/2D6/3A4 inhibitor and substrate sets. `cyp_reference()` reads a small (~1.5MB, 105,695-row) parquet mirror of just those ten, useful for e.g. checking compound overlap against another CYP dataset before trusting a transfer or leakage number:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
df = deeppk.cyp_reference("cyp3a4", "inhibitor")
|
|
82
|
+
df = deeppk.cyp_reference() # every isoform and kind
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Columns: `isoform` (one of `cyp1a2`/`cyp2c9`/`cyp2c19`/`cyp2d6`/`cyp3a4`), `kind` (`inhibitor`/`substrate`), `split` (Deep-PK's own `training`/`val`/`test` split), `smiles`, `label` (0/1). Row counts per isoform+kind reproduce Deep-PK's own stated totals exactly.
|
|
86
|
+
|
|
87
|
+
## Command line
|
|
88
|
+
|
|
89
|
+
```console
|
|
90
|
+
$ scigantic-deeppk predict "CC(=O)OC1=CC=CC=C1C(=O)O" --pred-type metabolism
|
|
91
|
+
$ scigantic-deeppk cyp-reference --isoform cyp3a4 --kind inhibitor
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
MIT-0. See [LICENSE](LICENSE). This covers the code in this package only.
|
|
97
|
+
|
|
98
|
+
## Data license
|
|
99
|
+
|
|
100
|
+
Deep-PK's data page states the CYP450 datasets are "Open Knowledge" but publishes no formal license file or terms beyond that. `cyp_reference()`'s mirror reproduces that data as-is; check with the Ascher lab (biosig.lab.uq.edu.au/deeppk) before redistributing it further if that matters for your use.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/scigantic_deeppk/__init__.py
|
|
5
|
+
src/scigantic_deeppk/__main__.py
|
|
6
|
+
src/scigantic_deeppk/cli.py
|
|
7
|
+
src/scigantic_deeppk/py.typed
|
|
8
|
+
src/scigantic_deeppk.egg-info/PKG-INFO
|
|
9
|
+
src/scigantic_deeppk.egg-info/SOURCES.txt
|
|
10
|
+
src/scigantic_deeppk.egg-info/dependency_links.txt
|
|
11
|
+
src/scigantic_deeppk.egg-info/entry_points.txt
|
|
12
|
+
src/scigantic_deeppk.egg-info/requires.txt
|
|
13
|
+
src/scigantic_deeppk.egg-info/top_level.txt
|
|
14
|
+
tests/test_cli.py
|
|
15
|
+
tests/test_cyp_reference.py
|
|
16
|
+
tests/test_predict.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
scigantic_deeppk
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from scigantic_deeppk.cli import main
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_cyp_reference_command_prints_tsv(capsys):
|
|
7
|
+
rc = main(["cyp-reference", "--isoform", "cyp3a4", "--kind", "substrate"])
|
|
8
|
+
assert rc == 0
|
|
9
|
+
out = capsys.readouterr().out
|
|
10
|
+
lines = out.strip().split("\n")
|
|
11
|
+
assert lines[0].split("\t") == ["isoform", "kind", "split", "smiles", "label"]
|
|
12
|
+
assert len(lines) == 1552 # header + 1551 rows
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_no_command_errors():
|
|
16
|
+
with pytest.raises(SystemExit):
|
|
17
|
+
main([])
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_invalid_isoform_choice_errors():
|
|
21
|
+
with pytest.raises(SystemExit):
|
|
22
|
+
main(["cyp-reference", "--isoform", "not_a_real_isoform"])
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
import scigantic_deeppk as deeppk
|
|
4
|
+
|
|
5
|
+
# Row counts per isoform+kind, reproduced exactly from Deep-PK's own stated
|
|
6
|
+
# totals at biosig.lab.uq.edu.au/deeppk/data (checked 2026-09-06). Update if
|
|
7
|
+
# the mirror is ever refreshed from a newer Deep-PK release.
|
|
8
|
+
_EXPECTED_COUNTS = {
|
|
9
|
+
("cyp1a2", "inhibitor"): 19891,
|
|
10
|
+
("cyp1a2", "substrate"): 366,
|
|
11
|
+
("cyp2c19", "inhibitor"): 19652,
|
|
12
|
+
("cyp2c19", "substrate"): 261,
|
|
13
|
+
("cyp2c9", "inhibitor"): 19283,
|
|
14
|
+
("cyp2c9", "substrate"): 1034,
|
|
15
|
+
("cyp2d6", "inhibitor"): 19700,
|
|
16
|
+
("cyp2d6", "substrate"): 917,
|
|
17
|
+
("cyp3a4", "inhibitor"): 23040,
|
|
18
|
+
("cyp3a4", "substrate"): 1551,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_full_mirror_shape_and_columns():
|
|
23
|
+
df = deeppk.cyp_reference()
|
|
24
|
+
assert len(df) == sum(_EXPECTED_COUNTS.values())
|
|
25
|
+
assert list(df.columns) == ["isoform", "kind", "split", "smiles", "label"]
|
|
26
|
+
assert set(df["label"].unique()) <= {0, 1}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_filter_by_isoform_and_kind_matches_site_totals():
|
|
30
|
+
for (isoform, kind), expected in _EXPECTED_COUNTS.items():
|
|
31
|
+
df = deeppk.cyp_reference(isoform=isoform, kind=kind)
|
|
32
|
+
assert len(df) == expected
|
|
33
|
+
assert (df["isoform"] == isoform).all()
|
|
34
|
+
assert (df["kind"] == kind).all()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_split_column_uses_deeppks_own_split():
|
|
38
|
+
df = deeppk.cyp_reference("cyp3a4", "inhibitor")
|
|
39
|
+
assert set(df["split"]) == {"training", "val", "test"}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_invalid_isoform_raises():
|
|
43
|
+
with pytest.raises(ValueError):
|
|
44
|
+
deeppk.cyp_reference(isoform="not_a_real_isoform")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_invalid_kind_raises():
|
|
48
|
+
with pytest.raises(ValueError):
|
|
49
|
+
deeppk.cyp_reference(kind="not_a_real_kind")
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
import scigantic_deeppk as deeppk
|
|
4
|
+
|
|
5
|
+
_ASPIRIN = "CC(=O)OC1=CC=CC=C1C(=O)O"
|
|
6
|
+
|
|
7
|
+
# Deep-PK has no SLA and CI runs several matrix jobs against it concurrently,
|
|
8
|
+
# so the timeout here is generous on purpose -- a real job usually finishes
|
|
9
|
+
# in under 90s, but this leaves room for a slow day on their server.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_invalid_pred_type_raises():
|
|
13
|
+
with pytest.raises(ValueError):
|
|
14
|
+
deeppk.predict(_ASPIRIN, pred_type="not_a_real_pred_type")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_single_molecule_metabolism_prediction():
|
|
18
|
+
df = deeppk.predict(_ASPIRIN, pred_type="metabolism", poll_interval=8, timeout=280)
|
|
19
|
+
assert len(df) == 1
|
|
20
|
+
assert df["SMILES"].iloc[0] == _ASPIRIN
|
|
21
|
+
assert "[Metabolism/CYP 3A4 Inhibitor] Predictions" in df.columns
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_batch_prediction_returns_one_row_per_molecule():
|
|
25
|
+
smiles = [_ASPIRIN, "CC(C)Cc1ccc(cc1)C(C)C(=O)O"] # aspirin, ibuprofen
|
|
26
|
+
df = deeppk.predict(smiles, pred_type="metabolism", poll_interval=8, timeout=280)
|
|
27
|
+
assert len(df) == 2
|
|
28
|
+
assert list(df["SMILES"]) == smiles
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def test_timeout_raises_before_job_ever_finishes():
|
|
32
|
+
with pytest.raises(TimeoutError):
|
|
33
|
+
deeppk.predict(_ASPIRIN, pred_type="admet", poll_interval=1, timeout=0.01)
|