AILIXIR Bot commited on
Commit
2a9a2ac
·
1 Parent(s): 37e0b04

Auto-sync: 49d1afda6864825154ae6bb9f8b01dd5280cef78

Browse files
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
- "data": {
1391
- "job_id": 123,
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
- "data": {
1412
- "job_id": 14,
1413
- "status": "completed",
1414
- "inputs": {
1415
- "protein": "EGFR",
1416
- "ligand": "Erlotinib"
1417
- },
1418
- "created_at": "2026-04-21T18:29:45+00:00",
1419
- "results": {
1420
- "vina_scores": [0, 0.001, 0.002],
1421
- "download_url": "{base_url}/api/docking/download/{job_id}"
1422
- }
1423
- }
1424
  }
1425
  ```
1426
 
1427
- If the job is not completed, the `results` block may be omitted.
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
- "data": {
1444
- "data": [
1445
- {
1446
- "job_id": 14,
1447
- "status": "completed",
1448
- "inputs": {
1449
- "protein": "EGFR",
1450
- "ligand": "Erlotinib"
1451
- },
1452
- "created_at": "2026-04-21T18:29:45+00:00",
1453
- "results": {
1454
- "vina_scores": [0, 0.001, 0.002],
1455
- "download_url": "{base_url}/api/docking/download/{job_id}"
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 $this->successResponse('Docking Job Successfully Queued', [
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
- $data = [
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 $data;
 
 
 
 
 
 
 
 
116
  });
117
 
118
- return $this->successResponse('Docking history retrieved successfully', [
119
- 'data' => $items,
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
- $results = null;
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
- 'job_id' => $job->id,
162
- 'status' => $job->status,
163
- 'inputs' => [
164
- 'protein' => $job->protein_name,
165
- 'ligand' => $job->ligand_name,
166
- ],
167
- 'created_at' => $job->created_at->toIso8601String(),
168
  ];
169
 
170
- if ($results !== null) {
171
- $data['results'] = $results;
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
  /**