mzwiki Mass spectrometry
knowledge commons by UniMZ
Guides & terminologyAll Guides
Guide 33 · Computation

Spectral library search: from query to defensible match

Build a reproducible small-molecule MS/MS search, inspect competing hits, and distinguish exact matches from analog hypotheses.

Choose the question before the search

A spectral library search compares a query spectrum with reference measurements and ranks compatible entries. For small-molecule MS/MS, an exact-compound search asks whether a reference can explain the same compound and ion experiment. An analog search asks whether a related compound offers structural clues. “Exact” names the search objective; it does not promise unique identification. This Guide turns the evidence principles in small-molecule annotation into a reproducible comparison.

Start with a stable spectrum or feature identifier. Record polarity, precursor m/z, charge, proposed adduct, isolation conditions, fragmentation method, and collision energy. A spectral library contains experimental context as well as peaks; MassBank explicitly preserves such metadata. Separate measured references from predicted or propagated annotations. [1]

Filter candidates using the ion actually measured

For a singly charged [M+H]+ ion, subtract approximately 1.007276 Da from its m/z numerical value to estimate neutral monoisotopic mass. For [M+Na]+, subtract approximately 22.989221 Da, using neutral sodium minus an electron. These corrections differ by approximately 21.981945 Da. Neither rule applies unchanged to multiply charged ions or multimers. [2] [3]

Do not compare a neutral database mass directly with a protonated precursor coordinate. For an ion-level exact search, document precursor tolerance and compatible polarity, charge, adduct, ionization, and fragmentation conditions. Inspect metadata exclusions: a correct molecule with only an incompatible reference may never reach scoring. If software cannot enforce a needed filter, check it during review. Collision energies labeled with the same number on different instruments are not automatically equivalent.

Freeze preprocessing before inspecting the winners

Keep the original spectrum and save the searched version. Document centroiding, intensity cutoff, precursor-region removal, mass range, peak merging, and intensity transformation. Specify whether the same rules apply to references. Removing a precursor-dominated region can help one comparison yet discard informative products in another. GNPS exposes separate filtering, precursor-tolerance, fragment-tolerance, score, and matched-peak controls. Their presence is a checklist, not a universal recipe. [4]

  1. Choose a reference release and preserve its accession identifiers.
  2. Define precursor eligibility independently of fragment matching.
  3. Specify peak-pair tolerance and how ambiguous pairings are resolved.
  4. Record normalization, scoring, minimum matched peaks, and result-retention rules.
  5. Return competing candidates, including failures and no-hit queries, for review.

Changing filters until a desired name wins makes the analysis difficult to audit. Exploratory changes are legitimate when recorded and checked on independent known materials. Search settings should answer the analytical question, rather than imitate a screenshot from another experiment.

A hypothetical search you can calculate

Constructed teaching example: query Q is positive-mode, singly protonated MS/MS with precursor m/z 301.1000. Choose a ±5 ppm precursor window around Q and ±0.01 m/z fragment matching. These are illustrative choices, not recommended cutoffs. The precursor half-width is 301.1000 × 5/106 = 0.0015055; a compatible reference at 301.1008 passes, while one at 301.1030 fails.

After the declared processing, Q has peaks (100.00, 10), (150.00, 6), and (200.00, 4), written as (m/z, intensity). Reference A has the same coordinates and intensities 10, 6, 0; reference B has 10, 0, 4. For this example only, align the union of coordinates, insert zero for an absent peak, apply no intensity transformation, and compute cosine as dot product divided by the two vector lengths.

The squared lengths are 152 for Q, 136 for A, and 116 for B. Therefore Q–A scores 136/√(152 × 136) ≈ 0.946, while Q–B scores 116/√(152 × 116) ≈ 0.874. A ranks first, although it does not explain Q's peak at 200.00. Both have two matched peaks. A minimum of three would reject both; filtering away that unmatched peak would change the score. The numbers illustrate decisions in the algorithm, not molecular truth.

Ask a different question when the query is absent

Suppose a related reference has precursor 315.1157 and fragments at 100.00, 164.0157, and 214.0157. An analog alignment may pair the first fragment directly and the other two after a +14.0157 shift, corresponding here to the precursor difference for singly charged ions. Modified alignment can use both unchanged and shifted products. [5]

This pattern motivates a relationship hypothesis. It does not establish the location of a change, its mechanism, or a unique structure; a precursor difference can also reflect a different ion form. Keep exact and analog result labels distinct. An absent query cannot become an exact library identification merely because its nearest available neighbor scores highly. Conversely, no accepted hit can mean missing coverage, incompatible conditions, poor spectrum quality, or restrictive settings rather than a novel molecule.

Review evidence beyond the rank

Inspect the mirror spectrum, matched-peak count, strong unmatched peaks, possible coisolation, and distinguishing fragments among close candidates. A library match is a comparison result. Its similarity is neither an individual correctness probability nor a false-discovery rate. Primary significance-estimation research found project-dependent relationships between search settings and error rates. An error estimate requires an appropriate validated procedure and reporting population; a borrowed cutoff cannot supply it. [6]

Use standards or orthogonal evidence when the decision requires stronger identity. MSI level-1 identification of a previously known metabolite calls for at least two independent, orthogonal properties matched to an authentic compound under identical conditions. A library hit alone does not meet that requirement. Preserve unresolved isomers and the confidence framework used; error control for an accepted set does not establish an individual isomer assignment. [7]

Leave a reproducible decision trail

Save query and reference spectra, library release, candidate filters, preprocessing, tolerances, scoring implementation, alternative hits, and reasons for acceptance or rejection. Report “no accepted match” when warranted. This lets a future analyst distinguish new reference coverage from a changed algorithm.

Check your understanding

Does A's score of 0.946 mean a 94.6% chance that Q is A?

No. It is the cosine under the stated representation. It lacks a validated probability mapping and cannot test candidates missing from the library.

Can the shifted-fragment example justify renaming Q as the reference compound?

No. It supports an analog hypothesis. Check charge and adduct, examine diagnostic fragments, and obtain evidence that distinguishes candidate structures.

References & further reading

  1. MassBank consortium. About MassBank.

    Official description of a reference spectral library and chemical/experimental record metadata. No coverage or accuracy benchmark is inferred.

  2. NIST. CODATA recommended values of the fundamental physical constants: proton mass in u and electron mass in u.

    Official constants table. Examples round the proton mass to 1.007276467 Da; u and Da name the same mass unit.

  3. NIST. Atomic Weights and Isotopic Compositions for Sodium.

    Neutral sodium-23 relative atomic mass 22.9897692820; the example subtracts one electron mass to approximate sodium-cation mass.

  4. GNPS. Spectral Library Search documentation.

    Official documentation checked 7 October 2026. Supports distinct precursor/fragment tolerances, peak filters, score and matched-peak requirements, and exact versus analog search options. Interface defaults are not recommended as universal scientific thresholds.

  5. GNPS. Molecular Networking Theory: spectrum alignment.

    Official explanation of unshifted and precursor-difference-shifted peak alignment and its limitations. The packet uses original hypothetical spectra, not the source illustrations; a mass shift does not locate a modification or establish a unique structure.

  6. Scheubert et al. (2017). Significance estimation for large scale metabolomics annotations by spectral matching. Nature Communications 8, 1494.

    Primary publisher-indexed discussion and methods checked; a later direct open encountered an authentication redirect. Supports project-dependent score/error relationships and method-specific significance estimation. No fixed cosine cutoff, universal FDR, or guarantee of isomer identification is transferred.

  7. Sumner et al. (2007). Proposed minimum reporting standards for chemical analysis. Metabolomics 3, 211–221.

    MSI Chemical Analysis Working Group reporting recommendations. Supports evidence-specific identification of previously characterized metabolites and calibration/validation reporting. Publisher metadata/abstract, indexed PMC text, and an institutional author manuscript (Fiehn Lab, UC Davis), p. 12, were checked. The institutional manuscript is not the final typeset version. Historical numerical validation thresholds are not adopted.

Help make this article clearer.Edit this article →Suggest a correction →