# Protein Mutation

Point-mutation scanning with Chai-1: each mutation group is re-folded with all ligands/glycans bound, the selected ligand is scored with Gnina, and per-ligand 2D interaction diagrams are generated.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Re-folds each mutation group of a protein/DNA/RNA complex with Chai-1, keeping all ligands/glycans bound. The selected ligand (score_smiles_idx) is evaluated with Gnina (Affinity / CNN Score / CNN Affinity), and 2D interaction diagrams are generated per ligand.

**Tool Name:** `get_chai_info_from_params_mutation_get_chai_info_from_params_mutation_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `MSA_method` | `select` | ✓ | Protein MSA method: 'Search MSA' (server MMseqs2), 'Upload File' (use MSA_file) or 'No MSA'. Applies to all mutation groups. | `Search MSA`, `Upload File`, `No MSA` |
| `Template_method` | `select` | ✓ | Protein template method: 'Default Search Template' (only with MSA_method='Search MSA') or 'No Template'. | `Default Search Template`, `No Template` |
| `MSA_file` | `file` | ✗ | Protein MSA file (a3m), shared by ALL protein sequences. Required when MSA_method is 'Upload File'.<br/>file suffix: `a3m` |  |
| `protein` | `string` | ✗ | Wild-type protein sequences, one per chain (list order = P1/P2/...). Max 5 polymer chains (protein+DNA+RNA combined). |  |
| `dna` | `string` | ✗ | Wild-type DNA sequences, one per chain (list order = D1/D2/...). |  |
| `rna` | `string` | ✗ | Wild-type RNA sequences, one per chain (list order = R1/R2/...). |  |
| `sequence_mutation` | `string` | ✗ | Mutation groups to scan, one string per group. Format: 'ChainID,origRes-index-newRes|...' (multiple chains separated by ';', simultaneous mutations by '|'). ChainID is P#/D#/R#; index is 1-based and origRes is validated against the sequence. Example: 'P1,A-17-G|S-20-N' scans one group with A17G+S20N applied together. |  |
| `ligand_smiles` | `string` | ✗ | Ligand SMILES, one per line in a single string (line order = L1/L2/... numbering used by score_smiles_idx). Draw via the ketcher plugin; '.select(...).sdf(...)' marks a covalent attachment atom. At least one ligand or glycan required; max 50 ligands. |  |
| `score_smiles_idx` | `string` | ✗ | Ligand to score with Gnina, as 'L<n>' (n = 1-based line number in ligand_smiles, e.g. 'L1'). Required when ligands are present; glycans cannot be scored. |  |
| `glycan` | `string` | ✗ | Glycan sequences, one per chain. Folded with the assembly but not Gnina-scored. At least one ligand or glycan required; max 50. |  |
| `covalent_bonds` | `string` | ✗ | Covalent bonds as chainA-res_idxA-res_name/atom-chainB-res_idxB-res_name/atom (6 fields). Polymer res_idx must be residue+position (e.g. C217). Example: P1-C217-SG-L1-1-S1. |  |
| `contact_restraints` | `string` | ✗ | Contact restraints as chainA-res_idxA-chainB-res_idxB-min_max_distance_angstrom (6 fields). Polymer res_idx must be residue+position. Example: P1-C387-P2-Y101-0.0-5.5. |  |
| `pocket_restraints` | `string` | ✗ | Pocket restraints as chainA-chainB-res_idxB-min-max_distance_angstrom (5 fields). Example: L1-P1-C387-0.0-5.5. |  |
| `num_diffn_samples` | `number` | ✗ | Predicted structures per mutation group (1-20). |  |

### 示例代码

#### 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": "Protein Mutation",
    "tool_name": "get_chai_info_from_params_mutation_get_chai_info_from_params_mutation_post",
    "parameters": {
    "MSA_method": "Search MSA",
    "Template_method": "Default Search Template",
    "MSA_file": "<MSA_FILE_FILE_ID>",
    "protein": "<PROTEIN>",
    "dna": "<DNA>",
    "rna": "<RNA>",
    "sequence_mutation": "<SEQUENCE_MUTATION>",
    "ligand_smiles": "<LIGAND_SMILES>",
    "score_smiles_idx": "<SCORE_SMILES_IDX>",
    "glycan": "<GLYCAN>",
    "covalent_bonds": "<COVALENT_BONDS>",
    "contact_restraints": "<CONTACT_RESTRAINTS>",
    "pocket_restraints": "<POCKET_RESTRAINTS>",
    "num_diffn_samples": 5
},
    # 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/Protein-Mutation>
