# Bioemu2

Predict folded structures, sample equilibrium ensembles, and propagate structures forward in time.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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 prediction / equilibrium sampling; `task` selects the mode.

**Tool Name:** `predict_and_sampling_predict_and_sampling_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `task` | `select` | ✓ | What to generate. 'predict_structure' folds plausible 3D structures from the molecular composition, like a cofolding model — use it when you want one or a few trustworthy structures. 'sample_equilibrium' draws independent conformations from the modelled equilibrium ensemble, revealing flexibility and multiple conformational states. | `predict_structure`, `sample_equilibrium` |
| `sampler` | `select` | ✗ | Denoising algorithm. 'edm' (default) is the plain unguided sampler and the fastest. 'edm_gd' adds gradient guidance with the default physicality potentials (cleaner bonds and fewer clashes, slower) — the usual upgrade when structures must be physically sound. 'edm_fk' additionally applies Feynman-Kac resampling; 'edm_fkc' uses the Feynman-Kac corrector. Keep 'edm' when in doubt. Note: for 'edm_fk'/'edm_fkc', auto batching changes the resampling population (still valid samples, slightly different statistics). | `edm`, `edm_gd`, `edm_fk`, `edm_fkc` |
| `structure_file` | `file` | ✗ | The molecular system to model, as an uploaded file. Required whenever the system contains ligands, nucleic acids, modified residues, glycans, declared disulfides or contact restraints — the other two sources (pdb_id, protein_sequences) cannot express these. Accepted formats: (1) YAML (.yaml/.yml), detected by content rather than by filename: either the full BioEmu2 system YAML listing entities, bonds and contacts (the most flexible option; runnable example: system.yaml), or the compact form that starts with 'version: sciminer' — short proteins/rna/dna/ligands maps plus optional disulfides/contacts whose endpoints are [chain, residue, atom?], compiled server-side into the full YAML (runnable example: system.spec.yaml). (2) A metadata-complete mmCIF (.cif), e.g. a PDB entry downloaded from RCSB; water is dropped automatically. Plain PDB-format files are NOT supported — convert to mmCIF first. Provide exactly one of structure_file / pdb_id / protein_sequences.<br/>file suffix: `yaml`, `yml`, `cif` |  |
| `pdb_id` | `string` | ✗ | A 4-character RCSB PDB entry ID (e.g. '1UBQ' for ubiquitin, '1AKE' for adenylate kinase) used as the system instead of an uploaded file. The server downloads the entry's biological assembly 1 (the biologically relevant unit, not the crystallographic asymmetric unit) with all chains and ligands, excluding water. Requires internet access to RCSB. Provide exactly one of structure_file / pdb_id / protein_sequences. |  |
| `protein_sequences` | `string` | ✗ | The simplest input: one plain amino-acid sequence per line; each line becomes one protein chain (chain IDs A, B, C... in order). FASTA header lines starting with '>' are ignored, spaces are removed, letters are upper-cased; use X for an unknown residue (letters B, J, O, U are rejected). Proteins only — for ligands, nucleic acids, modified residues or contact restraints use structure_file. Provide exactly one of structure_file / pdb_id / protein_sequences. |  |
| `num_samples` | `number` | ✗ | How many structures to generate: for predict_structure, the number of independent folded structures; for sample_equilibrium, the number of independent conformations drawn from the ensemble. Runtime grows roughly linearly with this value. The denoising batch is sized statically from the system size and this count against the reserved GPU memory, so requesting many results does not raise peak GPU memory; extra results run as extra batches. |  |
| `num_steps` | `string` | ✗ | Number of denoising steps. Leave empty to use the sampler's built-in default (200 or 500 depending on the sampler). Larger values are slower and rarely improve results — intended for advanced use. |  |

### 示例代码

#### 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": "Bioemu2",
    "tool_name": "predict_and_sampling_predict_and_sampling_post",
    "parameters": {
    "task": "<TASK>",
    "sampler": "<SAMPLER>",
    "structure_file": "<STRUCTURE_FILE_FILE_ID>",
    "pdb_id": "<PDB_ID>",
    "protein_sequences": "<PROTEIN_SEQUENCES>",
    "num_samples": 8,
    "num_steps": "<NUM_STEPS>"
},
    # 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. Sample time-lagged endpoints from starting conformations.

**Tool Name:** `propagate_gpu_propagate_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `sampler` | `select` | ✗ | Denoising algorithm. 'edm' (default) is the plain unguided sampler and the fastest. 'edm_gd' adds gradient guidance with the default physicality potentials (cleaner bonds and fewer clashes, slower) — the usual upgrade when structures must be physically sound. 'edm_fk' additionally applies Feynman-Kac resampling; 'edm_fkc' uses the Feynman-Kac corrector. Keep 'edm' when in doubt. | `edm`, `edm_gd`, `edm_fk`, `edm_fkc` |
| `x0_structure` | `file` | ✓ | The starting structure at time zero, as an mmCIF file: propagation asks 'starting from this structure, where might the molecule be after lag_time_ns?'. Its atoms must exactly match the system's atoms, in the same order — the topology.cif written by any previous run of this tool satisfies this by construction; arbitrary external structures often do not (the error names the first mismatching atom). When structure_file is omitted the system is also inferred from this file, and it serves as the topology for x0_trajectory.<br/>file suffix: `cif` |  |
| `x0_trajectory` | `file` | ✗ | Optional XTC trajectory holding several starting structures (e.g. the samples.xtc written by a previous run): one endpoint is sampled per input frame, in the same order. Omit it to instead sample num_samples endpoints from the single structure contained in x0_structure.<br/>file suffix: `xtc` |  |
| `lag_time_ns` | `number` | ✓ | How far into the future each starting structure is advanced, in nanoseconds (1.0 = sample the state 1 ns later). Recommended 1-1000 ns (1 ns - 1 us), the range the model was mostly trained on; at much longer lags the start loses influence and results approach equilibrium sampling. |  |
| `structure_file` | `file` | ✗ | Optional explicit system definition that overrides the system inferred from x0_structure: a BioEmu2 system YAML (.yaml/.yml), a compact system.spec.yaml (version: sciminer; may omit its source to use x0_structure), or a metadata-complete mmCIF (.cif). Use it only to keep definitions that CIF inference drops: declared extra bonds (e.g. disulfides) and contact restraints. For the common case — propagating the output of a previous run — omit it.<br/>file suffix: `yaml`, `yml`, `cif` |  |
| `num_samples` | `number` | ✗ | Endpoints sampled from the single structure in x0_structure; each endpoint is an independent possible future. Ignored when x0_trajectory is provided (then one endpoint is sampled per input frame). Endpoints are denoised in statically sized batches bounded by the reserved GPU memory, so this count does not raise peak VRAM. |  |
| `num_steps` | `string` | ✗ | Number of denoising steps. Leave empty to use the sampler's built-in default (200 or 500 depending on the sampler). Larger values are slower and rarely improve results — intended for advanced use. |  |

### 示例代码

#### 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": "Bioemu2",
    "tool_name": "propagate_gpu_propagate_post",
    "parameters": {
    "sampler": "<SAMPLER>",
    "x0_structure": "<X0_STRUCTURE_FILE_ID>",
    "x0_trajectory": "<X0_TRAJECTORY_FILE_ID>",
    "lag_time_ns": "",
    "structure_file": "<STRUCTURE_FILE_FILE_ID>",
    "num_samples": 8,
    "num_steps": "<NUM_STEPS>"
},
    # 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/Bioemu2>
