Reads MGF files and extracts the relevant MS2 spectra information. This function is tailored for database-oriented analyses.

read_mgf4database(file)

Arguments

file

A character vector specifying the path(s) to the MGF file(s).

Value

A list containing processed MS2 spectra information for each provided MGF file. Each element of the list contains two components:

  • info: A data frame with columns for the name (composed of m/z and retention time), m/z, retention time, and file name.

  • spec: A data frame where each row represents a fragment ion peak, with columns for m/z and intensity values.

Empty spectra are removed from the output.

Examples

# Locate the example mgf file in the installed package
file_path <- system.file("extdata", "example.mgf", package = "masstools")
# Then use it in your function
result <- read_mgf(file_path)
#> Reading mgf data...
#> Warning: incomplete final line found on 'D:/R-4.4.3/library/masstools/extdata/example.mgf'