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

Module 'pyteomics.proforma' has no attribute 'Proforma' #96

Closed alessandro-vai closed 1 year ago

alessandro-vai commented 1 year ago

Hello,

I just want to report that if you pass a proforma sequence to the mirror plot function, you get an error saying that module 'pyteomics.proforma' has no attribute 'Proforma'. I checked and actually proforma has a module called ProForma, with the capital F. So I guess it's just a typo :).

Have a great day

from pyteomics import pylab_aux as pa, usi
import matplotlib.pyplot as plt
usi_top = 'mzspec:MSV000079960:DY_HS_Exp7-Ad1:scan:30372'
usi_bottom = 'mzspec:MSV000080679:j11962_C1orf144:scan:10671'

spectrum_top = usi.proxi(usi_top, 'massive')
spectrum_bottom = usi.proxi(usi_bottom, 'massive')
peptide = 'DLTDYLM[+15.9949]K'
pa.mirror(spectrum_top, spectrum_bottom, peptide=peptide, precursor_charge=2,
    ion_types='aby', ftol=0.5, scaling='root',
    remove_precursor_peak=True, backend='spectrum_utils')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:598, in _spectrum_utils_annotate_spectrum(spectrum, peptide, *args, **kwargs)
    597 try:
--> 598     parsed_proforma = proforma.Proforma.parse(peptide)
    599     peptide_pro = peptide

AttributeError: module 'pyteomics.proforma' has no attribute 'Proforma'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:603, in _spectrum_utils_annotate_spectrum(spectrum, peptide, *args, **kwargs)
    602 try:
--> 603     peptide_pro = parser.to_proforma(peptide, aa_mass=aa_mass, aa_comp=aa_comp, mod_names=mod_names, prefix=prefix)
    604 except Exception:

File /opt/conda/lib/python3.10/site-packages/pyteomics/parser.py:500, in to_proforma(sequence, **kwargs)
    499 if isinstance(sequence, str):
--> 500     return to_proforma(parse(sequence), **kwargs)
    502 aa_mass = kwargs.get('aa_mass', std_aa_mass)

File /opt/conda/lib/python3.10/site-packages/pyteomics/parser.py:539, in to_proforma(sequence, **kwargs)
    538             mod, aa = _split_label(label)
--> 539             pro_sequence.append((aa, get_tag(mod)))
    540 else:  # split sequence

File /opt/conda/lib/python3.10/site-packages/pyteomics/parser.py:515, in to_proforma.<locals>.get_tag(label)
    514     return [proforma.MassModification(aa_mass[label])]
--> 515 if label in aa_comp:
    516     return [proforma.FormulaModification(''.join('{}{}'.format(k, v if v not in {0, 1} else '') for k, v in aa_comp[label].items()))]

TypeError: argument of type 'NoneType' is not iterable

During handling of the above exception, another exception occurred:

PyteomicsError                            Traceback (most recent call last)
Cell In[3], line 9
      7 spectrum_bottom = usi.proxi(usi_bottom, 'massive')
      8 peptide = 'DLTDYLM[+15.9949]K'
----> 9 pa.mirror(spectrum_top, spectrum_bottom, peptide=peptide, precursor_charge=2,
     10     ion_types='aby', ftol=0.5, scaling='root',
     11     remove_precursor_peak=True, backend='spectrum_utils')

File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:818, in mirror(spec_top, spec_bottom, peptide, spectrum_kws, ax, **kwargs)
    783 """Create a mirror plot of two (possible annotated) spectra using `spectrum_utils`.
    784 
    785 Parameters
   (...)
    814 out : matplotlib.pyplot.Axes
    815 """
    817 spec_gen = _spectrum_utils_create_spectrum if peptide is None else _spectrum_utils_annotate_spectrum
--> 818 spec_top = spec_gen(spec_top, peptide, **kwargs)
    819 spec_bottom = spec_gen(spec_bottom, peptide, **kwargs)
    821 bname = kwargs.pop('backend', 'spectrum_utils')

File /opt/conda/lib/python3.10/site-packages/pyteomics/pylab_aux.py:605, in _spectrum_utils_annotate_spectrum(spectrum, peptide, *args, **kwargs)
    603         peptide_pro = parser.to_proforma(peptide, aa_mass=aa_mass, aa_comp=aa_comp, mod_names=mod_names, prefix=prefix)
    604     except Exception:
--> 605         raise PyteomicsError("Cannot parse {} as ProForma or convert from modX".format(peptide))
    607 precursor_mz = kwargs.pop('precursor_mz', None)
    608 if precursor_mz is None:

PyteomicsError: Pyteomics error, message: 'Cannot parse DLTDYLM[+15.9949]K as ProForma or convert from modX'
levitsky commented 1 year ago

Thank you! I don't know how I could have possibly missed this...