# BindCraft

A simple binder design pipeline integrating AlphaFold2 backpropagation, ProteinMPNN, and PyRosetta. By combining AlphaFold2’s accurate protein structure prediction, deep learning-based sequence design, and Rosetta-based structural refinement, this pipeline enables efficient generation and optimization of protein binders.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Get Bindcraft

**Tool Name:** `get_BindCraft_get_BindCraft_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `binder_mode` | `select` | ✓ | Type of binder to design (options: default-standard binder for globular target proteins, peptide-short peptide binder, betasheet-beta-sheet binder, required). Together with stage, use_mpnn and flexibility it selects the design preset, and with use_filter it selects the filter preset (peptide mode uses peptide-specific filters); unsupported combinations are rejected with a message listing all supported ones. | `default`, `peptide`, `betasheet` |
| `stage` | `select` | ✓ | Number of design pipeline stages (options: 3-faster protocol, 4-more thorough protocol that also takes longer per attempt, required). Multiplies with binder_mode, use_mpnn and flexibility to select the design preset. | `3`, `4` |
| `flexibility` | `select` | ✓ | How much the target structure is allowed to move during design (options: default-standard protocol, flexible-target gets conformational freedom, hardtarget-target kept fully rigid, flexible_hardtarget-flexible target with rigid binding interface, required). Only the binder_mode x stage x use_mpnn x flexibility combinations available on the server are accepted; an invalid combination returns an error listing the supported ones. | `default`, `flexible`, `hardtarget`, `flexible_hardtarget` |
| `use_mpnn` | `select` | ✓ | Whether to redesign the binder sequence with ProteinMPNN after backbone generation (options: True-recommended, usually better sequences and a higher design success rate; False-keep the initial sequences, required). When use_mpnn=True the mpnn_model_type parameter selects the model weights. | `True`, `False` |
| `mpnn_model_type` | `select` | ✗ | ProteinMPNN model weights used when use_mpnn=True (options: soluble-trained on soluble proteins, recommended for most targets; original-original MPNN weights, optional, default: soluble). Ignored when use_mpnn=False. | `soluble`, `original` |
| `use_filter` | `select` | ✓ | Whether final designs must pass the quality-filter set (options: True-recommended, only designs passing the filters are returned; False-no filtering, required). When use_filter=True the filter_type parameter selects strict or relaxed filters. | `True`, `False` |
| `filter_type` | `select` | ✗ | Filter set applied when use_filter=True (options: default-strict filters, higher final quality but more candidates rejected; relaxed-looser filters, higher success rate but lower average quality, optional, default: default). The peptide binder_mode automatically uses the peptide-specific version of the selected set. Ignored when use_filter=False. | `default`, `relaxed` |
| `pdb_file` | `file` | ✓ | Target protein structure file that the designed binder must bind (supported formats: PDB, required). The chain ids given in 'chains' and the residue numbers given in 'target_hotspot_residues' must be taken from this file. Only the chain(s) listed in 'chains' are used as the target — all other chains in this file are ignored and not counted towards the length limits. The target chain(s) must not exceed 328 residues, and target + binder must not exceed 400 residues in total — requests exceeding these limits are rejected immediately, before the task is queued. |  |
| `chains` | `string` | ✓ | Chain id(s) of the target protein to design a binder against (format: comma-separated chain ids exactly as they appear in the uploaded PDB file, e.g. 'A' or 'A,B', required). Only the chain(s) listed here are used as the target — all other chains in the uploaded file are ignored (also for length checks). The hotspot residues selected in 'target_hotspot_residues' should lie on these target chains. |  |
| `target_hotspot_residues` | `string` | ✓ | Hotspot residues on the target that the binder must contact, exactly as returned by the residue-selection plugin (format: 'Chain: start-end,start' segments separated by ';', e.g. 'A: 191,194-199; B: 30-34', required). The plugin returns the ACTUAL residue numbers of the uploaded PDB file — do not renumber them, and do not paste values like 'A 191' or 'A191': the chain id and the residues must be separated by a colon. Invalid formats are rejected immediately, before the task is queued. |  |
| `lengths` | `string` | ✗ | Length range of the binder to design (format: 'min-max' or a single fixed length, unit: amino acid residues, optional, default: 65-128). The binder length must not exceed 128 residues, and together with the target chain(s) listed in 'chains' the total must not exceed 400 residues — requests exceeding these limits are rejected immediately, before the task is queued. Longer binders need more compute per design attempt; if attempts fail with 'Timeout', increase 'timeout' or narrow this range. |  |
| `number_of_final_designs` | `number` | ✗ | Number of independent binder designs to run (range: 1-3, optional, default: 1). Designs run sequentially and each one is a full design attempt bounded by 'timeout', so the overall task can take up to timeout x number_of_final_designs hours. Results of already-finished designs are returned incrementally while the remaining ones are still running. |  |
| `timeout` | `number` | ✗ | Maximum runtime in hours allowed for ONE design attempt (range: 1-32, default: 3). The task runs number_of_final_designs attempts sequentially, so the overall job time can reach timeout x number_of_final_designs hours. The allowed maximum depends on your membership level (FREE Plan: 8h, Iron Shovel Plan: 16h, Silver Shovel Plan: 32h) — upgrading your membership grants a longer runtime per task. If the task fails with 'Timeout', increase this parameter and submit again. |  |

### 示例代码

#### 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": "BindCraft",
    "tool_name": "get_BindCraft_get_BindCraft_post",
    "parameters": {
    "binder_mode": "<BINDER_MODE>",
    "stage": "<STAGE>",
    "flexibility": "<FLEXIBILITY>",
    "use_mpnn": "<USE_MPNN>",
    "mpnn_model_type": "<MPNN_MODEL_TYPE>",
    "use_filter": "<USE_FILTER>",
    "filter_type": "<FILTER_TYPE>",
    "pdb_file": "<PDB_FILE_FILE_ID>",
    "chains": "<CHAINS>",
    "target_hotspot_residues": "<TARGET_HOTSPOT_RESIDUES>",
    "lengths": "65-128",
    "number_of_final_designs": 1,
    "timeout": 3
},
    # 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/BindCraft>
