scigantic-deeppk 0.1.0__py3-none-any.whl

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.
@@ -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,8 @@
1
+ """Enables `python -m scigantic_deeppk`, same commands as the `scigantic-deeppk` console script."""
2
+
3
+ import sys
4
+
5
+ from .cli import main
6
+
7
+ if __name__ == "__main__":
8
+ sys.exit(main())
@@ -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,10 @@
1
+ scigantic_deeppk/__init__.py,sha256=v1m0BK2ZqD2HINhes72kwjRB05Ha0z37vbDMQ1VSTzs,4233
2
+ scigantic_deeppk/__main__.py,sha256=TAoUXLftFR4Ys-PdmZ60KIx5kgvE6XqcYGg0a4F1A7U,184
3
+ scigantic_deeppk/cli.py,sha256=Q4w8wJnC7Gby2xVaiKkllv8MJtwY3DIRNtohHo0GIJo,1977
4
+ scigantic_deeppk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ scigantic_deeppk-0.1.0.dist-info/licenses/LICENSE,sha256=RiBhEtE0qZ65CeSf05VqMHWAhMh0ETETZAj4TEtscWE,904
6
+ scigantic_deeppk-0.1.0.dist-info/METADATA,sha256=hnXem4L0MlqZlg1jCPFGO2Cgm7OHECe0irBh1UuJ94o,4999
7
+ scigantic_deeppk-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
8
+ scigantic_deeppk-0.1.0.dist-info/entry_points.txt,sha256=nWDLrqVz8_O6AoBnIIXXBWLZvZG6rqHiQ0-849gCNNo,63
9
+ scigantic_deeppk-0.1.0.dist-info/top_level.txt,sha256=TyOunWp1J67yySMeXoXF0GJPg_XPe56Syj7O3yYm2Zo,17
10
+ scigantic_deeppk-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ scigantic-deeppk = scigantic_deeppk.cli:main
@@ -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 @@
1
+ scigantic_deeppk