bittremieux / spectrum_utils

Python package for efficient mass spectrometry data processing and visualization
https://spectrum-utils.readthedocs.io/
Apache License 2.0
130 stars 21 forks source link

ValueError: Unknown precursor m/z from USI. Specify the precursor m/z directly. #54

Closed chinmayaNK22 closed 10 months ago

chinmayaNK22 commented 10 months ago

Hello,

I am trying to plot a mirror plot using the example provided in the _spectrumutils document (https://spectrum-utils.readthedocs.io/en/latest/plotting.html#mirror-plot). The "_sus.MsmsSpectrum.from_usi(usibottom)", where it fetches the spectra throws the below error.

    spectrum_top = sus.MsmsSpectrum.from_usi(usi_top)
  File "C:\Users\new\AppData\Local\Programs\Python\Python310\lib\site-packages\spectrum_utils\spectrum.py", line 345, in from_usi
    raise ValueError(
ValueError: Unknown precursor m/z from USI. Specify the precursor m/z directly.

However, it works great when I execute the mirror plot function of pyteomics with '_spectrumutils' backend.

Can you please solve this issue?

Here, I am trying to plot experimental and predicted spectra using the mirror plot. can I extend its application apart from USI?

Thanks, Chinmaya

bittremieux commented 10 months ago

Some public repositories (notably MassIVE) only return the peak values, whereas spectrum_utils also requires having a valid precursor m/z value. Therefore, if the spectrum for your USI is only available on MassIVE and not on alternative repositories, you might encounter this error. In that case you can specify the precursor_mz directly in the from_usi call, as mentioned in the error message.

However, we had a workaround for this by retrieving USIs from MassIVE through the GNPS resolver as well to fill in missing precursor m/z values. This currently needs a small update (see #52), and will be fixed in the next upcoming release.

For now either specify the precursor m/z directly or retrieve USIs from repositories other than MassIVE.

chinmayaNK22 commented 10 months ago

Thank you Bittremieux

That was quite informative. I will try to work with other repositories for now.

-- Chinmaya