agentsclimarketplace

Nmr spectrum reconstruction from library

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/nmr-spectrum-reconstruction-from-library

Use when you have an NMR spectrum of a mixture sample and a library of reference spectra for individual compounds.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill nmr-spectrum-reconstruction-from-library

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.0 KB, ~1.4k tokens by cl100k_base, as published. Nobody here has run it

NMR Spectrum Reconstruction from Library

Summary

Reconstruct an NMR mixture spectrum by solving a minimum-cost flow (MCF) problem that optimally combines single-compound reference spectra from a library, measured by Earth Mover's Distance. This skill identifies constituent compounds and their fractional abundances in a mixture sample.

When to use

You have an NMR spectrum of a mixture sample and a library of reference spectra for individual compounds. Use this skill when you need to determine which compounds are present in the mixture and in what proportions, measured against an Earth Mover's Distance optimality criterion rather than simple peak matching.

When NOT to use

  • Input is a pure single-compound spectrum (no mixture present); use direct spectral matching instead.
  • Library does not contain reference spectra for the compounds present in the mixture; mcfNMR can only reconstruct from available library entries.
  • Mixture spectrum lacks sufficient spectral resolution or signal-to-noise ratio to resolve individual compound peaks from library spectra.

Inputs

  • NMR mixture spectrum (CSV or gzipped CSV with columns: 1H, 13C, optionally weights)
  • Library of single-compound reference spectra (CSV or gzipped CSV with columns: name, 1H, 13C, optionally weights)
  • Configuration file (TOML) specifying assignment_radius, detection_threshold, and other MCF parameters

Outputs

  • List of identified compounds and their fractional abundances
  • Reconstructed approximated mixture spectrum
  • Reconstruction error metric (Earth Mover's Distance or residual norm)
  • Visualization of matched compounds overlaid on target spectrum (optional)

How to apply

Load the NMR mixture spectrum and the library of single-compound reference spectra (both as CSV files with columns for 1H, 13C coordinates and peak weights). Compute pairwise Earth Mover's Distance scores between the mixture spectrum and each library spectrum to establish edge costs in a flow network. Formulate the MCF problem where nodes represent spectral bins, edges represent compound contributions, and arc costs derive from EMD; enforce flow conservation constraints at each bin and supply/demand constraints for source and sink nodes. Solve using a successive shortest-paths or cost-scaling algorithm to identify the minimum-cost flow. Extract compound identities and their fractional abundances from the optimal flow solution, then reconstruct the approximated mixture spectrum by linear combination of selected library spectra weighted by their identified abundances. Validate by computing reconstruction error (EMD or residual norm) and confirming it meets the reported tolerance threshold.

Related tools

Examples

mcfNMR -c config.toml

Evaluation signals

  • Reconstruction error (EMD or residual norm) is below the detection_threshold specified in the configuration file.
  • Identified compounds have assignment scores (derived from MCF flow values) that exceed the detection_threshold, indicating reliable containment.
  • Linear combination of selected library spectra weighted by identified abundances visually matches the target mixture spectrum when plotted.
  • Flow conservation constraints are satisfied at all nodes in the MCF solution, and all arc flows are non-negative.
  • Compound abundances sum to a physically meaningful total (e.g., between 0 and 1 in normalized representation) without negative values.

Limitations

  • mcfNMR can only identify compounds present in the reference library; unknown compounds or library gaps lead to incomplete or incorrect reconstruction.
  • Reconstruction quality depends on the quality and diversity of the reference spectral library; incomplete or poorly curated libraries reduce reliability.
  • Overlapping spectral peaks from different compounds can lead to ambiguous assignments; the MCF algorithm resolves this globally but may not reflect true individual concentrations in highly congested regions.
  • Works with 1D and 2D spectra; 1D spectra require the second coordinate to be set to zero or a fixed identical value across all spectra.
  • Performance and solution quality can be sensitive to the choice of assignment_radius and detection_threshold parameters; incremental_fit mode with multiple radii can improve robustness but increases computational cost.

Evidence

  • [readme] mcfNMR constructs an optimal approximation (in terms of the Earth Mover's Distance) of the mixture spectrum by combining single compound spectra from a library.: "It constructs an optimal approximation (in terms of the Earth Mover's Distance) of the mixture spectrum by combining single compound spectra from a library."
  • [readme] mcfNMR is a tool for recovering constituent compounds from an NMR spectrum of a mixture sample.: "mcfNMR is a tool for recovering constituent compounds from an NMR spectrum of a mixture sample."
  • [readme] Library- and target files must be csv-files, with columns '1H', '13C', and optionally 'weights'. A library file must additionally have a column 'name' to indicate the compound id the corresponding peaks belong to.: "Library- and target files must be csv-files, with columns '1H', '13C', and optionally 'weights'. A library file must additionally have a column 'name' to indicate the compound id the corresponding"
  • [readme] Although developed with the goal of processing 2D spectra, it is possible to analyze 1D spectra. To represent a 1D-spectrum, simply set the second coordinate to zero (or any fixed, identical value).: "Although developed with the goal of processing 2D spectra, it is possible to analyze 1D spectra. To represent a 1D-spectrum, simply set the second coordinate to zero (or any fixed, identical value)."
  • [other] Compute pairwise Earth Mover's Distance scores between the mixture spectrum and each library spectrum to establish edge costs. Formulate the MCF problem: nodes represent spectral bins, edges represent compound contributions, and arc costs are derived from EMD; set flow conservation constraints at each bin and supply/demand constraints for source and sink nodes. Solve the MCF problem using a successive shortest-paths or cost-scaling algorithm.: "Compute pairwise Earth Mover's Distance scores between the mixture spectrum and each library spectrum to establish edge costs. Formulate the MCF problem: nodes represent spectral bins, edges"
  • [other] Validate: compute reconstruction error (EMD or residual norm) and confirm it meets the reported tolerance threshold.: "Validate: compute reconstruction error (EMD or residual norm) and confirm it meets the reported tolerance threshold."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.