dsadd4's picture
Upload folder using huggingface_hub
a03fc9f verified
|
Raw History Blame Contribute Delete
5.72 kB
# UltraMS MSnLib formula-level split (split A)
Version **1.0.0** · 2026-11-04 · license **CC BY 4.0**
The frozen, **formula-disjoint** 80/10/10 train / validation / test split of the complete
MSnLib tandem mass spectral library (560,084 spectra, all adducts). This directory is also
shipped as `split_A_full_msnlib/` inside `ultrams_msnlib_benchmark_v1/`.
| | train | validation | test | total |
| --- | ---: | ---: | ---: | ---: |
| molecular formulas | 16,885 | 2,110 | 2,112 | 21,107 |
| spectra | 446,667 | 55,980 | 57,437 | 560,084 |
Every spectrum of a molecular formula lies in exactly one fold; no formula occurs in two
folds. The frozen assignment is the `fold` column of `MSnLib.csv` and the split is replayed
exactly by [`build_split_a.py`](build_split_a.py).
## Files
| file | rows | content |
| --- | ---: | --- |
| `formula_split.csv(.gz)` | 21,107 | `formula, fold, n_spectra` — one row per molecular formula |
| `row_formula_fold.csv(.gz)` | 560,084 | `row_index, formula, fold` — authoritative row → formula → fold map for all spectra |
| `test_spectra.csv(.gz)` | 57,437 | `row_index, smiles, precursor_mz, adduct, collision_energy, fold, canonical_isomeric_smiles` |
| `val_spectra.csv(.gz)` | 55,980 | same schema for the validation fold |
| `msnlib_rt.csv.gz` | 560,084 | `row_index, rt` — compact per-spectrum retention time (seconds); gzipped only |
| `test_molecules_voting.csv(.gz)` | 5,002 | **official** multiple-spectrum voting units (Figure 3d / 3a voting): the test spectra grouped by the MSnLib source SMILES string, group size ≥ 2 (57,436 spectra); reproduces the published voting task's `n_molecules = 5002` grouping member-for-member |
| `test_molecules_voting_canonical_view.csv(.gz)` | 4,888 | alternative canonical view (not the official unit): the same test spectra grouped by RDKit canonical isomeric SMILES, group size ≥ 2 (57,436 spectra) |
| `REPORT.json` | | machine-readable report: counts, expected values, hashes, cross-checks, anomaly record |
| `VERIFY.md` | | full verification record (inputs, counts, cross-checks, replay transcript) |
| `build_split_a.py` | | replay from `MSnLib.csv` and SHA-256 check against the frozen tables |
`row_index` is the 0-based data row of `MSnLib.csv` (560,084 rows, 752,707,651 bytes,
SHA-256 `be54b33039cf18675751ea3c6354b592177c899a0cd5df303ae616330133ec07`; physical
line = data row + 2). Every `.csv` has a `.csv.gz` twin that decompresses to the identical
bytes.
## Official voting units (Figure 3d / Figure 3a voting)
The official multiple-spectrum voting unit is the **MSnLib source SMILES string**. The
57,437 test spectra contain 5,003 distinct source strings; one of them occurs in only one
spectrum, so `test_molecules_voting.csv` has **5,002 groups covering 57,436 spectra**. This
is the grouping of the published multiple-spectrum voting task and it is verified
member-for-member against the repository voting table (`n_molecules = 5002`).
For a chemically deduplicated view, `test_molecules_voting_canonical_view.csv` groups the
same spectra by RDKit canonical isomeric SMILES: 4,889 distinct molecules, of which
**4,888 groups cover the same 57,436 spectra**. 114 source-string groups merge into
chemically identical molecules, and the single excluded molecule is
`CC(C)(C)OC(=O)NCC1(CC(=O)O)CCCCC1`. The canonical view is an alternative, **not** the
official voting unit. See `VERIFY.md` §7.
## Retention times (RT)
`msnlib_rt.csv.gz` is a compact companion table (1.4 MB gzipped, no 756 MB full CSV):
`row_index` is the 0-based `MSnLib.csv` data row (0 … 560,083) and `rt` is the retention time
in seconds, kept in the source text representation. It was exported from
`MSnLib_with_rt.csv` (755,984,910 bytes, SHA-256
`a5b7c38228287c5c1de401050445319b331ee9a5f17993d6e104e9a734fe2964`, columns
`mzs,intensities,smiles,precursor_mz,adduct,collision_energy,fold,rt`) after verifying
row-by-row that its first seven columns are identical to `MSnLib.csv` in the same order
(560,084/560,084 rows, 0 mismatches). RT is source metadata from the MSnLib records
(CC BY 4.0; see `NOTICE.md` / the parent package `NOTICE.md`).
```python
import gzip
import pandas as pd
test = pd.read_csv("test_spectra.csv")
rt = pd.read_csv("msnlib_rt.csv.gz") # row_index, rt
test_rt = test.merge(rt, on="row_index", how="left")
assert test_rt["rt"].notna().all()
```
The table is needed by the label-blind grouping / multiple-spectrum voting analyses
(Figure 3d), which use RT as spectrum metadata.
## Quick start
```python
import pandas as pd
formulas = pd.read_csv("formula_split.csv")
test = pd.read_csv("test_spectra.csv")
rows = pd.read_csv("row_formula_fold.csv") # 560,084 rows
# formula-level disjointness: one fold per formula
assert formulas.groupby("formula")["fold"].nunique().max() == 1
assert formulas["n_spectra"].sum() == 560_084
```
## Rebuild and verify
```bash
# read-only replay + hash check (needs MSnLib.csv and RDKit 2026.03.5):
python3 build_split_a.py --csv /path/to/datasets/MSnLib/MSnLib.csv
# write the tables (byte-identical with the frozen copies under RDKit 2026.03.5):
python3 build_split_a.py --csv /path/to/MSnLib.csv --output-dir replay_split_a
```
The split is **formula-disjoint, not molecule-disjoint**: different molecules can share a
formula and therefore a fold. The molecule-disjoint benchmark is split B
(strict-adduct 70/15/15) of `ultrams_msnlib_benchmark_v1/`; the two splits must never be
combined into a single global-disjointness claim. See `figures_mapping.md` in the parent
package for which manuscript panels use which split, and `NOTICE.md` for the MSnLib
attribution (Brungs et al., Zenodo 10.5281/zenodo.11163380, CC BY 4.0).