File size: 7,278 Bytes
0b16d1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
license: cc-by-nc-4.0
library_name: pytorch
pipeline_tag: token-classification
tags:
  - biology
  - protein
  - secondary-structure
  - conformer
  - esm2
  - netsurfp
  - plddt
  - alphafold2
  - disorder
  - solvent-accessibility
---

# `StructEstimator`: Standalone Multi-Layer Frozen ESM2-650M + RoPE-Conformer Predictor

**`StructEstimator_esm2_650m.pth`** (`1.36 GiB`) is a **100% self-contained standalone checkpoint** bundling frozen **`ESM2-650M`** (`facebook/esm2_t33_650M_UR50D`, FP16 weights + config + 33-token vocabulary) together with a multi-layer **Multi-Scale `RoPE-Conformer` + Coupled Dual-Stream Decoder** (`39.03M` parameters) tapping frozen layers **`[18, 24, 30, 33]`**.

Given any FASTA file, it predicts **all 7 classical NetSurfP-3.0 structural features plus AlphaFold2 per-residue `pLDDT`** (50-bin HL-Gauss head) in a single alignment-free pass on GPU (~1.6–2.2 GB VRAM), Apple Silicon (`MPS`), or CPU (~3.0 GB RAM) — with **zero external ESM-2 downloads or MSA searches required**.

---

## Benchmark Performance

Trained on `10,337` PISCES `<25%` non-redundant crystal chains (`Train_HHblits.npz`) + `~67,800` `MMseqs2` **`35%` sequence-identity** clustered **AlphaFoldDB Swiss-Prot v6** structures (`78,109` unique training chains total, with selective `CB513 / TS115 / CASP12` secondary-structure decontamination).

### 1. Crystal Structure Benchmarks vs. NetSurfP-2.0, NetSurfP-3.0 & `netsurfp3-esm2`

| Benchmark | Model | `Q3` (↑) | `Q8` (↑) | `RSA` $r$ (↑) | `Disorder` MCC (↑) | `Phi` MAE (↓) | `Psi` MAE (↓) |
| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
| **`CB513`** | NetSurfP-2.0 *(HHblits MSA)* | 84.5% | 71.3% | 0.791 | – | 20.35° | 29.04° |
| | Official NetSurfP-3.0 *(ESM-1b)* | 84.6% | 71.1% | 0.793 | – | 20.22° | 29.25° |
| | `netsurfp3-esm2` *(CNNbLSTM)* | 88.25% | 77.14% | 0.8228 | – | 18.2° | 24.4° |
| | **`StructEstimator` *(RoPE-Conformer)*** | **88.51%** | **77.85%** | **0.8292** | – | **17.9°** | **23.8°** |
| **`TS115`** | NetSurfP-2.0 *(HHblits MSA)* | 84.9% | 74.0% | 0.771 | 0.624 | 17.40° | 26.80° |
| | Official NetSurfP-3.0 *(ESM-1b)* | 85.6% | 74.9% | 0.776 | 0.662 | 17.16° | 25.80° |
| | `netsurfp3-esm2` *(CNNbLSTM)* | 87.65% | 78.14% | 0.8001 | **0.6743** | 15.6° | 22.2° |
| | **`StructEstimator` *(RoPE-Conformer)*** | **88.20%** | **78.69%** | **0.8090** | 0.6740 | **15.3°** | **21.8°** |
| **`CASP12`** | NetSurfP-2.0 *(HHblits MSA)* | 81.0% | 69.9% | 0.728 | **0.653** | 20.90° | 32.80° |
| | Official NetSurfP-3.0 *(ESM-1b)* | 79.1% | 66.9% | 0.707 | 0.621 | 21.25° | 33.92° |
| | `netsurfp3-esm2` *(CNNbLSTM)* | 83.15% | 72.07% | 0.7421 | 0.6247 | 19.1° | **29.0°** |
| | **`StructEstimator` *(RoPE-Conformer)*** | **83.37%** | **72.17%** | **0.7538** | 0.6491 | **19.0°** | **29.0°** |

### 2. AlphaFold2 v6 `pLDDT` Benchmarks

| Split | Regime | Model | Residue `pLDDT` $r$ (↑) | Protein `mean pLDDT` $r$ (↑) | `pLDDT` MAE (↓) | `>=70` Acc (↑) |
| :--- | :--- | :--- | :---: | :---: | :---: | :---: |
| **`afdb_plddt_test_unseen`** | `<35%` seq-id unseen families | `netsurfp3-esm2` | 0.9294 | 0.9301 | 5.72 | 93.0% |
| | | **`StructEstimator`** | **0.9358** | **0.9392** | **5.12** | **93.4%** |
| **`afdb_plddt_test_homologs`** | Non-rep Swiss-Prot homologs | `netsurfp3-esm2` | 0.9410 | 0.9553 | 5.01 | 94.3% |
| | | **`StructEstimator`** | **0.9475** | **0.9654** | **4.39** | **94.6%** |

---

## Model Architecture

`StructEstimator` freezes **`ESM2-650M`** (`FP16`, no fine-tuning) and trains a compact **`39.03M`-parameter** downstream architecture (`149 MB` FP32 vs. `241 MB` for NetSurfP-3's `CNNbLSTM`):

1. **Multi-Layer Frozen Fusion (`MultiLayerScalarMix` × 3):** Extracts 4 strategic layers **`[18, 24, 30, 33]`** and learns independent per-layer `RMSNorm` + softmax weights for the shared trunk (`54.3%` intermediate layers), local `Q3`/torsion skip (`30.9%`), and global `pLDDT` skip (`50.5%`), concatenated with a `32`-dim AA identity embedding.
2. **Multi-Scale Gated Conv Stem (`k = 3, 7, 15, 31`):** Padding-masked depthwise-separable 1D convolutions capturing turns, α-helices, and β-hairpins.
3. **6-Layer Pre-Norm Macaron `RoPE-Conformer` (`d = 512`, `8` heads, `ffn = 1024`):** Combines `SwiGLU` FFNs, dynamic Rotary Position Embedding (RoPE) FlashAttention/SDPA, and GLU-gated `k = 9` depthwise convolutions.
4. **Dual-Stream Decoder + Global Fold FiLM + Stage-2 Cross-Task Refinement:**
   * **Local Geometry Stream** fuses mid-backbone (Block 3) + final (Block 6) + local layer skip for `Q3`, `Q8`, `Phi`, and `Psi`.
   * **Global Fold Stream** modulates `h_final` with **Attentive Statistics Pooling (mean + std) FiLM** for **50-bin HL-Gauss `pLDDT`**, `RSA`, and `Disorder`.
   * **Stage-2 Refinement** (`d = 256`, masked `k = 5` depthwise conv + `SwiGLU`) couples all 7 tasks via residual logit deltas.

---

## Predicted Per-Residue Outputs

| Column(s) | Output | Description |
| :--- | :--- | :--- |
| `q3`, `p_q3_*` | **3-state Secondary Structure (`SS3`)** | `H` (Helix), `E` (Strand), `C` (Coil) + per-state probabilities |
| `q8`, `p_q8_*` | **8-state Secondary Structure (`SS8`)** | DSSP classes `G, H, I, B, E, S, T, C` + per-state probabilities |
| `plddt` | **AlphaFold2 `pLDDT`** | Predicted per-residue AlphaFold2 confidence score (`[0, 100]`, 50-bin HL-Gauss) |
| `rsa`, `asa` | **Solvent Accessibility** | Relative (`[0, 1]`) & Absolute ($\text{\AA}^2$, Tien et al. maxima) surface accessibility |
| `disorder` | **Intrinsic Disorder** | Probability (`[0, 1]`) of crystallographic missing electron density |
| `phi`, `psi` | **Backbone Dihedrals** | Torsion angles $\phi, \psi \in [-180^\circ, +180^\circ]$ |

---

## Quick Start

### 1. Install `StructEstimator` from GitHub
```bash
pip install git+https://github.com/cpdong/StructEstimator.git
```

### 2. Run CLI Prediction (Auto-Downloads `StructEstimator_esm2_650m.pth` on First Run)
```bash
struct-estimator \
  --fasta sample.fasta \
  --hf-repo cpdong/StructEstimator \
  --out-dir predictions
```

Or run completely offline with a pre-downloaded `StructEstimator_esm2_650m.pth`:
```bash
struct-estimator --fasta sample.fasta --checkpoint /path/to/StructEstimator_esm2_650m.pth --out-dir predictions
```

Or run the **zero-install all-in-one single script** (`predict_standalone.py`, only needs `torch` + `transformers` + `StructEstimator_esm2_650m.pth` — no package install required):
```bash
python3 predict_standalone.py \
  --model StructEstimator_esm2_650m.pth \
  --input sample.fasta \
  --output predictions.csv
```

### 3. Python API
```python
from predict import predict_fasta

results = predict_fasta(
    fasta="sample.fasta",
    hf_repo="cpdong/StructEstimator",
    out_dir="predictions",
)
```

---

## License & Attribution

Released under **CC-BY-NC-4.0** (Academic / Non-Commercial use only).
* Powered by frozen **ESM-2** (`facebook/esm2_t33_650M_UR50D`, Lin et al., *Science* 2023; MIT License).
* `pLDDT` and confident secondary structure supervision derived from **AlphaFold Protein Structure Database v6** (Varadi et al., *Nucleic Acids Research* 2024; CC-BY-4.0).
* Evaluated on standard **NetSurfP-3.0** PDB/DSSP benchmarks (`CB513`, `TS115`, `CASP12`; Høie et al., *NAR* 2022).