Metadata-Version: 2.4
Name: SolvNet
Version: 1.0.19
Summary: Protein solubility prediction toolkit
Author: Thao Nguyen et al.
License: MIT License
        
        Copyright (c) 2025 Thao Nguyen et al.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch==2.7.1
Requires-Dist: torch-geometric==2.6.1
Requires-Dist: transformers==4.41.2
Requires-Dist: numpy==1.26.4
Requires-Dist: pandas==2.3.0
Requires-Dist: tqdm==4.67.1
Requires-Dist: scikit-learn==1.7.0
Dynamic: license-file

# SolvNet

**Protein Solubility Prediction Toolkit**

**SolvNet** is a Python toolkit for predicting protein solubility from amino acid sequences. It provides easy-to-use functions to generate embeddings and predict solubility with confidence estimates.

---

## Installation

### Create environment:
```bash
conda create --name solvnet
conda activate solvnet
```
### Install package
```bash
pip install SolvNet
```

### Step 0: Prepare Data

Prepare your dataset or load a test dataset from pbdsolv.

```python
from SolvNet import load_pdb
df = load_pdb()
```

The dataset should be a pandas DataFrame with the following columns:

| Column  | Description                                           |
|---------|-------------------------------------------------------|
| name    | Protein name                                         |
| aa_seq  | Amino acid sequence                                  |
| label   | Binary solubility label (`0`: insoluble, `1`: soluble) |


### Step 1: Generate ESMC Embeddings

Generate ESMC embeddings for the protein sequences:

```python
from SolvNet import esmc_embeddings
data = esmc_embeddings(df_test)
```

Parameters:

* `df_test`: Dataframe from step 0.

### Step 2: Predict Solubility

Use the generated embeddings to predict protein solubility:

```python
from SolvNet import Predict

labels, preds, confs, probs = Predict(
    data=data,
    model = "pdb", # model in ["pdb", "plm"]
    percentage=0.85,
    batch_size=64
)
```

Parameters:

* `data:` ESMC embeddings.
* `model:` Must be `pdb` or `plm`, which indicates the dataset the model was trained on Default is `pdb`
* `percentage:` The top percentage of most confident predictions to return (default 0.85).
* `batch_size:` Batch size for prediction (default 64).

Returns:

* `labels:` True labels for the top percentage% most confident proteins.
* `preds:` Predicted labels for the top percentage%.
* `confs:` Confidence scores for predictions.
* `probs:` Predicted probabilities.

## Example Workflow for Inference

```python
from SolvNet import *

# Step 0: Load pdb dataset:
df = load_pdb()

# Step 1: Generate embeddings
data = esmc_embeddings(df)

# Step 2: Make predictions
labels, preds, confs, probs = Predict(
    data=data,
    percentage=0.85,
    batch_size=64
)
```

## Training
Step 0: Prepare `df_train`, `df_val`, and `df_test`

```python
from SolvNet import *

top_percent = 0.95
noise_rate = 1-top_percent

TRAIN, VAL, TEST = esmc_embeddings(df_train), esmc_embeddings(df_val), esmc_embeddings(df_test)

(m1,m2), test_metrics = train_dividemix(TRAIN, VAL, TEST, batch_size=64, lr=1e-4, epochs=12, warmup_epochs=5, noise_rate=noise_rate, alpha=0.85) # alpha: hyperparameter for mixup augmentation
```
___
## License
MIT License © 2025 Thao Nguyen et al.
