Skip to content

Metadata values type issues #816

@julianpollmann

Description

@julianpollmann

Describe the bug
The filter derive_annotation_from_compound_name will fail since numpy 2 stricter dtype handling.
While calculating mass_differences compound_name_annotation_df["monoisotopic_mass"] uses float64 parent_mass is a str.

To Reproduce
Steps to reproduce the behavior:

  1. load_from_mgf with a file with missing inchi and smiles.
  2. process the metadata with:
from matchms.filtering import derive_annotation_from_compound_name

def metadata_processing(spectrum):
    spectrum = derive_annotation_from_compound_name(spectrum)

    return spectrum
  1. spectra = [metadata_processing(s) for s in spectra]

Will result in:

UFuncTypeError                            Traceback (most recent call last)
Cell In[5], line 1
----> 1 spectra = [metadata_processing(s) for s in spectra]

Cell In[4], line 4, in metadata_processing(spectrum)
      3 def metadata_processing(spectrum):
----> 4     spectrum = derive_annotation_from_compound_name(spectrum)
      6     return spectrum

File [~\workspace\matchms\matchms\filtering\metadata_processing\derive_annotation_from_compound_name.py:77](http://localhost:8888/lab/tree/~/workspace/matchms/matchms/filtering/metadata_processing/derive_annotation_from_compound_name.py#line=76), in derive_annotation_from_compound_name(spectrum_in, annotated_compound_names_file, mass_tolerance, clone)
     75 print(parent_mass)
     76 print(type(parent_mass))
---> 77 mass_differences = np.abs(compound_name_annotation_df["monoisotopic_mass"] - parent_mass)

...
UFuncTypeError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('float64'), dtype('<U8')) -> None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions