# FoldX

Protein folding and molecular modeling forcefield tool for stability analysis, mutation prediction, and complex interaction calculations

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Structure repair/modeling operations: RepairPDB, BuildModel, Optimize.

**Tool Name:** `structure_ops_structure_ops_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `operation` | `select` | ✗ | Structure operation type (options: RepairPDB-repair structure, BuildModel-introduce mutations, Optimize-optimize structure, default: RepairPDB) | `RepairPDB`, `BuildModel`, `Optimize` |
| `pdb_file` | `file` | ✓ | PDB structure file (supported formats: PDB, mmCIF, required)<br/>file suffix: `pdb`, `cif` |  |
| `mutations` | `string` | ✗ | Mutation list for BuildModel operation only (format: Chain:ORIAA-Position-NEWAA, semicolon-separated, e.g., 'A:A-5-G; B:D-10-K; C:R-20-W', ignored for other operations) |  |
| `temperature` | `number` | ✗ | Temperature in Kelvin (0-500, affects protein stability: 298K=room temp, 310K=body temp, 340K+=thermophilic conditions) |  |
| `ph` | `number` | ✗ | pH value (0-14, affects amino acid protonation state: 2-4=acidic/lysosomal, 7.0-7.4=physiological, 8-10=alkaline) |  |
| `number_of_runs` | `number` | ✗ | Number of FoldX runs (1-5, affects result reliability: 1=fast screening, 3-5=improved accuracy for final predictions) |  |

### 示例代码

#### 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": "FoldX",
    "tool_name": "structure_ops_structure_ops_post",
    "parameters": {
    "operation": "<OPERATION>",
    "pdb_file": "<PDB_FILE_FILE_ID>",
    "mutations": "<MUTATIONS>",
    "temperature": 298,
    "ph": 7,
    "number_of_runs": 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.")
```


---

## 2. Energy and stability analysis: Stability, AnalyseComplex, AlaScan, PositionScan.

**Tool Name:** `energy_ops_energy_ops_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `operation` | `select` | ✗ | Energy operation type (options: Stability-stability analysis, AnalyseComplex-complex interaction analysis, AlaScan-alanine scanning, PositionScan-position scanning, default: Stability) | `Stability`, `AnalyseComplex`, `AlaScan`, `PositionScan` |
| `pdb_file` | `file` | ✓ | PDB structure file (supported formats: PDB, mmCIF, required)<br/>file suffix: `pdb`, `cif` |  |
| `residues` | `string` | ✗ | Residue regions for AlaScan (format: ChainID: start-end, semicolon-separated, e.g., 'A: 1-172; B: 1-34' from residue picker plugin, optional) |  |
| `temperature` | `number` | ✗ | Temperature in Kelvin (0-500, affects protein stability: 298K=room temp, 310K=body temp, 340K+=thermophilic conditions) |  |
| `ph` | `number` | ✗ | pH value (0-14, affects amino acid protonation state: 2-4=acidic/lysosomal, 7.0-7.4=physiological, 8-10=alkaline) |  |

### 示例代码

#### 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": "FoldX",
    "tool_name": "energy_ops_energy_ops_post",
    "parameters": {
    "operation": "<OPERATION>",
    "pdb_file": "<PDB_FILE_FILE_ID>",
    "residues": "<RESIDUES>",
    "temperature": 298,
    "ph": 7
},
    # 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/FoldX>
