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

[BUG (??)] Terminal modifications are kept regardless of slicing #91

Closed jspaezp closed 1 year ago

jspaezp commented 1 year ago

Hello!

I was wondering whether this is a desired behavior. I noticed that when slicing a proforma object, it always keeps the terminal modifications. This feels odd to me, since I would expect terminal modifications to be removed when "slicing away" that side of the modification.

Example:

>>> from pyteomics import proforma
>>> pep = proforma.ProForma.parse("[U-1]-MPEP/2")
>>> pep
ProForma([('M', None), ('P', None), ('E', None), ('P', None)], {'n_term': [GenericModification('U-1', None, None)], 'c_term': None, 'unlocalized_modifications': [], 'labile_modifications': [], 'fixed_modifications': [], 'intervals': [], 'isotopes': [], 'group_ids': [], 'charge_state': ChargeState(2, [])})
>>> pep[:2]
ProForma([('M', None), ('P', None)], {'n_term': [GenericModification('U-1', None, None)], 'c_term': None, 'unlocalized_modifications': [], 'labile_modifications': [], 'fixed_modifications': [], 'intervals': [], 'isotopes': [], 'group_ids': [], 'charge_state': ChargeState(2, [])})
>>> pep[2:] # Here I would expect the modification to be gone
ProForma([('E', None), ('P', None)], {'n_term': [GenericModification('U-1', None, None)], 'c_term': None, 'unlocalized_modifications': [], 'labile_modifications': [], 'fixed_modifications': [], 'intervals': [], 'isotopes':  [], 'group_ids': [], 'charge_state': ChargeState(2, [])})

LMK what you think Best, Sebastian

jspaezp commented 1 year ago

Noticed the fix, thanks a lot! amazing work yall!

mobiusklein commented 1 year ago

Thank you for reporting these issues. Without your engagement we wouldn't know what was missing.