# p2smi

Peptide design toolkit: FASTA to SMILES conversion with cyclizations and noncanonical residues, random library generation, chemical modification, molecular properties and synthesis feasibility.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Generate random peptide sequences with configurable composition.

**Tool Name:** `generate_peptides_generate_peptides_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `cyclization_constraints` | `select_array` | ✗ | Cyclization types randomly assigned to sequences
(options: SS = disulfide,
HT = head-to-tail,
SCNT = sidechain-N terminus,
SCCT = sidechain-C terminus,
SCSC = sidechain-sidechain,
none = no constraint;
multi-select, default: HT, none must be selected alone) | `SS`, `HT`, `SCNT`, `SCCT`, `SCSC`, `none` |
| `num_sequences` | `number` | ✗ | Number of random peptide sequences to generate (range: 1-2000, default: 10) |  |
| `length_range` | `string` | ✗ | Inclusive sequence length range, min-max (range: 0-200 per bound, min <= max, default: 10-10) |  |
| `noncanonical_fraction` | `number` | ✗ | Fraction of noncanonical amino acids per sequence (range: 0.0-1.0, default: 0.0) |  |
| `dextro_fraction` | `number` | ✗ | Fraction of D-stereochemistry residues per sequence (range: 0.0-1.0, default: 0.0) |  |

### 示例代码

#### 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": "p2smi",
    "tool_name": "generate_peptides_generate_peptides_post",
    "parameters": {
    "cyclization_constraints": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "num_sequences": 10,
    "length_range": "10-10",
    "noncanonical_fraction": 0,
    "dextro_fraction": 0
},
    # 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. Convert FASTA to SMILES, optionally adding one custom residue to the registry.

**Tool Name:** `fasta2smi_fasta2smi_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `modifications` | `select_array` | ✗ | Built-in modifications applied deterministically during peptide assembly
(options: none,
n_acetyl = N-terminal acetylation,
c_amide = C-terminal amidation,
mpeg_acetyl = N-terminal methoxy-PEGylation with 2 EO units,
octanoyl to eicosanoyl = N-terminal acylation,
hexadecanedioyl to icosanedioyl = N-terminal diacid monoacylation,
azidoacetyl and propiolyl = N-terminal click handles,
carbamidomethyl = alkylation of the unique Cys,
phosphoryl = phosphorylation of the unique hydroxyl residue;
multi-select, default: none, none must be selected alone;
cannot be combined with modifier_registry_file) | `none`, `n_acetyl`, `c_amide`, `mpeg_acetyl`, `octanoyl`, `decanoyl`, `dodecanoyl`, `tetradecanoyl`, `palmitoyl`, `stearoyl`, `eicosanoyl`, `hexadecanedioyl`, `octadecanedioyl`, `icosanedioyl`, `azidoacetyl`, `propiolyl`, `carbamidomethyl`, `phosphoryl` |
| `fasta_file` | `file` | ✓ | Peptide input file (supported formats: FASTA, one record per peptide, required)<br/>file suffix: `fasta`, `fa`, `faa`, `txt` |  |
| `custom_residue` | `file` | ✗ | Upload a JSON file defining ONE new residue, used immediately in this FASTA conversion (supported format: JSON, optional).
Omit the file when not adding a residue.
This parameter accepts a file upload, not a JSON string form value.
The file must contain one JSON object directly, not a registry with a residues list.
Required string fields:
residue_id (ASCII letter followed by letters/digits/underscore/hyphen, e.g. LAB_001; referenced in comma-delimited FASTA sequences) and name (display name).
Structure: provide either smiles (free-amino-acid SMILES without '*' placeholders) inside this JSON OR upload mol_file, exactly one.
Optional string fields: code (alternative token) and letter (one-character alias for legacy sequences); both default to empty.
IDs and aliases must not conflict with existing or built-in residues.
Only residue_id, name, smiles, code and letter are accepted; all values must be strings.
SMILES example: custom_residue.json with
{"residue_id":"LAB_001","name":"Example NCAA","smiles":"N[C@@H](CC)C(=O)O","code":"LAB_ABU","letter":"z"}.
MOL example: custom_residue.json with
{"residue_id":"LAB_001","name":"Example NCAA"} plus mol_file.
Creates a reusable residue_registry.json, or extends residue_registry_file without modifying the uploaded file.
Legacy flat residue_id/name/smiles/code/letter form fields remain accepted but must not contain values alongside this uploaded file.
Invalid JSON, field types or incomplete definitions are rejected before billing; chemical structure and identifier/alias conflicts are checked in the background job<br/>file suffix: `json` |  |
| `mol_file` | `file` | ✗ | Free-amino-acid MOL structure for the new residue (supported format: MOL, optional).
Provide with residue_id and name in the custom_residue JSON file, omitting smiles or leaving it empty; exactly one of JSON smiles or mol_file is required when adding a residue.
Leave empty for SMILES input or ordinary conversion<br/>file suffix: `mol` |  |
| `residue_registry_file` | `file` | ✗ | Existing custom residue definitions used by the FASTA (supported format: JSON, optional).
Used directly when custom_residue is omitted, or extended with the ONE new residue defined there in the same request.
The uploaded file is not modified; an extended residue_registry.json is returned with the conversion results<br/>file suffix: `json` |  |
| `modifier_registry_file` | `file` | ✗ | Custom modifier registry JSON defining exactly one recipe, applied automatically
(advanced: custom fragments, residue-scoped sites, imported lipids; supported format: JSON, optional; see EXAMPLE.md)<br/>file suffix: `json` |  |

### 示例代码

#### 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": "p2smi",
    "tool_name": "fasta2smi_fasta2smi_post",
    "parameters": {
    "modifications": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "fasta_file": "<FASTA_FILE_FILE_ID>",
    "custom_residue": "<CUSTOM_RESIDUE_FILE_ID>",
    "mol_file": "<MOL_FILE_FILE_ID>",
    "residue_registry_file": "<RESIDUE_REGISTRY_FILE_FILE_ID>",
    "modifier_registry_file": "<MODIFIER_REGISTRY_FILE_FILE_ID>"
},
    # 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.")
```


---

## 3. Apply random PEGylation/N-methylation or an explicit recipe to SMILES.

**Tool Name:** `modify_smiles_modify_smiles_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `modifications` | `select_array` | ✗ | Built-in modifications applied deterministically instead of the random rates
(options: none,
n_acetyl = N-terminal acetylation,
c_amide = C-terminal amidation,
mpeg_acetyl = N-terminal methoxy-PEGylation with 2 EO units,
octanoyl to eicosanoyl = N-terminal acylation,
hexadecanedioyl to icosanedioyl = N-terminal diacid monoacylation,
azidoacetyl and propiolyl = N-terminal click handles,
carbamidomethyl = alkylation of the unique Cys,
phosphoryl = phosphorylation of the unique hydroxyl residue;
multi-select, default: none, none must be selected alone;
cannot be combined with modifier_registry_file) | `none`, `n_acetyl`, `c_amide`, `mpeg_acetyl`, `octanoyl`, `decanoyl`, `dodecanoyl`, `tetradecanoyl`, `palmitoyl`, `stearoyl`, `eicosanoyl`, `hexadecanedioyl`, `octadecanedioyl`, `icosanedioyl`, `azidoacetyl`, `propiolyl`, `carbamidomethyl`, `phosphoryl` |
| `input_file` | `file` | ✓ | Peptide SMILES input, one 'header: SMILES' or bare SMILES per line (supported formats: TXT, SMI, P2SMI, required)<br/>file suffix: `txt`, `smi`, `smiles`, `p2smi` |  |
| `modifier_registry_file` | `file` | ✗ | Custom modifier registry JSON defining exactly one recipe, applied automatically instead of the random rates
(advanced: custom fragments, residue-scoped sites, imported lipids; supported format: JSON, optional; see EXAMPLE.md)<br/>file suffix: `json` |  |
| `peg_rate` | `number` | ✗ | Fraction of sequences to PEGylate in random mode (range: 0.0-1.0, default: 0.2) |  |
| `nmeth_rate` | `number` | ✗ | Fraction of sequences to N-methylate in random mode (range: 0.0-1.0, default: 0.2) |  |
| `nmeth_residues` | `number` | ✗ | Fraction of amide sites per sequence to N-methylate (range: 0.0-1.0, default: 0.2) |  |

### 示例代码

#### 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": "p2smi",
    "tool_name": "modify_smiles_modify_smiles_post",
    "parameters": {
    "modifications": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "input_file": "<INPUT_FILE_FILE_ID>",
    "modifier_registry_file": "<MODIFIER_REGISTRY_FILE_FILE_ID>",
    "peg_rate": 0.2,
    "nmeth_rate": 0.2,
    "nmeth_residues": 0.2
},
    # 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.")
```


---

## 4. Compute molecular properties; any invalid SMILES fails the entire task.

**Tool Name:** `analyze_properties_analyze_properties_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `input_file` | `file` | ✓ | SMILES input, one 'id: SMILES' or bare SMILES per line (supported formats: TXT, SMI, P2SMI, required)<br/>file suffix: `txt`, `smi`, `smiles`, `p2smi` |  |

### 示例代码

#### 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": "p2smi",
    "tool_name": "analyze_properties_analyze_properties_post",
    "parameters": {
    "input_file": "<INPUT_FILE_FILE_ID>"
},
    # 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.")
```


---

## 5. Evaluate peptide synthesis feasibility and annotate PASS/FAIL.

**Tool Name:** `synthesis_check_synthesis_check_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `fasta_file` | `file` | ✓ | Natural-amino-acid peptide input file (supported formats: FASTA, required)<br/>file suffix: `fasta`, `fa`, `faa`, `txt` |  |
| `max_cysteines` | `number` | ✗ | Maximum allowed cysteines before a sequence is flagged (range: 0-100, default: 2) |  |
| `max_glycine_run` | `number` | ✗ | Maximum allowed consecutive glycines before a sequence is flagged (range: 0-100, default: 4) |  |
| `max_length` | `number` | ✗ | Maximum allowed peptide length in residues (range: 1-1000, default: 50) |  |
| `charge_window` | `number` | ✗ | Required window in residues for at least one charged residue (range: 1-100, default: 5) |  |
| `max_logp` | `number` | ✗ | Maximum allowed logP before a sequence is flagged as too hydrophobic (range: -20.0-50.0, default: 0.0) |  |

### 示例代码

#### 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": "p2smi",
    "tool_name": "synthesis_check_synthesis_check_post",
    "parameters": {
    "fasta_file": "<FASTA_FILE_FILE_ID>",
    "max_cysteines": 2,
    "max_glycine_run": 4,
    "max_length": 50,
    "charge_window": 5,
    "max_logp": 0
},
    # 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.")
```


---

## 6. Import optional definitions and compile one directly executable plan.

**Tool Name:** `import_lipids_import_lipids_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `acid_mode` | `select` | ✗ | Accepted acid type (options: both, monoacid, diacid, default: both) | `both`, `monoacid`, `diacid` |
| `modification_plan` | `file` | ✓ | Upload a JSON file: either a modifier registry with exactly one recipe, or a simplified plan with steps and optional modifiers.
See [p2smi documentation](https://github.com/AaronFeller/p2smi#build-explicitly-modified-peptides) for field definitions and examples.<br/>file suffix: `json` |  |
| `lipid_file` | `file` | ✗ | Lipid structures to import as amine-acylation modifiers (supported formats: SDF, MOL, optional).
Omit when the plan uses only built-in modifiers, existing registry definitions or inline custom definitions<br/>file suffix: `sdf`, `mol` |  |
| `id_property` | `string` | ✗ | SDF property used as the modifier ID (default: LM_ID) |  |
| `name_property` | `string` | ✗ | SDF property used as the modifier display name (default: NAME) |  |
| `max_carbons` | `number` | ✗ | Maximum lipid carbon count accepted (range: 1-200, default: 20) |  |
| `modifier_registry_file` | `file` | ✗ | Existing modifier definitions to reuse or extend (JSON, optional).
The output contains only the new plan's single recipe;
existing recipes are preserved in modifier_library.json inside the ZIP.
The uploaded file is not modified<br/>file suffix: `json` |  |

### 示例代码

#### 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": "p2smi",
    "tool_name": "import_lipids_import_lipids_post",
    "parameters": {
    "acid_mode": "both",
    "modification_plan": "<MODIFICATION_PLAN_FILE_ID>",
    "lipid_file": "<LIPID_FILE_FILE_ID>",
    "id_property": "LM_ID",
    "name_property": "NAME",
    "max_carbons": 20,
    "modifier_registry_file": "<MODIFIER_REGISTRY_FILE_FILE_ID>"
},
    # 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/p2smi>
