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

Cannot reproduce Example 4: Spectrum Annotation #90

Closed alessandro-vai closed 1 year ago

alessandro-vai commented 1 year ago

Hi,

First of all thanks for the package, it is really helpful. I got the error below when I try to reproduce the example of annotating a spectrum reported in the documentation. I am using the latest version of pyteomics and spetrum_utils. The error disappears if I use spectrum_utils 0.3.5.

Cheers

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) plt.show()


AttributeError Traceback (most recent call last) Cell In [2], line 1 ----> 1 pa.annotate_spectrum(spectrum, peptide, precursor_charge=2, backend='spectrum_utils', 2 ion_types='aby', title=peptide) 3 plt.show()

File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:758, in annotate_spectrum(spectrum, peptide, *args, **kwargs) 756 pylab.ylabel(kwargs.pop('ylabel', 'intensity')) 757 pylab.title(kwargs.pop('title', '')) --> 758 return backend(spectrum, peptide, *args, **kwargs)

File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:646, in _spectrum_utils_annotate_plot(spectrum, peptide, *args, **kwargs) 644 def _spectrum_utils_annotate_plot(spectrum, peptide, *args, **kwargs): --> 646 with SpectrumUtilsColorScheme(kwargs.pop('colors', None)): 647 spectrum = _spectrum_utils_annotate_spectrum(spectrum, peptide, *args, **kwargs) 648 return sup.spectrum(spectrum, annot_kws=kwargs.pop('text_kw', None), ax=kwargs.pop('ax', None))

File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:634, in SpectrumUtilsColorScheme.__init__(self, colors) 632 def __init__(self, colors): 633 self.colors = colors --> 634 self.previous_colors = sup.colors.copy()

AttributeError: 'NoneType' object has no attribute 'colors'

levitsky commented 1 year ago

Hi, thank you for the report!

I tried the latest versions and 0.3.5 and I get the traceback as shown with spectrum_utils 0.3.5, but with latest spectrum_utils everything works as expected. That is because Pyteomics should currently ignore installations prior to 0.4. Can you please check again if you indeed see the opposite behavior?

alessandro-vai commented 1 year ago

I just re-built the singularity image and now I get the error with both 0.3.5 and the latest version of spectrum_utils.

levitsky commented 1 year ago

Can you please check what version of spectrum_utils is installed as "latest"?

What is the output of pip list | grep spectrum-utils and python -c 'print(__import__("spectrum_utils").__version__)'?

If you have the output from pip install spectrum_utils, it can also provide some insight.

alessandro-vai commented 1 year ago

That was actually interesting. I installed spectrum_utils via conda and when I run the commands above, spectrum_utils was reported to be installed as version 0.0.0, even though conda output displayed version 0.4.1. So I tried to install spectrum_utils through pip and now everything works fine. Thanks a lot for your quick support.

levitsky commented 1 year ago

@bittremieux so it appears that spectrum_utils installed through conda reports itself as version 0.0.0, perhaps you'd want to look into that?

Apparently this fools the runtime version check that I put in Pyteomics. Perhaps there is a different way I should pull the version?

bittremieux commented 1 year ago

Hmm, interesting. Thanks for letting me know. spectrum_utils gets its version information from the package metadata, but maybe that's not compatible with conda. I'll have to look into it.

The typical solution would be to pin a minimum version for spectrum_utils in the setup dependencies, so that spectrum_utils would automatically get updated for users installing a new/updated version of Pyteomics. But because spectrum_utils is an optional dependency that is currently not explicitly specified, this is not applicable.