Metadata-Version: 2.4
Name: PyCule
Version: 0.3.0
Summary: Python wrapper for the MCule Ultimate API
Home-page: https://github.com/xchem/pycule.git
Author: Warren Thompson
Author-email: waztom@gmail.com
License: MIT
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.24.0
Requires-Dist: ratelimit>=2.2.1
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: requires-dist
Dynamic: summary

PyCule
==============================
[//]: # (Badges)
[![PyPI version](https://badge.fury.io/py/PyCule.svg)](https://badge.fury.io/py/PyCule)

Wrapper to access the MCule and Enamine APIs

## MCule

`MCuleWrapper` talks to the standard [MCule API](https://doc.mcule.com/api)
(base url `https://mcule.com/api/v1/`). Public endpoints (database files, compound
details, InChIKey lookup, single query search) work without authentication;
everything else requires an API access token sent as an `Authorization: Token <token>`
header. To request a token, email MCule with a summary of your intended use, per
their docs.

```python
from pycule import MCuleWrapper

mcule = MCuleWrapper(authorisation_token="your-mcule-token")

mcule.databasefiles()
mcule.compounddetails("Mcule-1234567")
mcule.inchikeylookup("IHHITLNORGKBTP-UHFFFAOYSA-N")
mcule.singlequerysearch("CCO")

# Protected endpoints (require a valid token).
mcule.compoundavailability("Mcule-1234567")
mcule.compoundprices("Mcule-1234567")
mcule.compoundpricesamount("Mcule-1234567", amount=10)
mcule.multiplequeriessearch(["Mcule-1234567", "CCO"])
mcule.multiplequerieswithavailability(["Mcule-1234567", "CCO"])
mcule.similaritysearch("CCO", limit=5, threshold=0.7)
mcule.substructuresearch("CCO")
```

Documented rate limits:

| | Burst | Sustained |
| --- | --- | --- |
| Anonymous (no token) | 10/min | 100/day |
| Authenticated (with token) | 20/min | 200/hour |

The [Compound list details](https://doc.mcule.com/api#compound_list_details1) and
[Quote Request](https://doc.mcule.com/api#quote_request1) (`POST`) endpoints have their
own, stricter limits — see the docs for details. On a 429 response, check the
`Retry-After` header/body before retrying.

## MCule ULTIMATE

`UltimateMCuleWrapper` talks to the separate
[MCule ULTIMATE API](https://doc.mcule.com/doku.php?id=ultimate-api) (base url
`https://ultimateapp.mcule.com/api/v1/`), which searches MCule's larger
make-on-demand "Ultimate" compound space. It requires its own access token
(also requested from MCule by email) and is **not** interchangeable with a
standard MCule API token.

```python
from pycule import UltimateMCuleWrapper

ultimate = UltimateMCuleWrapper(authorisation_token="your-ultimate-token")

ultimate.exact_search("CCO")
ultimate.similarity_search("CCO", limit=5, sim_threshold=0.7)
ultimate.substructure_search("CCO", limit=5)
ultimate.price_search_multi(["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10])
ultimate.quote_request_multi(
    ["IHHITLNORGKBTP-UHFFFAOYSA-N"], amounts=[10], delivery_country="GB"
)
```

Documented rate limits:

| | Per minute | Per day |
| --- | --- | --- |
| Anonymous (no token) | 10 | 100 |
| Authenticated (with token) | 100 | 1000 |

## Enamine

`EnamineWrapper` talks to the current [EnamineStore API](https://enaminestore.com/documentation)
(JWT-based auth, `/api/v2` endpoints). Authentication, token refresh and HTTP 429
(rate limit) retries with backoff are all handled transparently.

```python
from pycule import EnamineWrapper

enamine = EnamineWrapper(email="you@example.com", password="your-password")

# Exact-match searches (synchronous). Accept a single identifier or a list -
# lists are automatically split into batches of `batch_size` (default 2000,
# Enamine's documented recommendation for the Code Search endpoint).
enamine.compoundidsearch(["EN300-17264", "EN300-456830", "Z234859494"])
enamine.cassearch(["110-86-1", "91-17-8"], catalog="building-blocks")
enamine.mfcdsearch(["MFCD00011732"], catalog="building-blocks")

# Exact SMILES search (asynchronous "delayed result", polled to completion).
enamine.exactsearch(["C=1C=CN=CC1", "CC(N)=O"], catalog="building-blocks")

# Substructure/similarity searches only accept a single query SMILES per call.
enamine.substructuresearch("CC(N)=O", catalog="building-blocks")
enamine.similaritysearch("CC(N)=O", catalog="building-blocks", similarity_value=0.8)
```

Valid `catalog` values: `"building-blocks"`, `"screening-compounds"`,
`"made-building-blocks"`, `"real"`, `"bioactive-compounds"`.

Enamine does not currently publish its API rate limits. Rather than guessing,
requests are retried with exponential backoff when an HTTP 429 is received; once
the real limits are known, this can be tightened up in
[`pycule/decorators.py`](pycule/decorators.py).
