AILIXIR Bot commited on
Commit ·
2a9a2ac
1
Parent(s): 37e0b04
Auto-sync: 49d1afda6864825154ae6bb9f8b01dd5280cef78
Browse files- API.md +38 -40
- app/Http/Controllers/Api/DockingController.php +25 -37
API.md
CHANGED
|
@@ -1387,10 +1387,8 @@ curl -X POST "{base_url}/api/docking/submit" \\
|
|
| 1387 |
{
|
| 1388 |
"success": true,
|
| 1389 |
"message": "Docking Job Successfully Queued",
|
| 1390 |
-
"
|
| 1391 |
-
|
| 1392 |
-
"status": "pending"
|
| 1393 |
-
}
|
| 1394 |
}
|
| 1395 |
```
|
| 1396 |
|
|
@@ -1408,23 +1406,23 @@ curl -X POST "{base_url}/api/docking/submit" \\
|
|
| 1408 |
{
|
| 1409 |
"success": true,
|
| 1410 |
"message": "Job details retrieved successfully",
|
| 1411 |
-
"
|
| 1412 |
-
|
| 1413 |
-
|
| 1414 |
-
|
| 1415 |
-
|
| 1416 |
-
|
| 1417 |
-
|
| 1418 |
-
"
|
| 1419 |
-
"
|
| 1420 |
-
|
| 1421 |
-
|
| 1422 |
-
}
|
| 1423 |
-
|
| 1424 |
}
|
| 1425 |
```
|
| 1426 |
|
| 1427 |
-
If the job is not completed,
|
| 1428 |
|
| 1429 |
---
|
| 1430 |
|
|
@@ -1440,29 +1438,29 @@ If the job is not completed, the `results` block may be omitted.
|
|
| 1440 |
{
|
| 1441 |
"success": true,
|
| 1442 |
"message": "Docking history retrieved successfully",
|
| 1443 |
-
"
|
| 1444 |
-
|
| 1445 |
-
|
| 1446 |
-
|
| 1447 |
-
|
| 1448 |
-
|
| 1449 |
-
|
| 1450 |
-
|
| 1451 |
-
|
| 1452 |
-
"
|
| 1453 |
-
"
|
| 1454 |
-
|
| 1455 |
-
|
| 1456 |
-
}
|
| 1457 |
-
|
| 1458 |
-
],
|
| 1459 |
-
"pagination": {
|
| 1460 |
-
"current_page": 1,
|
| 1461 |
-
"per_page": 2,
|
| 1462 |
-
"total": 3,
|
| 1463 |
-
"last_page": 2,
|
| 1464 |
-
"has_more": true
|
| 1465 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1466 |
}
|
| 1467 |
}
|
| 1468 |
```
|
|
|
|
| 1387 |
{
|
| 1388 |
"success": true,
|
| 1389 |
"message": "Docking Job Successfully Queued",
|
| 1390 |
+
"job_id": 123,
|
| 1391 |
+
"status": "pending"
|
|
|
|
|
|
|
| 1392 |
}
|
| 1393 |
```
|
| 1394 |
|
|
|
|
| 1406 |
{
|
| 1407 |
"success": true,
|
| 1408 |
"message": "Job details retrieved successfully",
|
| 1409 |
+
"id": 5,
|
| 1410 |
+
"status": "completed",
|
| 1411 |
+
"protein": "EGFR",
|
| 1412 |
+
"ligand": "Erlotinib",
|
| 1413 |
+
"created_at": "2026-06-17T05:45:31+00:00",
|
| 1414 |
+
"download_url": "{base_url}/api/docking/download/5",
|
| 1415 |
+
"scores": [
|
| 1416 |
+
{"pose": 1, "affinity": -6.469},
|
| 1417 |
+
{"pose": 2, "affinity": -6.337},
|
| 1418 |
+
{"pose": 3, "affinity": -6.163},
|
| 1419 |
+
{"pose": 4, "affinity": -6.079},
|
| 1420 |
+
{"pose": 5, "affinity": -5.983}
|
| 1421 |
+
]
|
| 1422 |
}
|
| 1423 |
```
|
| 1424 |
|
| 1425 |
+
If the job is not completed, `scores` will be an empty array.
|
| 1426 |
|
| 1427 |
---
|
| 1428 |
|
|
|
|
| 1438 |
{
|
| 1439 |
"success": true,
|
| 1440 |
"message": "Docking history retrieved successfully",
|
| 1441 |
+
"results": [
|
| 1442 |
+
{
|
| 1443 |
+
"id": 5,
|
| 1444 |
+
"status": "completed",
|
| 1445 |
+
"protein": "EGFR",
|
| 1446 |
+
"ligand": "Erlotinib",
|
| 1447 |
+
"created_at": "2026-06-17T05:45:31+00:00",
|
| 1448 |
+
"download_url": "{base_url}/api/docking/download/5",
|
| 1449 |
+
"scores": [
|
| 1450 |
+
{"pose": 1, "affinity": -6.469},
|
| 1451 |
+
{"pose": 2, "affinity": -6.337},
|
| 1452 |
+
{"pose": 3, "affinity": -6.163},
|
| 1453 |
+
{"pose": 4, "affinity": -6.079},
|
| 1454 |
+
{"pose": 5, "affinity": -5.983}
|
| 1455 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1456 |
}
|
| 1457 |
+
],
|
| 1458 |
+
"pagination": {
|
| 1459 |
+
"current_page": 1,
|
| 1460 |
+
"per_page": 2,
|
| 1461 |
+
"total": 3,
|
| 1462 |
+
"last_page": 2,
|
| 1463 |
+
"has_more": true
|
| 1464 |
}
|
| 1465 |
}
|
| 1466 |
```
|
app/Http/Controllers/Api/DockingController.php
CHANGED
|
@@ -68,7 +68,7 @@ class DockingController
|
|
| 68 |
'n_poses' => $request->n_poses ?? 5,
|
| 69 |
]);
|
| 70 |
|
| 71 |
-
return
|
| 72 |
'job_id' => $job->id,
|
| 73 |
'status' => $job->status,
|
| 74 |
]);
|
|
@@ -91,32 +91,26 @@ class DockingController
|
|
| 91 |
->paginate($perPage);
|
| 92 |
|
| 93 |
$items = collect($paginator->items())->map(function ($job) {
|
| 94 |
-
$
|
| 95 |
-
'job_id' => $job->id,
|
| 96 |
-
'status' => $job->status,
|
| 97 |
-
'inputs' => [
|
| 98 |
-
'protein' => $job->protein_name,
|
| 99 |
-
'ligand' => $job->ligand_name,
|
| 100 |
-
],
|
| 101 |
-
'created_at' => $job->created_at->toIso8601String(),
|
| 102 |
-
];
|
| 103 |
-
|
| 104 |
if ($job->status === 'completed' && $job->result_data) {
|
| 105 |
-
$scores = [];
|
| 106 |
foreach (($job->result_data['vina_score'] ?? []) as $i => $affinity) {
|
| 107 |
$scores[] = ['pose' => $i + 1, 'affinity' => (float) $affinity];
|
| 108 |
}
|
| 109 |
-
$data['results'] = [
|
| 110 |
-
'scores' => $scores,
|
| 111 |
-
'download_url' => url('/api/docking/download/' . $job->id),
|
| 112 |
-
];
|
| 113 |
}
|
| 114 |
|
| 115 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
});
|
| 117 |
|
| 118 |
-
return
|
| 119 |
-
'
|
| 120 |
'pagination' => [
|
| 121 |
'current_page' => $paginator->currentPage(),
|
| 122 |
'per_page' => $paginator->perPage(),
|
|
@@ -145,33 +139,27 @@ class DockingController
|
|
| 145 |
}
|
| 146 |
|
| 147 |
// Build results block (only when job is completed)
|
| 148 |
-
$
|
| 149 |
if ($job->status === 'completed' && $job->result_data) {
|
| 150 |
-
$scores = [];
|
| 151 |
foreach (($job->result_data['vina_score'] ?? []) as $i => $affinity) {
|
| 152 |
$scores[] = ['pose' => $i + 1, 'affinity' => (float) $affinity];
|
| 153 |
}
|
| 154 |
-
$results = [
|
| 155 |
-
'scores' => $scores,
|
| 156 |
-
'download_url' => url('/api/docking/download/' . $job->id),
|
| 157 |
-
];
|
| 158 |
}
|
| 159 |
|
| 160 |
$data = [
|
| 161 |
-
'
|
| 162 |
-
'status'
|
| 163 |
-
'
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
'
|
| 168 |
];
|
| 169 |
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
return $this->successResponse('Job details retrieved successfully', $data);
|
| 175 |
}
|
| 176 |
|
| 177 |
/**
|
|
|
|
| 68 |
'n_poses' => $request->n_poses ?? 5,
|
| 69 |
]);
|
| 70 |
|
| 71 |
+
return response()->json([
|
| 72 |
'job_id' => $job->id,
|
| 73 |
'status' => $job->status,
|
| 74 |
]);
|
|
|
|
| 91 |
->paginate($perPage);
|
| 92 |
|
| 93 |
$items = collect($paginator->items())->map(function ($job) {
|
| 94 |
+
$scores = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
if ($job->status === 'completed' && $job->result_data) {
|
|
|
|
| 96 |
foreach (($job->result_data['vina_score'] ?? []) as $i => $affinity) {
|
| 97 |
$scores[] = ['pose' => $i + 1, 'affinity' => (float) $affinity];
|
| 98 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
}
|
| 100 |
|
| 101 |
+
return [
|
| 102 |
+
'id' => $job->id,
|
| 103 |
+
'status' => $job->status,
|
| 104 |
+
'protein' => $job->protein_name,
|
| 105 |
+
'ligand' => $job->ligand_name,
|
| 106 |
+
'created_at' => $job->created_at->toIso8601String(),
|
| 107 |
+
'download_url' => url('/api/docking/download/' . $job->id),
|
| 108 |
+
'scores' => $scores,
|
| 109 |
+
];
|
| 110 |
});
|
| 111 |
|
| 112 |
+
return response()->json([
|
| 113 |
+
'results' => $items,
|
| 114 |
'pagination' => [
|
| 115 |
'current_page' => $paginator->currentPage(),
|
| 116 |
'per_page' => $paginator->perPage(),
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
// Build results block (only when job is completed)
|
| 142 |
+
$scores = [];
|
| 143 |
if ($job->status === 'completed' && $job->result_data) {
|
|
|
|
| 144 |
foreach (($job->result_data['vina_score'] ?? []) as $i => $affinity) {
|
| 145 |
$scores[] = ['pose' => $i + 1, 'affinity' => (float) $affinity];
|
| 146 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
$data = [
|
| 150 |
+
'id' => $job->id,
|
| 151 |
+
'status' => $job->status,
|
| 152 |
+
'protein' => $job->protein_name,
|
| 153 |
+
'ligand' => $job->ligand_name,
|
| 154 |
+
'created_at' => $job->created_at->toIso8601String(),
|
| 155 |
+
'download_url' => url('/api/docking/download/' . $job->id),
|
| 156 |
+
'scores' => $scores,
|
| 157 |
];
|
| 158 |
|
| 159 |
+
return response()->json(array_merge(
|
| 160 |
+
['success' => true, 'message' => 'Job details retrieved successfully'],
|
| 161 |
+
$data
|
| 162 |
+
));
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
/**
|