# PackDock

PackDock: diffusion-guided protein-ligand docking with side-chain packing.

Pipeline: Stage 0 prepare & pocket extraction -> Stage 1 apo side-chain packing -> Stage 2 Vina docking on apo conformations -> Stage 3 holo side-chain packing (induced fit) -> Stage 4 final Vina docking (ranked score table).


## 基础信息

| 项目 | 值 |
|------|-----|
| Base URL | `https://sciminer.tech/console/api` |
| API Endpoint | `/v1/internal/tools/invoke` |
| Content-Type | `application/json` |
| Authentication | `X-Auth-Token: <YOUR_API_KEY>` |

## 1. Dock From Pocket Center Picker

**Tool Name:** `dock_from_pocket_center_picker_dock_from_pocket_center_picker_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `receptor` | `file` | ✓ | Complete protein structure file (allowed: .pdb, .cif)<br/>file suffix: `pdb`, `cif` |  |
| `ligand_to_dock` | `file` | ✓ | Ligand file to dock, will be moved to pocket center (allowed: .sdf/.pdb/.mol2/.mol/.smi/.txt; structure files must contain 3D coordinates)<br/>file suffix: `sdf`, `pdb`, `mol2`, `mol`, `smi`, `smiles`, `txt` |  |
| `reference_ligand` | `file` | ✗ | Reference ligand file to define pocket center (allowed: .sdf, .pdb; must contain 3D coordinates)<br/>file suffix: `sdf`, `pdb` |  |
| `pocket_info` | `string` | ✗ | Pocket box from the 3D picker, format 'center:x,y,z;size:x,y,z' (in Angstrom). The longest box edge is used as the pocket extraction radius. |  |
| `num_apo_conformers` | `number` | ✗ | Number of ligand-free (apo) protein side-chain conformations sampled in Stage 1; each one is docked against once in Stage 2. Higher = more pocket diversity but longer runtime (linearly more docking runs). |  |
| `num_holo_conformers` | `number` | ✗ | Number of ligand-conditioned (holo) complex side-chain conformations sampled in Stage 3 for each Stage-2 best pose; each one is re-docked in Stage 4 and adds poses to the final score table. Higher = more final poses but longer runtime.  |  |
| `vina_sample` | `number` | ✗ | Number of Vina output poses kept per Stage-4 docking run (Vina num_modes). |  |

### 示例代码

#### Python

```python
import requests

BASE_URL = "https://sciminer.tech/console/api"
API_KEY = "<YOUR_API_KEY>"
endpoint = "/v1/internal/tools/invoke"

# If the invoked API includes FILE-type parameters, upload the file first to obtain a `file_id`,
# then fill the corresponding field in `parameters` with the returned `file_id`.
# File upload example (form-data, parameter name is `file`):

# files = {'file': open('path/to/your_file.ext', 'rb')}
# upload_url = f"{BASE_URL}/v1/internal/tools/file"
# resp_upload = requests.post(upload_url, files=files, headers={"X-Auth-Token": f"{API_KEY}"}, timeout=60)
# resp_upload.raise_for_status()
# file_id = resp_upload.json().get("file_id")
# print(f"File uploaded successfully, file_id: {file_id}")
# # Then set the `file_id` in the corresponding field of `payload['parameters']`, for example: payload['parameters']["your_file_param_name"] = file_id

headers = {
    "X-Auth-Token": f"{API_KEY}",
    "Content-Type": "application/json",
}

payload = {
    "provider_name": "PackDock",
    "tool_name": "dock_from_pocket_center_picker_dock_from_pocket_center_picker_post",
    "parameters": {
    "receptor": "<RECEPTOR_FILE_ID>",
    "ligand_to_dock": "<LIGAND_TO_DOCK_FILE_ID>",
    "reference_ligand": "<REFERENCE_LIGAND_FILE_ID>",
    "pocket_info": "<POCKET_INFO>",
    "num_apo_conformers": 1,
    "num_holo_conformers": 5,
    "vina_sample": 9
},
    # The job name is an optional parameter.
    #"job_name": "xxx",
}

# Step 1: Submit the task.
# Call the /invoke endpoint to start the task and obtain a task_id.
print("1. Submitting task...")
resp_submit = requests.post(f"{BASE_URL}{endpoint}", json=payload, headers=headers, timeout=30)
resp_submit.raise_for_status()
task_id = resp_submit.json().get("task_id")
print(f"Task ID: {task_id}")

# Step 2: Poll for the result.
# Use the task_id obtained above to call the /result endpoint to check status and fetch the result.
# If this tool takes a long time, you can increase the max_retries parameter or after exceeding the maximum number of times, you can use the task_id to re-request.
status_url = f"https://sciminer.tech/console/api/v1/internal/tools/result"
max_retries = 300
status = "PENDING"
for i in range(max_retries):
    print(f"Polling status (attempt {i+1}/{max_retries})...")
    resp_status = requests.get(
        status_url,
        params={"task_id": task_id},
        headers=headers,
        timeout=10
    )
    resp_status.raise_for_status()
    
    result = resp_status.json()
    status = result.get("status")
    print(f"Status: {status}")
    
    if status == "SUCCESS":
        print("✅ Task completed successfully！")
        print(f"Result: {result.get('result')}")
        break
    elif status == "FAILURE":
        print(f"❌ Task failed: {result.get('result')}")
        break
    else:
        # Wait 2 seconds before retrying
        import time
        time.sleep(2)
else:
    print("⏱️  Maximum retry attempts reached. The task is still running.")
```


---

## User Interface URL

> When the user needs a tool recommendation, output the URL.

**URL:** <https://sciminer.tech/utility/tool/PackDock>
