# CAPE-BEAM

CAPE-Beam: a decoding strategy for ProteinMPNN that redesigns a protein sequence against a fixed input backbone with reduced cytotoxic T-lymphocyte (CTL) immunogenicity risk.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. TYPE 2: Returns code 20002 immediately (queued). Drives state via callbacks.
When X-SCIMINER-ACTION == 'estimate', returns a cost/time estimate (code 20003) instead.

**Tool Name:** `predict_async_predict_async_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `proteome` | `select` | ✗ | Proteome defining self-kmers / central tolerance. Single-select. Options: 'human' (default, full GRCh38), 'mouse' (GRCm39), 'rat' (mRatBN7.2), 'cyno' (cynomolgus macaque), or 'upload' = use a user-uploaded FASTA (proteome_file required). Pre-built presets need no upload; 'upload' requires proteome_file and is ASSUMED to be human data (the MHC-I presentation check stays available with human HLA alleles). Non-human presets (mouse/rat/cyno) disable the MHC-I presentation check (mhc_1_alleles ignored — proteome-only central-tolerance design). | `human (122k)`, `mouse (66k)`, `rat (46k)`, `cyno (50k)`, `upload (human)` |
| `mhc_1_locus` | `select_array` | ✗ | HLA locus for the ParamRelationSelect coupling (parameter one; multi-select: HLA-A, HLA-B, HLA-C, HLA-E, HLA-G). Send repeated query values to select multiple loci. The mhc_1_alleles picker returns locus-tagged tokens such as HLA-A-02-01,HLA-B-07-02, which are expanded individually to full allele names. | `HLA-A`, `HLA-B`, `HLA-C`, `HLA-E`, `HLA-G` |
| `protein_type` | `select` | ✗ | Input protein oligomeric state (options: MONOMER-single chain, HOMOOLIGOMER-identical chains, default: MONOMER) | `MONOMER`, `HOMOOLIGOMER` |
| `mhc_1_predictor` | `select` | ✗ | MHC-I presentation predictor (options: pwm-static PWM, pwm_dynamic-dynamic limit PWM, netmhcpan-NetMHCpan, default: pwm_dynamic). | `pwm`, `pwm_dynamic`, `netmhcpan` |
| `pdb_file` | `file` | ✓ | Input protein backbone structure to redesign (supported formats: PDB, mmCIF, required)<br/>file suffix: `pdb`, `cif` |  |
| `proteome_file` | `file` | ✗ | User-uploaded proteome FASTA. Required only when proteome=upload; ignored otherwise.<br/>file suffix: `fasta`, `fa`, `fas` |  |
| `mhc_1_alleles` | `string` | ✗ | MHC-I alleles to deimmunize against, selected with the ParamRelationSelect plugin coupled to mhc_1_locus. The plugin returns locus-tagged tokens 'HLA-<locus>-<group>-<subtype>' comma-separated (e.g. 'HLA-A-02-01,HLA-B-07-02'); the backend composes full NetMHCpan-style names (HLA-A*02:01,HLA-B*07:02), dedupes and re-joins them with '+' for the design subprocess. Full names (HLA-A*02:01) are accepted too. Each composed name is format- AND existence-checked against netMHCpan's 10480 real HLA-I alleles before credits are frozen. Required (non-empty) only when proteome is human/upload AND min_self_kmer_length<=9 (the MHC-I presentation check is active). Ignored otherwise (non-human proteome preset, or min_self_kmer_length=10 proteome-only fast mode). |  |
| `min_self_kmer_length` | `number` | ✗ | Minimum length of self-kmers enforced from the proteome (range: 4-10, default: 10). Non-self kmers longer than this (and of MHC-I length 8/9/10) may pass via the MHC-I presentation check when it is active. 10 = proteome-only fast mode: the MHC-I check is skipped entirely (no alleles needed). Lower values activate the MHC-I check for progressively more kmer lengths (9 -> 10-mers only; <=7 -> all of 8/9/10). |  |
| `width` | `number` | ✗ | Max number of beams kept in parallel; returned sequences may be fewer if beams are pruned (range: 1-100, default: 10) |  |
| `depth` | `number` | ✗ | Look-ahead depth when estimating future probability of each candidate (range: 1-30, default: 12) |  |
| `design_positions` | `string` | ✗ | Residue positions to redesign: these are re-designed by CAPE-Beam while every other residue keeps its input-PDB identity. Chain + comma-separated ranges, chain blocks separated by semicolons (e.g. 'A: 10-15,40,52-58' or 'C: 10-15; D: 40-55'). Multiple chains of any lengths are supported; chains not selected stay entirely fixed for MONOMER. For HOMOOLIGOMER the selection is copied to all tied chains. Empty = redesign the whole chain (default). |  |

### 示例代码

#### 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": "CAPE-BEAM",
    "tool_name": "predict_async_predict_async_post",
    "parameters": {
    "proteome": "human (122k)",
    "mhc_1_locus": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "protein_type": "MONOMER",
    "mhc_1_predictor": "pwm_dynamic",
    "pdb_file": "<PDB_FILE_FILE_ID>",
    "proteome_file": "<PROTEOME_FILE_FILE_ID>",
    "mhc_1_alleles": "",
    "min_self_kmer_length": 8,
    "width": 10,
    "depth": 12,
    "design_positions": ""
},
    # 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/CAPE-BEAM>
