# Haddock3

HADDOCK3 biomolecular docking: pick a docking scenario and a refinement level, upload the molecules (plus an optional constraints JSON file or a CAPRI reference), and get back docked models, CAPRI scores and the full run archive.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Submit a docking job; retry severe output loss and return available unique models.

Returns immediately; the background task reports failure only if no usable
docking/refinement model is available after its bounded recovery attempts.

**Tool Name:** `predict_async_predict_async_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `docking_scenario` | `select` | ✗ | What is docked; combined with refinement_level it selects the final chain: refinement_level sets the depth (rigidbody -> flexref -> emref/mdref), docking_scenario swaps the ensemble-analysis modules.
protein-protein: proteins/peptides/antibodies/nucleic acids; contact clustering (clustfcc).
protein-ligand: small-molecule ligand (topology auto-generated); ligand-RMSD clustering (ilrmsdmatrix + clustrmsd); standard ends at flexref (no emref).
glycan: protein-carbohydrate; RMSD clustering (rmsdmatrix/ilrmsdmatrix + clustrmsd); cluster-first at standard level.
refine: no sampling stage; refines uploaded poses/complexes directly (topoaa -> flexref -> ...); sampling ignored, single molecule allowed. | `protein-protein`, `protein-ligand`, `glycan`, `refine` |
| `refinement_level` | `select` | ✗ | How thorough (protein-protein shown, after topoaa and with caprieval scoring steps interleaved; other scenarios swap the clustering modules, see docking_scenario):
quick (rigid-body sampling + scoring only): rigidbody
standard: rigidbody -> seletop -> flexref -> emref -> clustfcc -> seletopclusts
cltsel (cluster first, refine representatives): rigidbody -> clustfcc -> seletopclusts -> flexref -> emref -> clustfcc -> seletopclusts
thorough (adds MD refinement): rigidbody -> seletop -> flexref -> mdref -> clustfcc -> seletopclusts
Modules: rigidbody=rigid-body sampling, flexref=semi-flexible refinement, emref=explicit-solvent refinement, mdref=MD refinement, seletop=top-N by score, clustfcc=clustering, seletopclusts=best per cluster. | `quick`, `standard`, `cltsel`, `thorough` |
| `molecule_files` | `file_array` | ✓ | Molecule structures to dock (.pdb/.cif), 2-20 files (1 allowed for the refine scenario). Upload order defines mol1, mol2, ... For protein-ligand docking the ligand structure is one of these files. Required.<br/>file suffix: `pdb`, `cif` |  |
| `reference_file` | `file` | ✗ | Reference structure (.pdb/.cif) for CAPRI evaluation. Optional; defaults to the best-scoring model.<br/>file suffix: `pdb`, `cif` |  |
| `restraints_file` | `file` | ✗ | Optional: upload a UTF-8 .json file (max 2 MiB); the backend generates CNS .tbl files automatically - do not upload .tbl.
File format: {"version":"1.0","constraints":[constraint1,constraint2,...]}.
All constraints in the array are applied together; no category or id fields are needed. molecule is the 1-based index following the molecule_files upload order;
chain is a one-letter chain ID present in the structure and must not repeat across files; residue/residues are structure residue numbers,
not sequence positions; atom/atoms are exact atom names already present in the uploaded structure. Missing residues/atoms, insertion codes or unknown fields raise an error.

Each record in constraints is filled in according to its type:
1. interface: both sides provide molecule, chain, residues (array of active residues), e.g.
{"type":"interface","left":{"molecule":1,"chain":"A","residues":[38,40,45]},
"right":{"molecule":2,"chain":"B","residues":[15,16,20]}}.
Surface passive residues within 6.5 Å are computed automatically by default; add "passive":[37,39] on either side to set them manually,
"passive":[] adds none. When only one side is known, leave the other side's residues as [] and the surface residues of its whole chain are used.
Multiple interface records express A-B, B-C, ... relations; the list is not paired by position.
2. distance: both sides provide molecule, chain, residue, atom and distance is [min,max] in Å, e.g.
{"type":"distance","left":{"molecule":1,"chain":"A","residue":45,"atom":"CA"},
"right":{"molecule":2,"chain":"B","residue":20,"atom":"O"},"distance":[6,10]}.
Using the same molecule on both ends describes an intramolecular distance. residues/atoms arrays select sets; omitting atom/atoms selects the whole residue.
3. contact: same selection format as distance, generating an ambiguous (AIR) contact restraint; distance may be omitted.
Multiple candidates use {"any_of":[selection1,selection2]}; a candidate is one aggregated distance and not all candidates must be contacted simultaneously.
4. hbond: same format as distance, written to the hydrogen-bond distance category; e.g. N and O with distance:[2.6,3.2]; no angle term is added automatically.
5. dihedral: four ordered single-atom addresses atoms:[addr1,addr2,addr3,addr4], angle:-60, tolerance:20 (degrees).
E.g. C44-N45-CA45-C45; requires a chain that contains a refinement stage - not available for protein-protein/quick.
6. symmetry: distance_pairs:[{"left":single-atom address,"right":single-atom address},
{"left":single-atom address,"right":single-atom address}] requesting two equal distances.
7. alternatives: sets:[[interface or contact records,...],[another set of records,...]]; each model uses one of the AIR sets;
only one alternatives block is allowed, with at least two sets; sampling must be at least the number of sets; not supported for the refine scenario.

By default a fraction of the interface/contact AIRs is randomly removed (HADDOCK default); to keep all of them add
"options":{"random_removal":false} to the root object. distance/hbond do not take part in the random removal.
For an advanced asymmetric distance tolerance write distance as
{"target_angstrom":8,"lower_tolerance_angstrom":1,"upper_tolerance_angstrom":2}.
Omitting the file or using constraints:[] means no known restraints; rigid-body docking then uses centre-of-mass restraints and no real interface is inferred.
The former interface_residues_1/2 parameters have been replaced by this file.
<br/>file suffix: `json` |  |
| `sampling` | `number` | ✗ | Number of rigid-body docking poses sampled (rigidbody.sampling). Ignored when the chain has no rigidbody stage (refine scenario). |  |

### 示例代码

#### 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": "Haddock3",
    "tool_name": "predict_async_predict_async_post",
    "parameters": {
    "docking_scenario": "<DOCKING_SCENARIO>",
    "refinement_level": "<REFINEMENT_LEVEL>",
    "molecule_files": [
        "<FILE_ID1>",
        "<FILE_ID2>"
    ],
    "reference_file": "<REFERENCE_FILE_FILE_ID>",
    "restraints_file": "<RESTRAINTS_FILE_FILE_ID>",
    "sampling": 20
},
    # 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/Haddock3>
