...
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:
- Start a prediction task and get a task ID
- Fetch your prediction task using the task ID from step (1). Keep fetching until the task is ready
The API for these two simple steps is described below.
Info |
---|
Some OCHEM models (e.g. models aggregated using Bagging method), require significant amount of calculations. |
Way
...
1: Request until done
To post a prediction task for a molecule, run the following request:
https://ochem.eu/modelservice/postModelgetPrediction.do?modelId=YOUR_MODEL_ID&mol=YOUR_MOLECULE
...
Code Block | ||
---|---|---|
| ||
{ "status" : "pending", "taskId" : 0, "metaserverTaskId" : 0 } |
The above response means that this molecule is new and it is being calculated at the moment.
Please, repeat the request at the periodic intervals until the prediction result is returned in the following format:
Code Block | ||
---|---|---|
| ||
{
"status" : "success",
"predictions" : [ {
"depictionID" : 1000618459,
"moleculeID" : 7868,
"predictions" : [ {
"value" : 1.2020000219345093,
"accuracy" : 0.5011452764639881,
"dm" : 0.28780001401901245,
"insideAD" : true,
"unit" : "Log unit",
"property" : "BCF",
"realValue" : 0.0,
"predictedValueString" : "1.2020000219345093"
} ]
} ],
"modelDescriptionUrl" : "http://ochem.eu/model/23120392",
"taskId" : 0,
"metaserverTaskId" : 0
} |
Way 2: Using task IDs
Since a prediction is not instantaneous and can take several seconds to minutes, the prediction is performed asynchronously, that is in two steps:
- Start a prediction task and get a task ID
- Fetch your prediction task using the task ID from step (1). Keep fetching until the task is ready
The API for these two simple steps is described below.
To post a task, run the following request:
https://ochem.eu/modelservice/postModel.do?modelId=YOUR_MODEL_ID&mol=YOUR_MOLECULE
The resulting JSON will look like:
Code Block | ||
---|---|---|
| ||
{
"taskId": "1000042989", // This is the task ID you need to know
"metaserverTaskId": "-1",
"status": "success"
} |
...