# Gnina

Limit molecular docking to known active pockets of proteins to improve computational accuracy and efficiency, suitable for drug screening of known binding sites.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Two-step gnina docking restricted to a known binding pocket: Step 1 runs a fast
vinardo docking of all input ligands, Step 2 re-scores every pose with CPU CNN
rescore+minimize for the final ranking.

**Tool Name:** `get_gnina_result_from_pocket_center_picker_get_gnina_result_from_pocket_center_picker_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `receptor` | `file` | ✓ | Receptor structure file. <br/>file suffix: `pdb`, `cif` |  |
| `ligand_to_dock` | `file` | ✓ | Ligand to dock with the receptor. <br/>file suffix: `sdf`, `mol`, `pdb`, `smi`, `txt` |  |
| `reference_ligand` | `file` | ✗ | Reference ligand file for comparison. <br/>file suffix: `sdf`, `mol`, `pdb` |  |
| `pocket_info` | `string` | ✗ | Pocket details (center and size). Format: center:x,y,z;size:x,y,z. Example: center:10.5,-3.2,7.8;size:15.0,15.0,15.0  |  |
| `Mol_Interactions` | `boolean` | ✗ | Whether to output protein-ligand interactions and generate 2D interaction diagrams (Poseview).  |  |
| `num_modes` | `number` | ✗ | Number of docking modes to generate.  |  |
| `exhaustiveness` | `number` | ✗ | Gnina exhaustiveness (global search thoroughness, default 8, max 64). CPU cores per docking process scale with it (exhaustiveness <=4 -> 1 core, 8 -> 2, 16 -> 4, 32 -> 8, 64 -> 16 cores); the total cores used by a task (and by all concurrent tasks) stays capped at 96.  |  |
| `score_only` | `boolean` | ✗ | If True, only score the input ligand poses via `gnina --score_only` (no docking, no minimize, no box required). Ligands must already have 3D coordinates (sdf/pdb).  |  |
| `local_only` | `boolean` | ✗ | If True, skip the global docking search and only locally refine the input ligand poses via `gnina --local_only` (autobox around each input pose). With this flag, `pocket_info`/`reference_ligand` are OPTIONAL: if omitted, the scoring box is also derived automatically from the input poses. Ligands must already have 3D coordinates (sdf/pdb).  |  |

### 示例代码

#### 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": "Gnina",
    "tool_name": "get_gnina_result_from_pocket_center_picker_get_gnina_result_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>",
    "Mol_Interactions": false,
    "num_modes": 1,
    "exhaustiveness": 8,
    "score_only": false,
    "local_only": false
},
    # 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.")
```


---

## 2. Dock one or more ligands against a receptor using fully customizable gnina
arguments. Input: one `params_json` file holding the gnina options (see the
parameter description for accepted keys and restrictions) plus a `files` list
containing the receptor, ligand(s), and any other files referenced by name in the
JSON.

**Tool Name:** `get_gnina_result_from_params_json_get_gnina_result_from_params_json_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `params_json` | `file` | ✓ | JSON file holding the gnina arguments to pass through (keys with or without leading dashes). All open gnina options are accepted EXCEPT the service-managed ones: --cpu/--device/--no_gpu (CPU/GPU is allocated by the server), output paths -o/--out/--out_flex/--log/--atom_terms, --config, --help/--version, and --score_only (use the main endpoint's score_only flag instead). Any string value whose filename matches an uploaded `files` entry (receptor, ligand, autobox_ligand, flex, cnn_model, custom_scoring, custom_atoms, user_grid, ...) is resolved to that uploaded file by filename. `receptor` and `ligand` are required. Boolean true adds the flag; boolean false omits it. Optional non-gnina switch: "Mol_Interactions": true to add 2D interaction diagrams. Example: {"receptor": "protein.pdb", "ligand": "ligs.sdf", "center_x": 2.0, "center_y": 6.5, "center_z": -1.0, "size_x": 20, "size_y": 20, "size_z": 20, "exhaustiveness": 8, "num_modes": 9, "seed": 42, "cnn_scoring": "rescore", "Mol_Interactions": false}<br/>file suffix: `json` |  |
| `files` | `file_array` | ✓ | Files referenced by filename in params_json: receptor (.pdb/.cif), ligand (.sdf/.mol/.pdb/.smi/.txt), plus any optional files used by the JSON arguments (autobox_ligand, flex, cnn_model, custom_scoring, custom_atoms, user_grid, ...). File names must be unique. <br/>file suffix: `pdb`, `cif`, `sdf`, `mol`, `smi`, `txt`, `pdbqt`, `map` |  |

### 示例代码

#### 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": "Gnina",
    "tool_name": "get_gnina_result_from_params_json_get_gnina_result_from_params_json_post",
    "parameters": {
    "params_json": "<PARAMS_JSON_FILE_ID>",
    "files": [
        "<FILE_ID1>",
        "<FILE_ID2>"
    ]
},
    # 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/Gnina>
