MassBank / RMassBank

Playground for experiments on the official http://bioconductor.org/packages/devel/bioc/html/RMassBank.html
Other
12 stars 15 forks source link

`findMz.formula` fails for multiple charges #306

Closed meowcat closed 2 years ago

meowcat commented 2 years ago

findMz.formula is actually incorrect, and will not work correctly when negative AND positive atom counts are present, or for multiple charges. My 6 year old code is wrong.

https://github.com/MassBank/RMassBank/blob/e51aa6faa8b091c53272ee62dc53a3315133b25c/R/leCsvAccess.R#L520-L547

https://github.com/MassBank/RMassBank/blob/e51aa6faa8b091c53272ee62dc53a3315133b25c/R/formulaCalculator.R#L356-L365

meowcat commented 2 years ago

While negative atoms only really make sense for charge=0 (to calculate mass shifts), I will now fix it such that it returns the formally correct result: "C-1" with charge 2- will return the negative mass of a carbon (-12) minus one electron.

meowcat commented 2 years ago

Fixed by 7b780e2 Multiply-charged fragments probably still don't work