agentsclimarketplace

Cnn inference on spectral data

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/cnn-inference-on-spectral-data

Use when you have preprocessed MS/MS spectral data (normalized peak intensities and m/z values) in memory or on disk, a trained CNN model checkpoint available, and you need to generate molecular embedding vectors for matching against a reference database of known metabolites.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill cnn-inference-on-spectral-data

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

7.8 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

CNN Inference on Spectral Data

License: restricted — no clear open-source license detected for the underlying tool; verify licensing before commercial use or redistribution. <!-- asb-license-banner -->

Summary

Load preprocessed MS/MS spectra and pass them through a trained Convolutional Neural Network to extract multidimensional molecular embedding vectors for each spectrum. This is a core inference step in metabolite identification pipelines that converts raw mass spectrometry measurements into structured feature representations for downstream candidate matching.

When to use

You have preprocessed MS/MS spectral data (normalized peak intensities and m/z values) in memory or on disk, a trained CNN model checkpoint available, and you need to generate molecular embedding vectors for matching against a reference database of known metabolites. This step is required after data preprocessing and model training but before candidate matching and ranking.

When NOT to use

  • Input spectra are not yet preprocessed (still contain raw, unnormalized peak intensities or missing m/z calibration) — preprocess first using data_processing.py
  • You do not have a trained CNN model available — train the model on labeled spectra data before attempting inference
  • Your goal is to interpret or validate the learned features directly; CNN embeddings are designed for similarity matching, not human interpretability

Inputs

  • Preprocessed MS/MS spectral data (normalized peak intensities and m/z values)
  • Trained CNN model checkpoint file (.pt or equivalent)
  • MSP format spectra file (with or without SMILES annotations)
  • Configuration file (config.yaml) specifying model_path, input file paths, and parameters

Outputs

  • Multidimensional molecular embedding vectors (one vector per spectrum)
  • Embedding feature matrix (CSV or NumPy format)
  • Aggregated embeddings ready for candidate matching

How to apply

Initialize the trained CNN model from disk (e.g., via torch.load or the ChemEmbed cnn_train.up_cnn_model module). Create a data loader using the appropriate inference dataset class (inference_dataset_loader.py for MSP files with SMILES, or spectra_inference_dataset_loader.py for MSP files without SMILES) that batches normalized spectra. Iterate over batches, feeding each spectrum through the CNN in inference mode (model.eval()) to extract embedding vectors. Aggregate the embeddings into a feature matrix with one row per spectrum and embedding dimensions as columns. Save the resulting embeddings matrix to disk in CSV or NumPy format for subsequent cosine similarity matching against the reference database.

Related tools

Examples

python main.py --config config.yaml

Evaluation signals

  • Embeddings matrix has shape (number_of_spectra, embedding_dimension) with no NaN or infinite values
  • All embedding vectors are non-zero and have consistent magnitude (e.g., L2 norm ≈ 1.0 if normalized)
  • Cosine similarity scores between embeddings and reference database candidates fall within expected range [−1, 1], with top matches showing similarity > 0.5 for true positives
  • Output file successfully saved and is readable; row count matches input spectrum count
  • Inference runs without errors in model.eval() mode (gradients disabled, batch normalization frozen)

Limitations

  • CNN embeddings are specific to the training data distribution; performance degrades on spectra from different ionization modes, instruments, or chemical families not well-represented in training
  • The method requires a pre-trained model; inference on out-of-distribution data without retraining will produce unreliable embeddings
  • MSP files must have consistent formatting (consistent field names, num_peaks count, and peak data structure) or the data loader will fail or silently skip malformed entries
  • No changelog or versioning documented; updates to the model or data loader code may break compatibility with embeddings generated by older model checkpoints

Evidence

  • [other] Load preprocessed MS/MS spectral data (normalized peak intensities and m/z values) into memory. Initialize the trained Convolutional Neural Network (CNN) model from the ChemEmbed repository.: "Load preprocessed MS/MS spectral data (normalized peak intensities and m/z values) into memory. 2. Initialize the trained Convolutional Neural Network (CNN) model from the ChemEmbed repository."
  • [other] Pass each spectrum through the CNN to extract multidimensional molecular embedding vectors. Aggregate embeddings into a feature matrix with one row per spectrum and embedding dimension as columns. Save embeddings to output file in CSV or NumPy format.: "Pass each spectrum through the CNN to extract multidimensional molecular embedding vectors. 4. Aggregate embeddings into a feature matrix with one row per spectrum and embedding dimension as columns."
  • [readme] Model Prediction: Utilizes a pre-trained CNN model to predict molecular embeddings from spectra data.: "Model Prediction: Utilizes a pre-trained CNN model to predict molecular embeddings from spectra data."
  • [readme] Handles MSP files both with and without SMILES annotations, controlled via a configuration parameter.: "Supports for Multiple Input Types: Handles MSP files both with and without SMILES annotations, controlled via a configuration parameter."
  • [readme] Ensure the cnn_train module is present in your project and contains up_cnn_model.py and spectra_inference_dataset_loader.py.: "Ensure the cnn_train module is present in your project and contains up_cnn_model.py and spectra_inference_dataset_loader.py."

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.