lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
123 stars 50 forks source link

Mz of fragments with neutral losses #573

Closed nbisliuk closed 2 years ago

nbisliuk commented 2 years ago

Hi! It seems fragment charge is not taken into account when removing neutral loss in .removeNeutralLoss() which is a part of .neutralLoss(). E.g. compare to _pyteomics.mass.calculatemass():

Python:

from pyteomics import mass
mass.calculate_mass(sequence = "PEPTIDE", ion_type='b', charge = 3) #  261.4570762477734
mass.calculate_mass(sequence = "PEPTIDE", ion_type='b-H2O', charge = 3) #  255.45355468654

R:

MSnbase::calculateFragments("PEPTIDEE", z=3, type="b") %>% filter(pos == 7)
        mz ion type pos z     seq
1 261.4571  b7    b   7 3 PEPTIDE
2 243.4465 b7_   b_   7 3 PEPTIDE

Should be like this, no?

loss$mz <- loss$mz - mass / loss$z
lgatto commented 2 years ago

ping @sgibb

sgibb commented 2 years ago

@nbisliuk Indeed you are right! Thanks for reporting this bug (and its fix). I implemented it in the same way in cac88747b5de1b4b31292413059507af160afd6f

@lgatto because of this trivial fix I already pushed it into master instead of opening a PR. Unfortunately I lost track where this function is used in other packages. The patch has to be applied at least in PSMatch as well.