NMRGym / README.md
meaw0415's picture
revise
94115ef verified
---
license: mit
task_categories:
- tabular-regression
- tabular-classification
pretty_name: NMRGym
language:
- en
tags:
- chemistry
- nmr
- spectroscopy
- molecular-property-prediction
- drug-discovery
- cheminformatics
size_categories:
- 100K<n<1M
---
# NMRGym
Benchmark on NMR Spectrum.
!!! **Important:** !!!
If you need access to the dataset, please email [zhengf723@connect.hkust-gz.edu.cn](mailto:zhengf723@connect.hkust-gz.edu.cn)
## Data Sources (Before Cleaning)
| Source | Records | Unique SMILES | Total Spectrums | ¹H NMR | ¹³C NMR |
| :------------------ | ----------: | ------------: | --------------: | ----------: | ----------: |
| **CH-NP** | 12,165 | 12,165 | 24,326 | 12,161 | 12,165 |
| **HMDB** | 1,791 | 896 | 3,278 | 1,566 | 1,712 |
| **NMRBank** | 148,914 | 142,964 | 297,043 | 148,437 | 148,606 |
| **NMRShiftDB 2024** | 41,019 | 39,631 | 50,416 | 18,570 | 31,846 |
| **NP-MRD** | 489,569 | 243,598 | 950,242 | 462,233 | 488,009 |
| **PubChem-NMR** | 1,647 | 1,535 | 2,605 | 1,556 | 1,049 |
| **SDBS** | 12,926 | 12,626 | 22,711 | 11,522 | 11,189 |
| **Total** | **708,031** | **430,690** | **1,350,621** | **656,045** | **694,576** |
---
## Balanced Dataset Statistics (After Cleaning & Processing)
After data cleaning, filtering, quality control, and balanced scaffold splitting, the final NMRGym dataset consists of three splits:
| Split | Records | Unique SMILES | ¹H NMR | ¹³C NMR |
| :------- | ----------: | ------------: | ----------: | ----------: |
| **Train** | 402,676 | 250,822 | 402,676 | 402,676 |
| **Val** | 53,672 | 50,716 | 53,672 | 53,672 |
| **Test** | 80,069 | 74,568 | 80,069 | 80,069 |
| **Total** | **536,417** | **376,106** | **536,417** | **536,417** |
### Dataset Visualizations
<!-- ![Dataset Overview](dataset_overview.png)
*Figure 1: Overview of dataset statistics including total records, unique SMILES, data duplication, NMR spectra types, and top elements.*
![Functional Groups Distribution](functional_groups.png)
*Figure 2: Distribution of 22 functional groups across train, validation, and test sets.*
![Element Distribution](element_distribution.png)
*Figure 3: Distribution of common elements (C, H, O, N, F, Cl, Br, S, P, I) across datasets.* -->
---
### Quick Checklist
* [✅] Data cleaning: Heavy atom filtering and illegal smiles exclusion.
* [✅] Data Summary and Visualization.
* [✅] Data Split.
* [] 3D coord. generation. Rdkit.
* [✅] Toxic Property label generation.
* [✅] Function Group label generation.
---
## NMRGym Split Dataset Format (`nmrgym_spec_filtered_both_{train,test}.pkl`)
This dataset contains post-QC, scaffold-split molecular entries with paired NMR spectra, structure fingerprints, functional group annotations, and toxicity labels.
Each `.pkl` file is a Python list of dictionaries. Each dictionary corresponds to a single unique molecule.
### Example record structure
```python
{
"smiles": "CC(=O)Oc1ccccc1C(=O)O",
"h_shift": [7.25, 7.32, 2.14, 1.27],
"c_shift": [128.5, 130.1, 172.9, 20.7],
"fingerprint": np.ndarray(shape=(2048,), dtype=np.uint8),
"fg_onehot": np.ndarray(shape=(22,), dtype=np.uint8),
"toxicity": np.ndarray(shape=(7,), dtype=np.int8),
}
```
---
### Field definitions
**`smiles`** (`str`)
Canonical SMILES string for this molecule.
**`h_shift`** (`list[float]`)
Experimental or curated ¹H NMR peak positions in ppm.
**`c_shift`** (`list[float]`)
Experimental or curated ¹³C NMR peak positions in ppm.
**`fingerprint`** (`np.ndarray(2048,)`, `uint8`)
RDKit Morgan fingerprint (radius = 2, 2048 bits). Encodes local circular substructures.
**`fg_onehot`** (`np.ndarray(22,)`, `uint8`)
Binary functional-group vector. `1` means the SMARTS pattern is present in the molecule.
Index mapping (0→21):
1. Alcohol
2. Carboxylic Acid
3. Ester
4. Ether
5. Aldehyde
6. Ketone
7. Alkene
8. Alkyne
9. Benzene
10. Primary Amine
11. Secondary Amine
12. Tertiary Amine
13. Amide
14. Cyano
15. Fluorine
16. Chlorine
17. Bromine
18. Iodine
19. Sulfonamide
20. Sulfone
21. Sulfide
22. Phosphoric Acid
**`toxicity`** (`np.ndarray(7,)`, `int8`)
Seven binary toxicity endpoints (1 = toxic / positive, 0 = negative):
0. AMES (mutagenicity)
1. DILI (Drug-Induced Liver Injury)
2. Carcinogens_Lagunin (carcinogenicity)
3. hERG (cardiotoxic channel block)
4. ClinTox (clinical toxicity)
5. NR-ER (endocrine / estrogen receptor)
6. SR-ARE (oxidative stress response)
---
### Train / Test meaning
* `nmrgym_spec_filtered_both_train.pkl`: scaffold-based training set.
* `nmrgym_spec_filtered_both_test.pkl`: scaffold-disjoint test set.
Scaffold split is computed using Bemis–Murcko scaffolds. This means test scaffolds do not appear in train, simulating generalization to new chemotypes instead of just new stereoisomers.
---
### Minimal usage example
```python
import pickle
from rdkit import Chem
from rdkit.Chem import AllChem
# load the dataset
test_path = "/gemini/user/private/NMRGym/utils/split_output/nmrgym_spec_filtered_both_test.pkl"
with open(test_path, "rb") as f:
dataset = pickle.load(f)
print("num molecules:", len(dataset))
print("keys:", dataset[0].keys())
print("example toxicity vector:", dataset[0]["toxicity"])
# build 3D conformer for the first molecule
smi = dataset[0]["smiles"]
mol = Chem.MolFromSmiles(smi)
mol = Chem.AddHs(mol) # add hydrogens for 3D
AllChem.EmbedMolecule(mol, AllChem.ETKDG())
AllChem.UFFOptimizeMolecule(mol)
# extract 3D coordinates (in Å)
conf = mol.GetConformer()
coords = []
for atom_idx in range(mol.GetNumAtoms()):
pos = conf.GetAtomPosition(atom_idx)
coords.append([pos.x, pos.y, pos.z])
print("3D coords for first molecule (Angstrom):")
for i, (x,y,z) in enumerate(coords):
sym = mol.GetAtomWithIdx(i).GetSymbol()
print(f"{i:2d} {sym:2s} {x:8.3f} {y:8.3f} {z:8.3f}")
```
### Notes on 3D coordinates
* We generate a single low-energy conformer using RDKit ETKDG embedding + UFF optimization.
* Coordinates are in Ångström.
* These coordinates are not guaranteed to match the experimental NMR conformer in solvent; they are intended for featurization (message passing models, geometry-aware models, etc.), not quantum-accurate geometry.
---
## Downstream Benchmark Tasks
This benchmark suite evaluates AI models on multiple spectroscopy-related prediction tasks. Each task reflects a distinct molecular reasoning aspect — from direct spectrum regression to property and toxicity prediction.
### 1. Spectral Prediction
| **Method / Paper Title** | **Model Type / Approach** | **Metric(s)** | **Model Size** | **Notes** |
| ------------------------ | ------------------------- | ------------- | -------------- | --------- |
| x | x |x | x | x |
### 2. Structure Prediction (Inverse NMR)
| **Method / Paper Title** | **Model Type / Approach** | **Metric(s)** | **Model Size** | **Notes** |
| ------------------------ | ------------------------- | ------------- | -------------- | --------- |
| x | x |x | x | x |
### 3. Molecular Fingerprint Prediction (Spec2FP)
| **Method / Paper Title** | **Model Type / Approach** | **Metric(s)** | **Model Size** | **Notes** |
| ------------------------ | ------------------------- | ------------- | -------------- | --------- |
| x | x |x | x | x |
### 4. Functional Group Classification (Spec2Func)
| **Method / Paper Title** | **Model Type / Approach** | **Metric(s)** | **Model Size** | **Notes** |
| ------------------------ | ------------------------- | ------------- | -------------- | --------- |
| x | x |x | x | x |
### 5. Molecular Toxicity Prediction (Spec2Tox / ADMET)
| **Method / Paper Title** | **Model Type / Approach** | **Metric(s)** | **Model Size** | **Notes** |
| ------------------------ | ------------------------- | ------------- | -------------- | --------- |
| x | x |x | x | x |
---