levitsky / pyteomics

Pyteomics is a collection of lightweight and handy tools for Python that help to handle various sorts of proteomics data. Pyteomics provides a growing set of modules to facilitate the most common tasks in proteomics data analysis.
http://pyteomics.readthedocs.io
Apache License 2.0
105 stars 34 forks source link

Example 4: Spectrum Annotation appears to be broken #81

Closed wsnoble closed 1 year ago

wsnoble commented 1 year ago

I tried running example 4 from here, but it yielded an error. Maybe something in the interface to spectrum_utils has changed?

from pyteomics import pylab_aux as pa, usi
import matplotlib.pyplot as plt
spectrum = usi.proxi(
    'mzspec:PXD004732:01650b_BC2-TUM_first_pool_53_01_01-3xHCD-1h-R2:scan:41840',
    'massive')
peptide = 'WNQLQAFWGTGK'
pa.annotate_spectrum(spectrum, peptide, precursor_charge=2, backend='spectrum_utils',
    ion_types='aby', title=peptide)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/net/noble/vol1/home/noble/miniconda3/envs/spectrum_utils/lib/python3.8/site-packages/pyteomics/pylab_aux.py", line 757, in annotate_spectrum
    return backend(spectrum, peptide, *args, **kwargs)
  File "/net/noble/vol1/home/noble/miniconda3/envs/spectrum_utils/lib/python3.8/site-packages/pyteomics/pylab_aux.py", line 639, in _spectrum_utils_annotate_plot
    spectrum = _spectrum_utils_annotate_spectrum(spectrum, peptide, *args, **kwargs)
  File "/net/noble/vol1/home/noble/miniconda3/envs/spectrum_utils/lib/python3.8/site-packages/pyteomics/pylab_aux.py", line 584, in _spectrum_utils_annotate_spectrum
    spectrum = _spectrum_utils_create_spectrum(spectrum, clean_sequence, *args,
  File "/net/noble/vol1/home/noble/miniconda3/envs/spectrum_utils/lib/python3.8/site-packages/pyteomics/pylab_aux.py", line 536, in _spectrum_utils_create_spectrum
    spectrum = sus.MsmsSpectrum(
TypeError: __init__() got an unexpected keyword argument 'peptide'
levitsky commented 1 year ago

The new release of spectrum_utils changed its interface, so I had to change the calling code as well. The example code now works for me basically unchanged, but it doesn't work anymore with previous versions of spectrum_utils.

These changes in Pyteomics are in master but not yet released. If you get Pyteomics from master and latest spectrum_utils, everything should work, in which case I can make a new release of Pyteomics.

levitsky commented 1 year ago

The fix is now released. Please reopen if this issue persists with pyteomics 4.5.6 and spectrum_utils 0.4.1 or newer.

bittremieux commented 1 year ago

Sorry for the hassle @levitsky. The spectrum_utils API was indeed changed a bit. I wanted to open a PR with updates here, but I was on holiday the past 3 weeks and didn't get around to it before. I'm glad you managed to fix it already in the mean time.