wfondrie / depthcharge

A deep learning toolkit for mass spectrometry
https://wfondrie.github.io/depthcharge/
Apache License 2.0
59 stars 18 forks source link

Fix calculation of m/z for charged peptides. #23

Closed mriffle closed 1 year ago

mriffle commented 1 year ago

Not sure if I'm misreading, but I think I found a bug in the calculation of m/z of charged peptides.

bittremieux commented 1 year ago

It does indeed look a bit counter-intuitive, but both formulas actually give the same result if you bring the charge within the brackets.

calc_mass = (calc_mass + charge * self.proton) / charge
          = (calc_mass / charge) + ((charge * self.proton) / charge)
          = (calc_mass / charge) + self.proton
mriffle commented 1 year ago

Aha, thanks.