Skip to content

calculateRatio fails when feature_name = intensity and there is no IS - #3272

Merged
timosachsenberg merged 3 commits into
OpenMS:developfrom
dmccloskey:fix/AbsQuantIntensityRatio
Mar 1, 2018
Merged

timosachsenberg merged 3 commits into
OpenMS:developfrom
dmccloskey:fix/AbsQuantIntensityRatio

Conversation

@dmccloskey

Copy link
Copy Markdown
Contributor

Fix

  • added additional conditionals to calculateRatio and calculateIonRatio methods
  • added tests to test for the case of feature_name = intensity and no IS

const double feature_1 = component_1.getIntensity();
ratio = feature_1;
}
else if (component_1.metaValueExists(feature_name) && component_2.metaValueExists(feature_name))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these cases are bit difficult to follow.
Does this also cover the case were feature="intensity"? Then I think it would be wrong to request the metaValue("intensity")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Essentially some feature_names are stored as metaValues and others are given members in the Feature class. Specifically, I am trying to cover the case where one wants to quantify or filter based on peak area (i.e., "intensity") which is accessed via getIntensity() or peak height which is accessed by getMetaValue("peak_apex"int) for both the case where the first and second component exists or where the first component exists but the second does not.

@timosachsenberg timosachsenberg Mar 1, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok that's how I understood it. But this will e.g. fail if feature_name = intensity but no native_id meta value exists, right?
Then else if (component_1.metaValueExists(feature_name)) will be called with feature_name = intensity which will result in an error.

I think it would be better to distinguish two cases:
if (feature_name == "intensity")
{ // access member
}
else // feature name refers to meta value
{ // access meta values
}
and put the corresponding code in that parts.

@dmccloskey dmccloskey Mar 1, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If there is no metavalue called "native_id" it will fail. I am testing to see if the feature is actually populated with values. Is there a way you would recommend testing to see if the feature has an intensity value? That would avoid the need to test for the "native_id".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Intensity is initialized to 0. Guess you could error out if this is zero and feature_name = intensity

double feature_2 = component_2.getMetaValue(feature_name);
ratio = feature_1/feature_2;
}
else if (component_1.metaValueExists(feature_name))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here... what if feature_name is "intensity"

@timosachsenberg

Copy link
Copy Markdown
Contributor

thanks! now it's easier to read

@timosachsenberg
timosachsenberg merged commit b78f984 into OpenMS:develop Mar 1, 2018
@dmccloskey
dmccloskey deleted the fix/AbsQuantIntensityRatio branch August 21, 2020 12:10
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