bittremieux / spectrum_utils

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

loading spectrum by usi can't find m/z #37

Closed wsnoble closed 2 years ago

wsnoble commented 2 years ago

I am loading a spectrum by USI like this

usi = "mzspec:PXD031817:MSB19717Trypsin021915:scan:1930"
spectrum = spectrum_utils.spectrum.MsmsSpectrum.from_usi(usi)

but I get this error:

Traceback (most recent call last):
  File "./plot-annotated-spectrum.py", line 30, in <module>
    spectrum = spectrum_utils.spectrum.MsmsSpectrum.from_usi(usi)
  File "/net/noble/vol1/home/noble/miniconda3/envs/spectrum_utils/lib/python3.8\
/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.

If I download the file and convert to MGF, that spectrum looks like this:

BEGIN IONS
TITLE=controllerType=0 controllerNumber=1 scan=1930
SCANS=1930
RTINSECONDS=769.87164
PEPMASS=384.879058837891
CHARGE=3+
101.0714035 1807.1617431641
110.0717926 183053.5468750000
111.0751266 8941.6181640625
112.0874252 1604.1121826172
...

It has the peptide mass and the charge. Why can't it figure out the m/z?

bittremieux commented 2 years ago

spectrum_utils receives spectrum data from online resources based on the ProXi specification (through integration with Pyteomics). Unfortunately, precursor m/z (and charge) are only optional fields for spectra. As a result, this information is not always available for all files or provided by all data repositories.

Unfortunately this missing information cannot be remedied on the spectrum_utils side, hence the option to explicitly provide precursor m/z and charge.