chem-nmr-analysis
Scripts for Wasserstein deconvolution of 1H NMR mixture spectra against reference spectra, reaction product prediction, time-series kinetics, and spectral plotting.
learningmatter-mit · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add learningmatter-mit/AtomisticSkills --skill chem-nmr-analysis技能说明
name: chem-nmr-analysis description: Scripts for Wasserstein deconvolution of 1H NMR mixture spectra against reference spectra, reaction product prediction, time-series kinetics, and spectral plotting. category: chemistry
NMR Mixture Analysis
When to Use This Skill
The agent should use this skill's scripts when:
- A workflow (e.g.,
reaction-to-nmr-quantification.mdornmr-reaction-kinetics.md) calls for deconvolution, product prediction, kinetics analysis, or spectral plotting. - The user already has reference spectra and a mixture spectrum and wants to quantify component proportions directly.
- The user has multiple time-point spectra and wants to track reaction progress via NMR.
For end-to-end workflows that chain this skill with other skills, see: .agents/workflows/reaction-to-nmr-quantification.md and .agents/workflows/nmr-reaction-kinetics.md.
When NOT to Use This Skill
- 13C NMR, 2D NMR (COSY, HSQC, etc.), or solid-state NMR -- this skill handles 1H solution-state NMR only.
- Structure elucidation of unknown compounds -- this skill requires knowing (or predicting) what compounds are in the mixture. It does not identify unknowns from scratch.
- Pure compound characterization -- if the user has a single pure compound and just wants to assign peaks, this skill is not appropriate. The agent should interpret the spectrum directly.
- Mass spectrometry data -- despite the Wasserstein algorithm's origins in mass spec, this skill operates on NMR chemical shift axes only.
- Digitizing spectrum images -- the agent should use the
general-plot-digitizerskill for that step. - Predicting NMR spectra from SMILES -- the agent should use the
chem-nmr-predictskill for that step. - Resolving compound names to SMILES -- the agent should use the
drug-db-pubchemskill for that step.
Scripts Reference
| Script | Purpose | Key Inputs | Key Outputs |
|---|---|---|---|
predict_products.py | Predict reaction products via ReactionT5 (HuggingFace API) | --reactant_smiles, --reagent_smiles | JSON with predicted product SMILES |
deconvolve.py | Wasserstein deconvolution of mixture against references | mixture file + reference files + --protons | proportions, Wasserstein distance, plot |
kinetics.py | Time-series deconvolution across multiple time points | --refs, --timepoints, --times | kinetics.csv + kinetics_plot.png |
plot.py | Overlay or stack NMR spectra for visual comparison | spectrum files + --labels | plot image |
spectra.py | I/O utilities (imported by other scripts, not called directly) | -- | -- |
predict_products.py
The agent should use this script to predict reaction products from reactant and reagent SMILES via the ReactionT5 model.
# Env: nmr-agent
export HF_TOKEN=<token>
python .agents/skills/chem-nmr-analysis/scripts/predict_products.py \
--reactant_smiles "C1CCC(=O)C1" \
--reagent_smiles "[BH3-]" \
--output <research_dir>/predicted_products.json
deconvolve.py
The agent should use this script to determine mole fractions of known components in a mixture spectrum via Wasserstein-distance deconvolution.
# Env: nmr-agent
python .agents/skills/chem-nmr-analysis/scripts/deconvolve.py \
mixture.csv ref_borneol.xy ref_isoborneol.xy \
--protons 18 18 \
--names "borneol" "isoborneol" \
--baseline-correct \
--plot <research_dir>/deconvolution_result.png \
--json
kinetics.py
The agent should use this script when the user has crude NMR spectra recorded at multiple time points during a reaction.
# Env: nmr-agent
python .agents/skills/chem-nmr-analysis/scripts/kinetics.py \
--refs ref1.xy ref2.xy \
--timepoints t0.csv t10.csv t20.csv \
--times 0 10 20 \
--time_unit min \
--protons 18 18 \
--names "reactant" "product" \
--baseline_correct \
--output_dir <research_dir>/kinetics/
plot.py
The agent should use this script to overlay or stack spectra for visual inspection before or after deconvolution.
# Env: nmr-agent
python .agents/skills/chem-nmr-analysis/scripts/plot.py \
mixture.csv ref_borneol.xy ref_isoborneol.xy \
--labels "Mixture" "borneol" "isoborneol" \
--title "Mixture vs References" \
--output <research_dir>/spectra_overview.png
Key Arguments for deconvolve.py
| Argument | Required | Description |
|---|---|---|
--protons | Yes | Number of 1H protons per molecule for each reference component. Critical for converting area fractions to mole fractions. The agent must look this up from the molecular formula or count from the SMILES. |
--names | No | Human-readable labels matching the order of reference files. The agent should always provide these for interpretable output. |
--baseline-correct | No | Shifts each spectrum so minimum intensity = 0. The agent should use this for digitized spectra or SPINUS-predicted spectra. |
--kappa | No | Denoising penalty (default 0.25). The agent should not change this unless instructed. |
--plot | No | Output plot path. The agent should always generate a plot. |
--json | No | Emit machine-readable JSON output. The agent should always use this. |
Interpreting Results
The deconvolution output contains proportions and a Wasserstein distance (WD) indicating fit quality.
If/Then rules for Wasserstein distance:
- If WD < 0.05 -- good fit. The agent should report proportions with confidence.
- If 0.05 < WD < 0.15 -- acceptable fit. The agent should report proportions but note the fit quality and suggest possible causes (minor missing components, baseline noise).
- If WD > 0.15 -- poor fit. The agent should:
- Check if a component is missing (compare overlay plot for unmatched peaks).
- Check if there is a ppm calibration offset between mixture and references.
- Ask the user if there are additional species in the mixture not accounted for.
- Not report proportions as reliable.
**
阅读完整来源 ↗