# Protein Property Finetune

An API derived from the unified protein engineering open platform VenusFactory. It specifically targets the model training component, offering a convenient and efficient model training API interface.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Protein Property Finetune

**Tool Name:** `protein_property_finetune_protein_property_finetune_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `protein_language_model` | `select` | ✓ | Protein Language Model | `facebook/esm2_t33_650M_UR50D`, `facebook/esm2_t30_150M_UR50D`, `facebook/esm2_t36_3B_UR50D`, `Rostlab/prot_bert`, `Rostlab/prot_bert_bfd`, `Rostlab/prot_t5_xl_uniref50`, `Rostlab/prot_t5_xl_bfd`, `ElnaggarLab/ankh-base`, `ElnaggarLab/ankh-large`, `AI4Protein/Prime_690M`, `AI4Protein/ProSST-4096`, `AI4Protein/VenusPLM-300M`, `Exscientia/IgBert`, `Exscientia/IgBert_unpaired`, `Exscientia/IgT5`, `Exscientia/IgT5_unpaired` |
| `dataset_selection` | `select` | ✓ | Dataset Selection | `Use Custom Dataset`, `Use Pre-defined Dataset` |
| `dataset_source` | `select` | ✗ | Dataset Source | `DeepLocBinary - Binary classification: protein membrane localization`, `DeepET_Topt - Regression: protein optimal temperature prediction`, `DeepLoc2Multi - Multi-label classification: protein subcellular localization`, `DeepLocMulti - Single-label classification: protein specific localization`, `DeepSol - Binary classification: protein solubility prediction`, `DeepSoluE - Binary classification: protein solubility prediction`, `EC - Multi-label classification: enzyme commission number prediction`, `eSOL - Regression: protein solubility prediction`, `GO_BP - Multi-label classification: gene ontology biological process prediction`, `GO_CC - Multi-label classification: gene ontology cellular component prediction`, `GO_MF - Multi-label classification: gene ontology molecular function prediction`, `MetalIonBinding - Binary classification: metal ion binding prediction`, `PETA_CHS_Sol - Regression: protein mutation solubility prediction`, `PETA_LGK_Sol - Regression: protein mutation solubility prediction`, `PETA_TEM_Sol - Regression: protein mutation solubility prediction`, `ProtSolM - Binary classification: protein solubility prediction based on PDB structures`, `SortingSignal - Multi-label classification: protein sorting signal prediction`, `TAPE_Fluorescence - Regression: fluorescence intensity prediction for mutated proteins`, `TAPE_Stability - Regression: protein stability prediction`, `Thermostability - Regression: protein thermostability prediction`, `FLIP_AAV_one-vs-rest - Binary classification: distinguish single from other mutations`, `FLIP_AAV_two-vs-rest - Binary classification: detect epistasis in double mutations`, `FLIP_AAV_mut-des - Regression: predict functional change from wild-type to mutant`, `FLIP_AAV_des-mut - Regression: predict functional recovery from mutant to wild-type`, `FLIP_AAV_seven-vs-rest - Binary classification: identify 7 high-frequency mutant combinations`, `FLIP_AAV_low-vs-high - Binary classification: classify mutants by low/high fitness`, `FLIP_AAV_sampled - Binary classification: baseline task with random partitioning`, `FLIP_GB1_one-vs-rest - Binary classification: identify single-point mutations`, `FLIP_GB1_two-vs-rest - Binary classification: detect epistasis in double mutations`, `FLIP_GB1_three-vs-rest - Binary classification: predict functionality of triple mutations`, `FLIP_GB1_low-vs-high - Binary classification: classify mutations by binding affinity`, `FLIP_GB1_sampled - Binary classification: baseline task with random partitioning` |
| `dataset_type` | `select` | ✗ | Dataset Type | `AlphaFold2`, `ESMFold`, `Basic` |
| `problem_type` | `select` | ✗ | Dataset Problem Type (Required for Custom Dataset) | `single_label_classification`, `multi_label_classification`, `regression` |
| `metrics` | `select_array` | ✗ | Metrics (Required for Custom Dataset) | `accuracy`, `mcc`, `f1`, `precision`, `recall`, `auroc`, `f1_max`, `mse`, `spearman_corr` |
| `monitor` | `select_array` | ✗ | Monitor (Required for Custom Dataset) | `accuracy`, `mcc`, `f1`, `precision`, `recall`, `auroc`, `f1_max`, `mse`, `spearman_corr` |
| `monitor_strategy` | `select` | ✗ | Monitor Strategy (Required for Custom Dataset) | `max`, `min` |
| `normalize` | `select` | ✗ | Normalize | `min_max`, `standard` |
| `training_method` | `select` | ✓ | Training Method | `full`, `freeze`, `ses-adapter`, `plm-lora`, `plm-qlora`, `plm-adalora`, `plm-dora`, `plm-ia3` |
| `pooling_method` | `select` | ✗ | Pooling method | `mean`, `attention1d`, `light_attention` |
| `lora_target_modules` | `select` | ✗ | Lora target module | `q k v`, `q k v wo`, `--` |
| `structure_seq` | `select_array` | ✗ | Structure Seq | `foldseek_seq`, `ss8_seq` |
| `training_model_name` | `string` | ✓ | Training Model Name. |  |
| `dataset_file` | `file` | ✗ | Dataset file (CSV format). Data will be split 8:2 for training and evaluation. Required when dataset_selection is 'Use Custom Dataset'. |  |
| `number_of_labels` | `string` | ✗ | Number of labels (Required for Custom Dataset) |  |
| `batch_size` | `number` | ✗ | Training batch size |  |
| `max_seq_len` | `number` | ✗ | Max sequence length |  |
| `learning_rate` | `number` | ✓ | Learning rate |  |
| `gradient_accumulation_steps` | `number` | ✓ | Gradient accumulation steps |  |
| `number_of_epochs` | `number` | ✓ | Number of epochs |  |
| `patience` | `number` | ✓ | Early stopping patience |  |

### 示例代码

#### 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 Property Finetune",
    "tool_name": "protein_property_finetune_protein_property_finetune_post",
    "parameters": {
    "protein_language_model": "<PROTEIN_LANGUAGE_MODEL>",
    "dataset_selection": "<DATASET_SELECTION>",
    "dataset_source": "<DATASET_SOURCE>",
    "dataset_type": "Basic",
    "problem_type": "<PROBLEM_TYPE>",
    "metrics": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "monitor": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "monitor_strategy": "<MONITOR_STRATEGY>",
    "normalize": "<NORMALIZE>",
    "training_method": "<TRAINING_METHOD>",
    "pooling_method": "mean",
    "lora_target_modules": "<LORA_TARGET_MODULES>",
    "structure_seq": [
        "OPTION VALUE1",
        "OPTION VALUE2"
    ],
    "training_model_name": "<TRAINING_MODEL_NAME>",
    "dataset_file": "<DATASET_FILE_FILE_ID>",
    "number_of_labels": "<NUMBER_OF_LABELS>",
    "batch_size": 16,
    "max_seq_len": 1024,
    "learning_rate": "",
    "gradient_accumulation_steps": "",
    "number_of_epochs": "",
    "patience": ""
},
    # 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-Property-Finetune>
