agentsclimarketplace

Mgf metadata completion from smiles

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v1/skills/mgf-metadata-completion-from-smiles

Use when when processing MGF-format MS2 spectral libraries (e.g., GNPS) that contain SMILES but lack the Molecular Formula field, and you need to prepare the library for MS-DIAL import or polarity-based separation workflows.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill mgf-metadata-completion-from-smiles

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

5.3 KB, 905 tokens by cl100k_base, as published. Nobody here has run it

MGF Metadata Completion from SMILES

Summary

Complete missing Molecular Formula (MF) fields in MGF-format mass spectral libraries by calculating MF from existing SMILES strings. This is essential for libraries like GNPS that lack comprehensive metadata annotation required by downstream MS-DIAL processing.

When to use

When processing MGF-format MS2 spectral libraries (e.g., GNPS) that contain SMILES but lack the Molecular Formula field, and you need to prepare the library for MS-DIAL import or polarity-based separation workflows.

When NOT to use

  • Input library already has complete Molecular Formula metadata (e.g., RIKEN MS2 libraries).
  • SMILES field is absent or unpopulated in the library; MF cannot be calculated without structure information.
  • Working with EI-format libraries, which do not use MGF input format.

Inputs

  • MGF-format spectral library file (e.g., ALL_GNPS.mgf)
  • Library object in R with SMILES field populated, MF field absent or incomplete

Outputs

  • Library object with Molecular Formula field populated for all entries
  • Ready for downstream polarity separation and MSP export

How to apply

After loading an MGF-format library using read_lib() with format='mgf', apply the complete_mgf() function to infer missing Molecular Formula values directly from SMILES strings present in the library records. This step should be performed before separating by ionization polarity (separate_polarity()) and writing output MSP files. The function iterates over library entries, identifies records lacking MF, and computes MF from the SMILES chemical structure representation using standard chemistry rules (element composition from the structure graph).

Related tools

  • mspcompiler (R package providing complete_mgf() function for MGF metadata inference from SMILES) — https://github.com/QizhiSu/mspcompiler
  • R (Environment for executing complete_mgf() and library processing functions)
  • MS-DIAL (Downstream software requiring complete Molecular Formula metadata in MSP files)
  • GNPS (Source library in MGF format containing SMILES but lacking MF) — https://gnps.ucsd.edu/ProteoSAFe/libraries.jsp

Examples

gnps <- read_lib("D:/MS_libraries/ALL_GNPS.mgf", format = "mgf")
gnps <- complete_mgf(gnps)

Evaluation signals

  • All spectral records in the output library contain a non-empty Molecular Formula field
  • Molecular Formula values are chemically valid (e.g., match expected elemental composition from SMILES structure)
  • No records are dropped or lost during MF calculation; record count matches input library
  • Output library successfully passes subsequent separate_polarity() and write_MS2_msp() steps without errors
  • Generated MSP files conform to MS-DIAL format specification with MF field present

Limitations

  • Requires SMILES field to be present and correctly formatted in the input library; malformed SMILES will cause calculation failure or incorrect MF inference.
  • MF calculation relies on chemical structure parsing; ambiguous or non-standard SMILES notations may produce unexpected results.
  • Function is designed only for MGF-format input; MSP and other spectral formats require alternative preparation steps.
  • Large libraries (hundreds of thousands of records) may experience memory or computational overhead during batch MF calculation.

Evidence

  • [readme] GNPS library lacks MF field, requiring computation from SMILES: "this library does not have the Molecular Formula (MF) field, so we can calculated the MF from the SMILES (if it exists) by the complete_mgf function"
  • [other] complete_mgf() is the dedicated function for MGF metadata completion: "complete_mgf() to calculate Molecular Formula from SMILES where missing"
  • [readme] complete_mgf() must be applied to GNPS library in MGF format before polarity separation: "gnps <- read_lib("D:/MS_libraries/ALL_GNPS.mgf", format = "mgf")

Compute MF

gnps <- complete_mgf(gnps) gnps_pos <- separate_polarity(gnps, polarity = "pos")"

  • [methods] MGF metadata completion is part of standardized MS2 library compilation workflow: "For GNPS library in MGF format, use complete_mgf() to calculate Molecular Formula from SMILES where missing"

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.