matchms.filtering.metadata_processing.repair_not_matching_annotation module

matchms.filtering.metadata_processing.repair_not_matching_annotation.repair_not_matching_annotation(spectrum_in: <module 'matchms.Spectrum' from '/home/docs/checkouts/readthedocs.org/user_builds/matchms/checkouts/latest/readthedocs/../matchms/Spectrum.py'>)[source]

Repairs mismatches in a spectrum’s annotations related to SMILES, InChI, and InChIKey.

Given a spectrum, this function ensures that the provided SMILES, InChI, and InChIKey annotations are consistent with one another. If there are discrepancies, they are resolved as follows:

  1. If the SMILES and InChI do not match:
    • Both SMILES and InChI are checked against the parent mass.

    • The annotation that matches the parent mass is retained, and the other is regenerated.

  2. If the InChIKey does not match the InChI:
    • A new InChIKey is generated from the InChI and replaces the old one.

Warnings and information logs are generated to track changes and potential issues. For correctness of InChIKey entries, only the first 14 characters are considered.

Parameters:

spectrum_inSpectrum

The input spectrum containing annotations to be checked and repaired.

Returns:

Spectrum

A cloned version of the input spectrum with corrected annotations. If the input spectrum is None, it returns None.