# Pocket2Mol

Pocket2Mol is a 3D protein pocket-based molecular sampling tool that leverages E(3)-equivariant graph neural networks and efficient sampling algorithms to design novel drug molecules with high binding affinity, drug-likeness, and synthetic feasibility, significantly enhancing the specificity and success rate of drug design.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Predict Gpu

**Tool Name:** `predict_gpu_predict_gpu_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `receptor` | `file` | ✓ | Receptor protein structure file defining the binding-pocket surroundings (supported formats: PDB, mmCIF, required)<br/>file suffix: `pdb`, `cif` |  |
| `reference_ligand` | `file` | ✗ | Reference ligand used to auto-derive the pocket center and box; for a multi-molecule SDF only the first record is used (supported formats: SDF, PDB, MOL2, MOL, optional; if both reference_ligand and pocket_info are provided, reference_ligand takes precedence)<br/>file suffix: `sdf`, `pdb`, `mol2`, `mol` |  |
| `pocket_info` | `string` | ✗ | Binding pocket center and 3D box size, alternative to a reference ligand (format: Center:X,Y,Z;Size:SX,SY,SZ from the 3D pocket picker, unit: Angstrom, optional; ignored when reference_ligand is provided) |  |
| `num_sample` | `number` | ✓ | Minimum number of molecules to generate; due to parallel beam sampling the final count may exceed this value (range: 1-10000, required) |  |
| `beam_size` | `number` | ✗ | Beam search width; larger values explore more candidates but are slower (range: 1-500, default: 300) |  |
| `focal_threshold` | `number` | ✗ | Threshold for selecting focal atoms during generation; lower values grow larger molecules, higher values yield smaller ones (range: 0.0-1.0, default: 0.5) |  |
| `pos_threshold` | `number` | ✗ | Position confidence threshold for placing new atoms; lower values accept more positions and yield larger molecules (range: 0.0-1.0, default: 0.25) |  |
| `element_threshold` | `number` | ✗ | Element prediction threshold; atoms predicted below are ignored. Lower values yield larger molecules (range: 0.0-1.0, default: 0.3) |  |
| `hasatom_threshold` | `number` | ✗ | Threshold for deciding whether an atom exists at a position; main control on molecule size — lower values generate larger molecules (range: 0.0-1.0, default: 0.6) |  |
| `bond_threshold` | `number` | ✗ | Bond prediction threshold for adding a bond between two atoms; lower values yield larger, more complex molecules (range: 0.0-1.0, default: 0.4) |  |

### 示例代码

#### 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": "Pocket2Mol",
    "tool_name": "predict_gpu_predict_gpu_post",
    "parameters": {
    "receptor": "<RECEPTOR_FILE_ID>",
    "reference_ligand": "<REFERENCE_LIGAND_FILE_ID>",
    "pocket_info": "<POCKET_INFO>",
    "num_sample": "",
    "beam_size": 300,
    "focal_threshold": 0.5,
    "pos_threshold": 0.25,
    "element_threshold": 0.3,
    "hasatom_threshold": 0.6,
    "bond_threshold": 0.4
},
    # 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/Pocket2Mol>
