You can run predictions on OCHEM using simple REST-like web services.
Since a prediction is not instantaneous and can take several seconds to minutes, the prediction is performed asynchronously, that is in two steps:
The API for these two simple steps is described below.
Some OCHEM models (e.g. models aggregated using Bagging method), require significant amount of calculations. |
To post a task, run the following request:
https://ochem.eu/modelservice/postModel.do?modelId=YOUR_MODEL_ID&mol=YOUR_MOLECULE
Model id the public model identifier or "model identity" (GUID) provided by OCHEM administration. If you plan to use predictions systematically, it is recommended to request a model identity (GUID).
The molecule can be in SMILES or SD format. For both the formats, multiple molecules can be posted using $$$$ separator.
It is much more efficient to predict molecules in batches rather than posting separate tasks for each molecule.
The resulting JSON will look like:
{
"taskId": "1000042989", // This is the task ID you need to know
"metaserverTaskId": "-1",
"status": "success"
} |
Given that the result.modelResponse.status is "success", the task ID used for retrieving the predictions is result.modelResponse.taskId
To fetch the model, use the following request:
http://ochem.eu/modelservice/fetchModel.do?taskId=YOUR_TASK_ID
If the task is still running, the resulting JSON will look like:
{
"taskId": "0",
"metaserverTaskId": "0",
"status": "pending" // Keep requesting at periodic intervals, while the status is "pending"
} |
When the task is ready, the JSON will look like:
{
"taskId": "0",
"predictions": {
"moleculeID": "1002136505",
"predictions": {
"unit": "-log(mmol/L)",
// Name of the predicted class for classification models. Same as "value" for regression models.
"predictedValueString": "2.7139999866485596",
"value": "2.7139999866485596", // Prediction value (round it as you find necessary)
"dm": "0.8611000180244446", // The "distance to model" used for the accuracy estimation
"property": "log(IGC50-1)", // The predicted property
"accuracy": "0.7065203028344436", // The prediction accuracy (RMSE)
"realValue": "0.0"
},
"depictionID": "1000651576"
},
"metaserverTaskId": "0",
"status": "success",
"modelDescriptionUrl": "http://ochem.eu/model/3"
} |