# PreMOTA

A tool for drug off-target affinity prediction and model training, assisting in the assessment of potential side effect risks.

## 基础信息

| 项目 | 值 |
|------|-----|
| 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. Classfication Model Pretraining

**Tool Name:** `classfication_model_pretraining_classfication_model_pretraining_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `modulator_emb_dim` | `select` | ✓ | embedding size | `128`, `256`, `512`, `768`, `1024` |
| `ppi_emb_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024` |
| `h_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024`, `2048` |
| `n_heads` | `select` | ✓ | embedding size | `2`, `4`, `8`, `16` |
| `embedding_type` | `select` | ✓ |  | `onehot`, `tape`, `esm1b`, `esm2`, `bio2vec` |
| `emb_size` | `select` | ✓ | embedding size | `20`, `768`, `1280` |
| `protein_sequence_file` | `file` | ✓ | file suffix: `json` |  |
| `uniprot_smiles_file` | `file` | ✓ | file suffix: `csv` |  |
| `train_batch_size` | `number` | ✓ |  |  |
| `valid_batch_size` | `number` | ✓ |  |  |
| `learning_rate` | `number` | ✓ |  |  |
| `num_epochs` | `number` | ✓ |  |  |
| `dropout_global` | `number` | ✓ |  |  |
| `train_val_ratio` | `number` | ✓ |  |  |
| `early_stop` | `number` | ✓ |  |  |
| `best_auc` | `number` | ✓ |  |  |

### 示例代码

#### 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": "PreMOTA",
    "tool_name": "classfication_model_pretraining_classfication_model_pretraining_post",
    "parameters": {
    "modulator_emb_dim": "256",
    "ppi_emb_dim": "512",
    "h_dim": "512",
    "n_heads": "2",
    "embedding_type": "<EMBEDDING_TYPE>",
    "emb_size": "<EMB_SIZE>",
    "protein_sequence_file": "<PROTEIN_SEQUENCE_FILE_FILE_ID>",
    "uniprot_smiles_file": "<UNIPROT_SMILES_FILE_FILE_ID>",
    "train_batch_size": 32,
    "valid_batch_size": 16,
    "learning_rate": 0.0001,
    "num_epochs": 1,
    "dropout_global": 0.2,
    "train_val_ratio": 0.9,
    "early_stop": 10,
    "best_auc": 0.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.")
```


---

## 2. Affinity Model Finetuning

**Tool Name:** `affinity_model_finetuning_affinity_model_finetuning_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `modulator_emb_dim` | `select` | ✓ | embedding size | `128`, `256`, `512`, `768`, `1024` |
| `ppi_emb_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024` |
| `h_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024`, `2048` |
| `n_heads` | `select` | ✓ | embedding size | `2`, `4`, `8`, `16` |
| `embedding_type` | `select` | ✓ |  | `onehot`, `tape`, `esm1b`, `esm2`, `bio2vec` |
| `emb_size` | `select` | ✓ | embedding size | `20`, `768`, `1280` |
| `pretrained_model` | `file` | ✓ | file suffix: `pt` |  |
| `train_dataset` | `file` | ✓ | file suffix: `csv` |  |
| `protein_sequence_file` | `file` | ✓ | file suffix: `json` |  |
| `train_batch_size` | `number` | ✓ |  |  |
| `valid_batch_size` | `number` | ✓ |  |  |
| `learning_rate` | `number` | ✓ |  |  |
| `num_epochs` | `number` | ✓ |  |  |
| `dropout_global` | `number` | ✓ |  |  |
| `train_val_ratio` | `number` | ✓ |  |  |
| `early_stop` | `number` | ✓ |  |  |
| `best_auc` | `number` | ✓ |  |  |

### 示例代码

#### 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": "PreMOTA",
    "tool_name": "affinity_model_finetuning_affinity_model_finetuning_post",
    "parameters": {
    "modulator_emb_dim": "256",
    "ppi_emb_dim": "512",
    "h_dim": "512",
    "n_heads": "2",
    "embedding_type": "<EMBEDDING_TYPE>",
    "emb_size": "<EMB_SIZE>",
    "pretrained_model": "<PRETRAINED_MODEL_FILE_ID>",
    "train_dataset": "<TRAIN_DATASET_FILE_ID>",
    "protein_sequence_file": "<PROTEIN_SEQUENCE_FILE_FILE_ID>",
    "train_batch_size": 32,
    "valid_batch_size": 16,
    "learning_rate": 0.0001,
    "num_epochs": 1,
    "dropout_global": 0.2,
    "train_val_ratio": 0.9,
    "early_stop": 10,
    "best_auc": 0.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.")
```


---

## 3. Affinity Model Training

**Tool Name:** `affinity_model_training_affinity_model_training_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `modulator_emb_dim` | `select` | ✓ | embedding size | `128`, `256`, `512`, `768`, `1024` |
| `ppi_emb_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024` |
| `h_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024`, `2048` |
| `n_heads` | `select` | ✓ | embedding size | `2`, `4`, `8`, `16` |
| `embedding_type` | `select` | ✓ |  | `onehot`, `tape`, `esm1b`, `esm2`, `bio2vec` |
| `emb_size` | `select` | ✓ | embedding size | `20`, `768`, `1280` |
| `train_dataset` | `file` | ✓ | file suffix: `csv` |  |
| `protein_sequence_file` | `file` | ✓ | file suffix: `json` |  |
| `train_batch_size` | `number` | ✓ |  |  |
| `valid_batch_size` | `number` | ✓ |  |  |
| `learning_rate` | `number` | ✓ |  |  |
| `num_epochs` | `number` | ✓ |  |  |
| `dropout_global` | `number` | ✓ |  |  |
| `train_val_ratio` | `number` | ✓ |  |  |
| `early_stop` | `number` | ✓ |  |  |
| `best_auc` | `number` | ✓ |  |  |

### 示例代码

#### 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": "PreMOTA",
    "tool_name": "affinity_model_training_affinity_model_training_post",
    "parameters": {
    "modulator_emb_dim": "256",
    "ppi_emb_dim": "512",
    "h_dim": "512",
    "n_heads": "2",
    "embedding_type": "<EMBEDDING_TYPE>",
    "emb_size": "<EMB_SIZE>",
    "train_dataset": "<TRAIN_DATASET_FILE_ID>",
    "protein_sequence_file": "<PROTEIN_SEQUENCE_FILE_FILE_ID>",
    "train_batch_size": 32,
    "valid_batch_size": 16,
    "learning_rate": 0.0001,
    "num_epochs": 1,
    "dropout_global": 0.2,
    "train_val_ratio": 0.9,
    "early_stop": 10,
    "best_auc": 0.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.")
```


---

## 4. Predict Offtarget Affinity Drugs

**Tool Name:** `predict_offtarget_affinity_drugs_predict_offtarget_affinity_drugs_post`

**Method:** `POST`

### 参数

| 参数名 | 类型 | 必需 | 说明 | 枚举值 |
|--------|------|------|------|--------|
| `emb_size` | `select` | ✓ | embedding size | `20`, `768`, `1280` |
| `modulator_emb_dim` | `select` | ✓ | embedding size | `128`, `256`, `512`, `768`, `1024` |
| `ppi_emb_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024` |
| `h_dim` | `select` | ✓ | embedding size | `256`, `512`, `768`, `1024`, `2048` |
| `n_heads` | `select` | ✓ | embedding size | `2`, `4`, `8`, `16` |
| `embedding_type` | `select` | ✓ |  | `onehot`, `tape`, `esm1b`, `esm2`, `bio2vec` |
| `pretrained_model` | `file` | ✓ | file suffix: `pt` |  |
| `protein_sequence_file` | `file` | ✓ | file suffix: `json` |  |
| `predict_dataset_file` | `file` | ✓ | file suffix: `csv` |  |

### 示例代码

#### 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": "PreMOTA",
    "tool_name": "predict_offtarget_affinity_drugs_predict_offtarget_affinity_drugs_post",
    "parameters": {
    "emb_size": "<EMB_SIZE>",
    "modulator_emb_dim": "256",
    "ppi_emb_dim": "512",
    "h_dim": "512",
    "n_heads": "2",
    "embedding_type": "<EMBEDDING_TYPE>",
    "pretrained_model": "<PRETRAINED_MODEL_FILE_ID>",
    "protein_sequence_file": "<PROTEIN_SEQUENCE_FILE_FILE_ID>",
    "predict_dataset_file": "<PREDICT_DATASET_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/PreMOTA>
