Python interface for the molecule.one chemical synthesis accessibility batch API
The API works in three stages:
- Submitting molecules (expressed as SMILES) to the batch server.
- Querying the batch server for the status.
- Retrieving results from the batch server.
import moleculeone as mo
my_api_key = "<your api key here>"
smiles_to_scan = ["CC(C)NC[C@@H](O)COc1cccc(c12)[nH]c3c2cccc3"]
request = mo.BatchScoreRequest(smiles_to_scan, my_api_key)
request.submit()
status = mo.BatchJobStatus(request)
It is possible to ask if the job is finished running all jobs
if status.is_finished():
# do something
results = mo.BatchResult(request)
which can return a list of dictionaries with the results through the .get()
method
my_results = results.get()
which can be printed or postprocessed.
A convenience iterator is supplied directly for the BatchResult
object.
for r in results:
score = r["result"]
smiles = r["targetSmiles"]
print("{0:6.2f} {1:s}".format(score, smiles))