# ESMFold2

Predict the 3D structure of a protein/DNA/RNA/ligand complex with ESMFold2, returning an mmCIF structure and a rich set of confidence/quality metrics (pLDDT, pTM, ipTM, complex pLDDT/ipLDDT, pAE/pDE aggregates, interface & ligand metrics, per-chain pDockQ2).

## 基础信息

| 项目 | 值 |
|------|-----|
| 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`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `protein_msa_method` | `select` | ✗ | How to obtain MSA for the protein chains: 'mmseqs2' (auto-generate MSA for all protein chains via the internal MMseqs2 API), 'upload_file' (use the uploaded protein_msa_file), or 'no_msa' (single-sequence mode). Any MSA method requires the Full model. | `mmseqs2`, `upload_file`, `no_msa` |
| `model` | `select` | ✗ | Model to fold with: esmfold2 (ESMFold2 Full — 48-layer trunk, MSA encoder enabled, higher accuracy, slower/larger) or esmfold2-fast (ESMFold2-Fast — 24-layer trunk, MSA encoder disabled, faster/lower memory). | `esmfold2`, `esmfold2-fast` |
| `protein` | `array` | ✗ | Protein sequences, one amino-acid sequence per array element. |  |
| `protein_msa_file` | `file` | ✗ | MSA file (a3m or stockholm) to use when protein_msa_method='upload_file'. Optional. |  |
| `dna` | `array` | ✗ | DNA sequences, one nucleotide sequence per array element. Optional. |  |
| `rna` | `array` | ✗ | RNA sequences, one nucleotide sequence per array element. Optional. |  |
| `ligand_smiles` | `string` | ✗ | Ligands, one SMILES per line (use the ketcher editor). Optional. |  |
| `num_loops` | `number` | ✗ | Number of trunk prediction/recycling loops over the sequence (more = higher accuracy but slower; the reference default is 20, the tutorial uses 10) |  |
| `num_sampling_steps` | `number` | ✗ | Number of diffusion denoising steps used to decode the structure (higher = higher quality but slower). THIS IS THE CRITICAL KNOB: below ~50 steps the diffusion sampler has not converged and the output is an unfolded/random cloud (real runs at steps 5-10 produced pLDDT ~0.2). Reference uses 100-200. Must stay >= 50. |  |
| `covalent_bonds` | `array` | ✗ | Covalent bonds, one per array element, format ChainA-ResPosA-AtomA-ChainB-ResPosB-AtomB, e.g. "P1-45-SG-L1-1-C1". Chain ids must match the tool's generated ids (protein1, protein2, ..., dna1, rna1, LIG1). Optional. |  |
| `num_diffusion_samples` | `number` | ✗ | Number of independent diffusion samples to draw; the highest-confidence (mean pLDDT) structure is returned. More samples = higher quality but slower. Default 1. |  |

### 示例代码

#### 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": "ESMFold2",
    "tool_name": "predict_gpu_predict_gpu_post",
    "parameters": {
    "protein_msa_method": "<PROTEIN_MSA_METHOD>",
    "model": "<MODEL>",
    "protein": [],
    "protein_msa_file": "<PROTEIN_MSA_FILE_FILE_ID>",
    "dna": [],
    "rna": [],
    "ligand_smiles": "<LIGAND_SMILES>",
    "num_loops": 5,
    "num_sampling_steps": 100,
    "covalent_bonds": [],
    "num_diffusion_samples": 1
},
    # 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/ESMFold2>
