EMSL-Computing / CoreMS

CoreMS is a comprehensive mass spectrometry software framework
BSD 2-Clause "Simplified" License
51 stars 25 forks source link

Added options for nominal kendrick mass calculation #3

Closed Kzra closed 3 years ago

Kzra commented 3 years ago

It might be good to support different rounding methods to calculate nominal kendrick mass in kendrick mass defect calculations.

I noticed that corems uses int(kendrick_mass) to calculate nominal kendrick mass, so the kendrick mass is always rounded down to the nearest integer. This isn’t the same nominal kendrick mass calculation as is performed in Hughey, Christine A., et al. (2001), in which the kendrick mass us rounded up to the nearest integer (e.g. for km = 350.9346 351, nkm = 360, kmd = 0.66). I’ve also seen nominal kendrick mass rounded up or down to nearest integer (e.g. Cody, Robert B., and Thierry Fouquet (2018) ).

The differences aren’t too important for analyzing mass defect plots, but they could become confusing when you are comparing mass defects between studies.

This pull request adds three new rounding methods, ‘ceil’: nominal km always rounded up to the nearest integer, ‘round’: nominal km rounded up or down to the nearest integer and ‘floor’: (default) nominal km always rounded down to the nearest integer.

I haven’t added a settings attribute to the ICRMassPeak class so instead MsPeakCalc imports MSSettings to read kendrick_rounding_method. I can imagine it is a bit cleaner to instead use self.settings to read the rounding method, but I am unsure about messing with the classes too much.

Hopefully this is useful. The changes seem to work in my limited testing but might need some tidying up.

Thanks, Ezra