Prepare libraries of spectra

Description

Prepares spectral libraries for matching by importing, harmonizing, and splitting spectra by polarity. Exports results as Spectra RDS files (pos/neg) and a structure-organism pair (SOP) table.

Usage

prepare_libraries_spectra(
  input = get_params(step = "prepare_libraries_spectra")\$files\$libraries\$spectral\$raw,
  nam_lib = get_params(step = "prepare_libraries_spectra")\$names\$libraries,
  col_ad = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$adduct,
  col_ce = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$collision_energy,
  col_ci = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$compound_id,
  col_em = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$exact_mass,
  col_in = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$inchi,
  col_io = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$inchi_no_stereo,
  col_ik = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$inchikey,
  col_il = get_params(step =
    "prepare_libraries_spectra")\$names\$mgf\$inchikey_connectivity_layer,
  col_mf = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$molecular_formula,
  col_na = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$name,
  col_po = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$polarity,
  col_sm = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$smiles,
  col_sn = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$smiles_no_stereo,
  col_si = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$spectrum_id,
  col_sp = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$splash,
  col_sy = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$synonyms,
  col_xl = get_params(step = "prepare_libraries_spectra")\$names\$mgf\$xlogp
)

Arguments

input Character vector of file paths containing spectral data.
nam_lib Character library name for metadata.
col_ad Name of the adduct column in MGF.
col_ce Name of the collision energy column in MGF.
col_ci Name of the compound ID column in MGF.
col_em Name of the exact mass column in MGF.
col_in Name of the InChI column in MGF.
col_io Name of the InChI without stereo column in MGF.
col_ik Name of the InChIKey column in MGF.
col_il Name of the InChIKey connectivity layer column in MGF.
col_mf Name of the molecular formula column in MGF.
col_na Name of the name column in MGF.
col_po Name of the polarity column in MGF.
col_sm Name of the SMILES column in MGF.
col_sn Name of the SMILES without stereo column in MGF.
col_si Name of the spectrum ID column in MGF.
col_sp Name of the SPLASH column in MGF.
col_sy Name of the synonyms column in MGF.
col_xl Name of the xlogp column in MGF.

Details

This function:

  • Checks if output files already exist (idempotent).

  • Imports spectral data from input files.

  • Extracts and harmonizes spectra for positive and negative modes.

  • Fixes precursor m/z and InChIKey connectivity layer issues.

  • Exports polarity-specific Spectra objects and SOP table.

  • Returns empty templates if input files are missing.

Value

Character vector with paths to prepared library files (invisible).

Examples

library("tima")

copy_backbone()
go_to_cache()
prepare_libraries_spectra()
unlink("data", recursive = TRUE)