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

Fix iteration in example for calculating theoretical fragment m/z #106

Closed michabirklbauer closed 1 year ago

michabirklbauer commented 1 year ago

https://github.com/levitsky/pyteomics/blob/5661fd40512884113adf6699388cbf69d4a93c02/doc/source/_static/example_msms.py#L34

If I am not mistaken this loop should go from inclusive 1 to inclusive len(peptide) - 1 to generate all fragment masses. Since the upper bound of range is exclusive we don't need to substract the 1 here.

The previous code would miss one ion of each ion type. E.g. For b ions PEPT would give P, PE and missing PEP since "PEPT"[:2] = "PE" where 2 is the maximum of iterable i Similarly for y ions it would give EPT, PT and missing T since "PEPT"[2:] = "PT"

levitsky commented 1 year ago

Thank you!