Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Kzra
Copy link
Contributor

@Kzra Kzra commented May 14, 2021

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

Copy link
Member

@corilo corilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the changes look good; however, can you please change:

MSParameters.ms_peak.kendrick_rounding_method

to:

self._ms_parent.mspeaks_settings.kendrick_rounding_method

MSParameters should be used before the mass spectrum object creation, not inside the object.

self._ms_parent.mspeaks_settings is a new instance of the MassSpecPeakSetting, created when the mass spectrum is generated, ensuring the parameters are specific to that object.

@corilo corilo merged commit 46b6b94 into EMSL-Computing:master May 20, 2021
deweycw pushed a commit to deweycw/CoreMS that referenced this pull request Aug 23, 2022
Added options for nominal kendrick mass calculation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants