Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example results in error #52

Open
LLautenbacher opened this issue Jan 27, 2025 · 2 comments
Open

Example results in error #52

LLautenbacher opened this issue Jan 27, 2025 · 2 comments
Labels
A-python Area: rustyms-python

Comments

@LLautenbacher
Copy link

Hi, thank you for preparing this package! When I tried to use the example from https://rustyms.readthedocs.io/en/stable/. It results in this error. I used version rustyms==0.9.0.

import rustyms

# Create a new spectrum
raw_spectrum = rustyms.RawSpectrum(
    title="spectrum_1",
    num_scans=6,
    rt=10,
    precursor_mass=436.12634,
    precursor_charge=2,
    mz_array=[72.04444, 148.06048, 175.05362, 263.08742, 290.08056, 366.09661],
    intensity_array=[100, 600, 300, 400, 500, 200],
)

# Create a new peptide from a ProForma 2.0 string
peptide = rustyms.LinearPeptide("ACDE/2")

# Annotate the spectrum with the peptide
annotated_spectrum = raw_spectrum.annotate(peptide, "cid_hcd")
TypeError                                 Traceback (most recent call last)
Cell In[3], [line 18](vscode-notebook-cell:?execution_count=3&line=18)
     [15](vscode-notebook-cell:?execution_count=3&line=15) peptide = rustyms.LinearPeptide("ACDE/2")
     [17](vscode-notebook-cell:?execution_count=3&line=17) # Annotate the spectrum with the peptide
---> [18](vscode-notebook-cell:?execution_count=3&line=18) annotated_spectrum = raw_spectrum.annotate(peptide, "cid_hcd")

TypeError: argument 'peptide': 'LinearPeptide' object cannot be converted to 'CompoundPeptidoform'
@douweschulte
Copy link
Member

I will update the example, thank you for opening the issue. The issue here is that since 0.9 the spectrum annotation has to be done with a CompoundPeptidoform. To get your code running the easiest is to create one instead on a linear peptide rustyms.CompoundPeptidoform("ACDE/2"). I will look into how I can make the API easier to use, maybe I can make it so that any peptide like object will work.

@douweschulte douweschulte added the A-python Area: rustyms-python label Jan 30, 2025
@douweschulte
Copy link
Member

I am not sure if I can get nice behaviour where the annotate function accepts any of the three peptidoform types. It looks like getting this to work in pyO3 is somewhat more involved then I hoped. I will keep my eyes peeled for a solution though. Otherwise I updated the documentation so with the next release it will be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-python Area: rustyms-python
Projects
None yet
Development

No branches or pull requests

2 participants