PyCule 0.2.2b0__tar.gz → 0.3.1__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.
- pycule-0.3.1/.github/workflows/ci.yml +38 -0
- pycule-0.3.1/.github/workflows/publish-to-pypi.yml +34 -0
- pycule-0.3.1/.gitignore +7 -0
- pycule-0.3.1/PKG-INFO +138 -0
- pycule-0.3.1/PyCule.egg-info/PKG-INFO +138 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/PyCule.egg-info/SOURCES.txt +9 -1
- pycule-0.3.1/PyCule.egg-info/scm_file_list.json +18 -0
- pycule-0.3.1/PyCule.egg-info/scm_version.json +8 -0
- pycule-0.3.1/README.md +111 -0
- pycule-0.3.1/pycule/__init__.py +12 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/pycule/core.py +328 -100
- pycule-0.3.1/pycule/decorators.py +180 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/pycule/urls.py +37 -6
- pycule-0.3.1/pyproject.toml +8 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/setup.py +3 -12
- pycule-0.3.1/tests/test_enamine.py +145 -0
- pycule-0.3.1/tests/test_ultimate_mcule.py +55 -0
- PyCule-0.2.2b0/PKG-INFO +0 -21
- PyCule-0.2.2b0/PyCule.egg-info/PKG-INFO +0 -21
- PyCule-0.2.2b0/README.md +0 -6
- PyCule-0.2.2b0/pycule/__init__.py +0 -5
- PyCule-0.2.2b0/pycule/decorators.py +0 -143
- {PyCule-0.2.2b0 → pycule-0.3.1}/PyCule.egg-info/dependency_links.txt +0 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/PyCule.egg-info/requires.txt +0 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/PyCule.egg-info/top_level.txt +0 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/pycule/callbacks.py +0 -0
- {PyCule-0.2.2b0 → pycule-0.3.1}/setup.cfg +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
max-parallel: 3
|
|
17
|
+
matrix:
|
|
18
|
+
python-version:
|
|
19
|
+
- "3.11"
|
|
20
|
+
- "3.12"
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
# setuptools_scm derives the package version from git tag history;
|
|
26
|
+
# a shallow clone wouldn't reliably see the tags.
|
|
27
|
+
fetch-depth: 0
|
|
28
|
+
- name: Python setup ${{ matrix.python-version }}
|
|
29
|
+
uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
pip install -e .
|
|
36
|
+
pip install pytest
|
|
37
|
+
- name: Run tests
|
|
38
|
+
run: pytest
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
name: Build and publish pycule on PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
# setuptools_scm derives the package version from the git tag;
|
|
19
|
+
# a shallow clone wouldn't reliably see it.
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
- name: Python setup
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
- name: Build dist
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip build
|
|
28
|
+
python -m build --sdist
|
|
29
|
+
- name: Publish to PyPI
|
|
30
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
31
|
+
with:
|
|
32
|
+
# Defensive no-op if this exact tag/version was already published
|
|
33
|
+
# (e.g. a re-run), rather than a hard failure.
|
|
34
|
+
skip-existing: true
|
pycule-0.3.1/.gitignore
ADDED
pycule-0.3.1/PKG-INFO
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyCule
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Python wrapper for the MCule Ultimate API
|
|
5
|
+
Home-page: https://github.com/xchem/pycule.git
|
|
6
|
+
Author: Warren Thompson
|
|
7
|
+
Author-email: waztom@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: requests>=2.24.0
|
|
17
|
+
Requires-Dist: ratelimit>=2.2.1
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: license
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
PyCule
|
|
29
|
+
==============================
|
|
30
|
+
[//]: # (Badges)
|
|
31
|
+
[](https://badge.fury.io/py/PyCule)
|
|
32
|
+
|
|
33
|
+
Wrapper to access the MCule and Enamine APIs
|
|
34
|
+
|
|
35
|
+
## MCule
|
|
36
|
+
|
|
37
|
+
`MCuleWrapper` talks to the standard [MCule API](https://doc.mcule.com/api)
|
|
38
|
+
(base url `https://mcule.com/api/v1/`). Public endpoints (database files, compound
|
|
39
|
+
details, InChIKey lookup, single query search) work without authentication;
|
|
40
|
+
everything else requires an API access token sent as an `Authorization: Token <token>`
|
|
41
|
+
header. To request a token, email MCule with a summary of your intended use, per
|
|
42
|
+
their docs.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from pycule import MCuleWrapper
|
|
46
|
+
|
|
47
|
+
mcule = MCuleWrapper(authorisation_token="your-mcule-token")
|
|
48
|
+
|
|
49
|
+
mcule.databasefiles()
|
|
50
|
+
mcule.compounddetails("Mcule-1234567")
|
|
51
|
+
mcule.inchikeylookup("IHHITLNORGKBTP-UHFFFAOYSA-N")
|
|
52
|
+
mcule.singlequerysearch("CCO")
|
|
53
|
+
|
|
54
|
+
# Protected endpoints (require a valid token).
|
|
55
|
+
mcule.compoundavailability("Mcule-1234567")
|
|
56
|
+
mcule.compoundprices("Mcule-1234567")
|
|
57
|
+
mcule.compoundpricesamount("Mcule-1234567", amount=10)
|
|
58
|
+
mcule.multiplequeriessearch(["Mcule-1234567", "CCO"])
|
|
59
|
+
mcule.multiplequerieswithavailability(["Mcule-1234567", "CCO"])
|
|
60
|
+
mcule.similaritysearch("CCO", limit=5, threshold=0.7)
|
|
61
|
+
mcule.substructuresearch("CCO")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Documented rate limits:
|
|
65
|
+
|
|
66
|
+
| | Burst | Sustained |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Anonymous (no token) | 10/min | 100/day |
|
|
69
|
+
| Authenticated (with token) | 20/min | 200/hour |
|
|
70
|
+
|
|
71
|
+
The [Compound list details](https://doc.mcule.com/api#compound_list_details1) and
|
|
72
|
+
[Quote Request](https://doc.mcule.com/api#quote_request1) (`POST`) endpoints have their
|
|
73
|
+
own, stricter limits — see the docs for details. On a 429 response, check the
|
|
74
|
+
`Retry-After` header/body before retrying.
|
|
75
|
+
|
|
76
|
+
## MCule ULTIMATE
|
|
77
|
+
|
|
78
|
+
`UltimateMCuleWrapper` talks to the separate
|
|
79
|
+
[MCule ULTIMATE API](https://doc.mcule.com/doku.php?id=ultimate-api) (base url
|
|
80
|
+
`https://ultimateapp.mcule.com/api/v1/`), which searches MCule's larger
|
|
81
|
+
make-on-demand "Ultimate" compound space. It requires its own access token
|
|
82
|
+
(also requested from MCule by email) and is **not** interchangeable with a
|
|
83
|
+
standard MCule API token.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from pycule import UltimateMCuleWrapper
|
|
87
|
+
|
|
88
|
+
ultimate = UltimateMCuleWrapper(authorisation_token="your-ultimate-token")
|
|
89
|
+
|
|
90
|
+
ultimate.exact_search("CCO")
|
|
91
|
+
ultimate.similarity_search("CCO", limit=5, sim_threshold=0.7)
|
|
92
|
+
ultimate.substructure_search("CCO", limit=5)
|
|
93
|
+
ultimate.price_search_multi(["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10])
|
|
94
|
+
ultimate.quote_request_multi(
|
|
95
|
+
["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10], delivery_country="GB"
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Documented rate limits:
|
|
100
|
+
|
|
101
|
+
| | Per minute | Per day |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| Anonymous (no token) | 10 | 100 |
|
|
104
|
+
| Authenticated (with token) | 100 | 1000 |
|
|
105
|
+
|
|
106
|
+
## Enamine
|
|
107
|
+
|
|
108
|
+
`EnamineWrapper` talks to the current [EnamineStore API](https://enaminestore.com/documentation)
|
|
109
|
+
(JWT-based auth, `/api/v2` endpoints). Authentication, token refresh and HTTP 429
|
|
110
|
+
(rate limit) retries with backoff are all handled transparently.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from pycule import EnamineWrapper
|
|
114
|
+
|
|
115
|
+
enamine = EnamineWrapper(email="you@example.com", password="your-password")
|
|
116
|
+
|
|
117
|
+
# Exact-match searches (synchronous). Accept a single identifier or a list -
|
|
118
|
+
# lists are automatically split into batches of `batch_size` (default 2000,
|
|
119
|
+
# Enamine's documented recommendation for the Code Search endpoint).
|
|
120
|
+
enamine.compoundidsearch(["EN300-17264", "EN300-456830", "Z234859494"])
|
|
121
|
+
enamine.cassearch(["110-86-1", "91-17-8"], catalog="building-blocks")
|
|
122
|
+
enamine.mfcdsearch(["MFCD00011732"], catalog="building-blocks")
|
|
123
|
+
|
|
124
|
+
# Exact SMILES search (asynchronous "delayed result", polled to completion).
|
|
125
|
+
enamine.exactsearch(["C=1C=CN=CC1", "CC(N)=O"], catalog="building-blocks")
|
|
126
|
+
|
|
127
|
+
# Substructure/similarity searches only accept a single query SMILES per call.
|
|
128
|
+
enamine.substructuresearch("CC(N)=O", catalog="building-blocks")
|
|
129
|
+
enamine.similaritysearch("CC(N)=O", catalog="building-blocks", similarity_value=0.8)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Valid `catalog` values: `"building-blocks"`, `"screening-compounds"`,
|
|
133
|
+
`"made-building-blocks"`, `"real"`, `"bioactive-compounds"`.
|
|
134
|
+
|
|
135
|
+
Enamine does not currently publish its API rate limits. Rather than guessing,
|
|
136
|
+
requests are retried with exponential backoff when an HTTP 429 is received; once
|
|
137
|
+
the real limits are known, this can be tightened up in
|
|
138
|
+
[`pycule/decorators.py`](pycule/decorators.py).
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyCule
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Python wrapper for the MCule Ultimate API
|
|
5
|
+
Home-page: https://github.com/xchem/pycule.git
|
|
6
|
+
Author: Warren Thompson
|
|
7
|
+
Author-email: waztom@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: requests>=2.24.0
|
|
17
|
+
Requires-Dist: ratelimit>=2.2.1
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: author-email
|
|
20
|
+
Dynamic: classifier
|
|
21
|
+
Dynamic: description
|
|
22
|
+
Dynamic: description-content-type
|
|
23
|
+
Dynamic: home-page
|
|
24
|
+
Dynamic: license
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
PyCule
|
|
29
|
+
==============================
|
|
30
|
+
[//]: # (Badges)
|
|
31
|
+
[](https://badge.fury.io/py/PyCule)
|
|
32
|
+
|
|
33
|
+
Wrapper to access the MCule and Enamine APIs
|
|
34
|
+
|
|
35
|
+
## MCule
|
|
36
|
+
|
|
37
|
+
`MCuleWrapper` talks to the standard [MCule API](https://doc.mcule.com/api)
|
|
38
|
+
(base url `https://mcule.com/api/v1/`). Public endpoints (database files, compound
|
|
39
|
+
details, InChIKey lookup, single query search) work without authentication;
|
|
40
|
+
everything else requires an API access token sent as an `Authorization: Token <token>`
|
|
41
|
+
header. To request a token, email MCule with a summary of your intended use, per
|
|
42
|
+
their docs.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from pycule import MCuleWrapper
|
|
46
|
+
|
|
47
|
+
mcule = MCuleWrapper(authorisation_token="your-mcule-token")
|
|
48
|
+
|
|
49
|
+
mcule.databasefiles()
|
|
50
|
+
mcule.compounddetails("Mcule-1234567")
|
|
51
|
+
mcule.inchikeylookup("IHHITLNORGKBTP-UHFFFAOYSA-N")
|
|
52
|
+
mcule.singlequerysearch("CCO")
|
|
53
|
+
|
|
54
|
+
# Protected endpoints (require a valid token).
|
|
55
|
+
mcule.compoundavailability("Mcule-1234567")
|
|
56
|
+
mcule.compoundprices("Mcule-1234567")
|
|
57
|
+
mcule.compoundpricesamount("Mcule-1234567", amount=10)
|
|
58
|
+
mcule.multiplequeriessearch(["Mcule-1234567", "CCO"])
|
|
59
|
+
mcule.multiplequerieswithavailability(["Mcule-1234567", "CCO"])
|
|
60
|
+
mcule.similaritysearch("CCO", limit=5, threshold=0.7)
|
|
61
|
+
mcule.substructuresearch("CCO")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Documented rate limits:
|
|
65
|
+
|
|
66
|
+
| | Burst | Sustained |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| Anonymous (no token) | 10/min | 100/day |
|
|
69
|
+
| Authenticated (with token) | 20/min | 200/hour |
|
|
70
|
+
|
|
71
|
+
The [Compound list details](https://doc.mcule.com/api#compound_list_details1) and
|
|
72
|
+
[Quote Request](https://doc.mcule.com/api#quote_request1) (`POST`) endpoints have their
|
|
73
|
+
own, stricter limits — see the docs for details. On a 429 response, check the
|
|
74
|
+
`Retry-After` header/body before retrying.
|
|
75
|
+
|
|
76
|
+
## MCule ULTIMATE
|
|
77
|
+
|
|
78
|
+
`UltimateMCuleWrapper` talks to the separate
|
|
79
|
+
[MCule ULTIMATE API](https://doc.mcule.com/doku.php?id=ultimate-api) (base url
|
|
80
|
+
`https://ultimateapp.mcule.com/api/v1/`), which searches MCule's larger
|
|
81
|
+
make-on-demand "Ultimate" compound space. It requires its own access token
|
|
82
|
+
(also requested from MCule by email) and is **not** interchangeable with a
|
|
83
|
+
standard MCule API token.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from pycule import UltimateMCuleWrapper
|
|
87
|
+
|
|
88
|
+
ultimate = UltimateMCuleWrapper(authorisation_token="your-ultimate-token")
|
|
89
|
+
|
|
90
|
+
ultimate.exact_search("CCO")
|
|
91
|
+
ultimate.similarity_search("CCO", limit=5, sim_threshold=0.7)
|
|
92
|
+
ultimate.substructure_search("CCO", limit=5)
|
|
93
|
+
ultimate.price_search_multi(["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10])
|
|
94
|
+
ultimate.quote_request_multi(
|
|
95
|
+
["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10], delivery_country="GB"
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Documented rate limits:
|
|
100
|
+
|
|
101
|
+
| | Per minute | Per day |
|
|
102
|
+
| --- | --- | --- |
|
|
103
|
+
| Anonymous (no token) | 10 | 100 |
|
|
104
|
+
| Authenticated (with token) | 100 | 1000 |
|
|
105
|
+
|
|
106
|
+
## Enamine
|
|
107
|
+
|
|
108
|
+
`EnamineWrapper` talks to the current [EnamineStore API](https://enaminestore.com/documentation)
|
|
109
|
+
(JWT-based auth, `/api/v2` endpoints). Authentication, token refresh and HTTP 429
|
|
110
|
+
(rate limit) retries with backoff are all handled transparently.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from pycule import EnamineWrapper
|
|
114
|
+
|
|
115
|
+
enamine = EnamineWrapper(email="you@example.com", password="your-password")
|
|
116
|
+
|
|
117
|
+
# Exact-match searches (synchronous). Accept a single identifier or a list -
|
|
118
|
+
# lists are automatically split into batches of `batch_size` (default 2000,
|
|
119
|
+
# Enamine's documented recommendation for the Code Search endpoint).
|
|
120
|
+
enamine.compoundidsearch(["EN300-17264", "EN300-456830", "Z234859494"])
|
|
121
|
+
enamine.cassearch(["110-86-1", "91-17-8"], catalog="building-blocks")
|
|
122
|
+
enamine.mfcdsearch(["MFCD00011732"], catalog="building-blocks")
|
|
123
|
+
|
|
124
|
+
# Exact SMILES search (asynchronous "delayed result", polled to completion).
|
|
125
|
+
enamine.exactsearch(["C=1C=CN=CC1", "CC(N)=O"], catalog="building-blocks")
|
|
126
|
+
|
|
127
|
+
# Substructure/similarity searches only accept a single query SMILES per call.
|
|
128
|
+
enamine.substructuresearch("CC(N)=O", catalog="building-blocks")
|
|
129
|
+
enamine.similaritysearch("CC(N)=O", catalog="building-blocks", similarity_value=0.8)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Valid `catalog` values: `"building-blocks"`, `"screening-compounds"`,
|
|
133
|
+
`"made-building-blocks"`, `"real"`, `"bioactive-compounds"`.
|
|
134
|
+
|
|
135
|
+
Enamine does not currently publish its API rate limits. Rather than guessing,
|
|
136
|
+
requests are retried with exponential backoff when an HTTP 429 is received; once
|
|
137
|
+
the real limits are known, this can be tightened up in
|
|
138
|
+
[`pycule/decorators.py`](pycule/decorators.py).
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
.gitignore
|
|
1
2
|
README.md
|
|
3
|
+
pyproject.toml
|
|
2
4
|
setup.cfg
|
|
3
5
|
setup.py
|
|
6
|
+
.github/workflows/ci.yml
|
|
7
|
+
.github/workflows/publish-to-pypi.yml
|
|
4
8
|
PyCule.egg-info/PKG-INFO
|
|
5
9
|
PyCule.egg-info/SOURCES.txt
|
|
6
10
|
PyCule.egg-info/dependency_links.txt
|
|
7
11
|
PyCule.egg-info/requires.txt
|
|
12
|
+
PyCule.egg-info/scm_file_list.json
|
|
13
|
+
PyCule.egg-info/scm_version.json
|
|
8
14
|
PyCule.egg-info/top_level.txt
|
|
9
15
|
pycule/__init__.py
|
|
10
16
|
pycule/callbacks.py
|
|
11
17
|
pycule/core.py
|
|
12
18
|
pycule/decorators.py
|
|
13
|
-
pycule/urls.py
|
|
19
|
+
pycule/urls.py
|
|
20
|
+
tests/test_enamine.py
|
|
21
|
+
tests/test_ultimate_mcule.py
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
".github/workflows/ci.yml",
|
|
4
|
+
".github/workflows/publish-to-pypi.yml",
|
|
5
|
+
".gitignore",
|
|
6
|
+
"README.md",
|
|
7
|
+
"pycule/__init__.py",
|
|
8
|
+
"pycule/callbacks.py",
|
|
9
|
+
"pycule/core.py",
|
|
10
|
+
"pycule/decorators.py",
|
|
11
|
+
"pycule/urls.py",
|
|
12
|
+
"pyproject.toml",
|
|
13
|
+
"setup.cfg",
|
|
14
|
+
"setup.py",
|
|
15
|
+
"tests/test_enamine.py",
|
|
16
|
+
"tests/test_ultimate_mcule.py"
|
|
17
|
+
]
|
|
18
|
+
}
|
pycule-0.3.1/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
PyCule
|
|
2
|
+
==============================
|
|
3
|
+
[//]: # (Badges)
|
|
4
|
+
[](https://badge.fury.io/py/PyCule)
|
|
5
|
+
|
|
6
|
+
Wrapper to access the MCule and Enamine APIs
|
|
7
|
+
|
|
8
|
+
## MCule
|
|
9
|
+
|
|
10
|
+
`MCuleWrapper` talks to the standard [MCule API](https://doc.mcule.com/api)
|
|
11
|
+
(base url `https://mcule.com/api/v1/`). Public endpoints (database files, compound
|
|
12
|
+
details, InChIKey lookup, single query search) work without authentication;
|
|
13
|
+
everything else requires an API access token sent as an `Authorization: Token <token>`
|
|
14
|
+
header. To request a token, email MCule with a summary of your intended use, per
|
|
15
|
+
their docs.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from pycule import MCuleWrapper
|
|
19
|
+
|
|
20
|
+
mcule = MCuleWrapper(authorisation_token="your-mcule-token")
|
|
21
|
+
|
|
22
|
+
mcule.databasefiles()
|
|
23
|
+
mcule.compounddetails("Mcule-1234567")
|
|
24
|
+
mcule.inchikeylookup("IHHITLNORGKBTP-UHFFFAOYSA-N")
|
|
25
|
+
mcule.singlequerysearch("CCO")
|
|
26
|
+
|
|
27
|
+
# Protected endpoints (require a valid token).
|
|
28
|
+
mcule.compoundavailability("Mcule-1234567")
|
|
29
|
+
mcule.compoundprices("Mcule-1234567")
|
|
30
|
+
mcule.compoundpricesamount("Mcule-1234567", amount=10)
|
|
31
|
+
mcule.multiplequeriessearch(["Mcule-1234567", "CCO"])
|
|
32
|
+
mcule.multiplequerieswithavailability(["Mcule-1234567", "CCO"])
|
|
33
|
+
mcule.similaritysearch("CCO", limit=5, threshold=0.7)
|
|
34
|
+
mcule.substructuresearch("CCO")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Documented rate limits:
|
|
38
|
+
|
|
39
|
+
| | Burst | Sustained |
|
|
40
|
+
| --- | --- | --- |
|
|
41
|
+
| Anonymous (no token) | 10/min | 100/day |
|
|
42
|
+
| Authenticated (with token) | 20/min | 200/hour |
|
|
43
|
+
|
|
44
|
+
The [Compound list details](https://doc.mcule.com/api#compound_list_details1) and
|
|
45
|
+
[Quote Request](https://doc.mcule.com/api#quote_request1) (`POST`) endpoints have their
|
|
46
|
+
own, stricter limits — see the docs for details. On a 429 response, check the
|
|
47
|
+
`Retry-After` header/body before retrying.
|
|
48
|
+
|
|
49
|
+
## MCule ULTIMATE
|
|
50
|
+
|
|
51
|
+
`UltimateMCuleWrapper` talks to the separate
|
|
52
|
+
[MCule ULTIMATE API](https://doc.mcule.com/doku.php?id=ultimate-api) (base url
|
|
53
|
+
`https://ultimateapp.mcule.com/api/v1/`), which searches MCule's larger
|
|
54
|
+
make-on-demand "Ultimate" compound space. It requires its own access token
|
|
55
|
+
(also requested from MCule by email) and is **not** interchangeable with a
|
|
56
|
+
standard MCule API token.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from pycule import UltimateMCuleWrapper
|
|
60
|
+
|
|
61
|
+
ultimate = UltimateMCuleWrapper(authorisation_token="your-ultimate-token")
|
|
62
|
+
|
|
63
|
+
ultimate.exact_search("CCO")
|
|
64
|
+
ultimate.similarity_search("CCO", limit=5, sim_threshold=0.7)
|
|
65
|
+
ultimate.substructure_search("CCO", limit=5)
|
|
66
|
+
ultimate.price_search_multi(["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10])
|
|
67
|
+
ultimate.quote_request_multi(
|
|
68
|
+
["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10], delivery_country="GB"
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Documented rate limits:
|
|
73
|
+
|
|
74
|
+
| | Per minute | Per day |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| Anonymous (no token) | 10 | 100 |
|
|
77
|
+
| Authenticated (with token) | 100 | 1000 |
|
|
78
|
+
|
|
79
|
+
## Enamine
|
|
80
|
+
|
|
81
|
+
`EnamineWrapper` talks to the current [EnamineStore API](https://enaminestore.com/documentation)
|
|
82
|
+
(JWT-based auth, `/api/v2` endpoints). Authentication, token refresh and HTTP 429
|
|
83
|
+
(rate limit) retries with backoff are all handled transparently.
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from pycule import EnamineWrapper
|
|
87
|
+
|
|
88
|
+
enamine = EnamineWrapper(email="you@example.com", password="your-password")
|
|
89
|
+
|
|
90
|
+
# Exact-match searches (synchronous). Accept a single identifier or a list -
|
|
91
|
+
# lists are automatically split into batches of `batch_size` (default 2000,
|
|
92
|
+
# Enamine's documented recommendation for the Code Search endpoint).
|
|
93
|
+
enamine.compoundidsearch(["EN300-17264", "EN300-456830", "Z234859494"])
|
|
94
|
+
enamine.cassearch(["110-86-1", "91-17-8"], catalog="building-blocks")
|
|
95
|
+
enamine.mfcdsearch(["MFCD00011732"], catalog="building-blocks")
|
|
96
|
+
|
|
97
|
+
# Exact SMILES search (asynchronous "delayed result", polled to completion).
|
|
98
|
+
enamine.exactsearch(["C=1C=CN=CC1", "CC(N)=O"], catalog="building-blocks")
|
|
99
|
+
|
|
100
|
+
# Substructure/similarity searches only accept a single query SMILES per call.
|
|
101
|
+
enamine.substructuresearch("CC(N)=O", catalog="building-blocks")
|
|
102
|
+
enamine.similaritysearch("CC(N)=O", catalog="building-blocks", similarity_value=0.8)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Valid `catalog` values: `"building-blocks"`, `"screening-compounds"`,
|
|
106
|
+
`"made-building-blocks"`, `"real"`, `"bioactive-compounds"`.
|
|
107
|
+
|
|
108
|
+
Enamine does not currently publish its API rate limits. Rather than guessing,
|
|
109
|
+
requests are retried with exponential backoff when an HTTP 429 is received; once
|
|
110
|
+
the real limits are known, this can be tightened up in
|
|
111
|
+
[`pycule/decorators.py`](pycule/decorators.py).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Pycule initialization."""
|
|
2
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
3
|
+
|
|
4
|
+
__name__ = "Pycule"
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("PyCule")
|
|
7
|
+
except PackageNotFoundError:
|
|
8
|
+
# Package isn't installed (e.g. running from a source checkout without
|
|
9
|
+
# `pip install`); version is derived from git tags via setuptools_scm.
|
|
10
|
+
__version__ = "unknown"
|
|
11
|
+
|
|
12
|
+
from .core import EnamineWrapper, MCuleWrapper, UltimateMCuleWrapper
|