Skip to content

Push MTD #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft

Push MTD #143

wants to merge 24 commits into from

Conversation

t-aretz
Copy link

@t-aretz t-aretz commented May 5, 2023

Description

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

How can I get additional information on failed tests during CI

Click to expand If your PR is failing you can check out
  • The details of the action statuses at the end of the PR or the "Checks" tab.
  • http://cdash.openms.de/index.php?project=OpenMS and look for your PR. Use the "Show filters" capability on the top right to search for your PR number.
    If you click in the column that lists the failed tests you will get detailed error messages.

Advanced commands (admins / reviewer only)

Click to expand
  • /reformat (experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.
  • setting the label "NoJenkins" will skip tests for this PR on jenkins (saves resources e.g., on edits that do not affect tests)
  • commenting with rebuild jenkins will retrigger Jenkins-based CI builds

⚠️ Note: Once you opened a PR try to minimize the number of pushes to it as every push will trigger CI (automated builds and test) and is rather heavy on our infrastructure (e.g., if several pushes per day are performed).


// calc_left_border_
Size calc_left_border_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& input_exp, const std::vector<Apex>& apices_vec);

// parameter stuff
Copy link

Choose a reason for hiding this comment

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

what does stuff mean?

Suggestion: more precise description

Comment on lines 41 to 46
#include <omp.h>
// #include <parallel/algorithm>
// #include <ctime>
#include <chrono>

#include <OpenMS/MATH/MISC/MathFunctions.h>
Copy link

Choose a reason for hiding this comment

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

sort includes lexicographically

@@ -193,6 +200,7 @@ namespace OpenMS

void MassTraceDetection::run(const PeakMap& input_exp, std::vector<MassTrace>& found_masstraces, const Size max_traces)
{

Copy link

Choose a reason for hiding this comment

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

why blank line?

@@ -267,14 +276,48 @@ namespace OpenMS
return;
} // end of MassTraceDetection::run

double MassTraceDetection::find_offset_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& input_exp, const std::vector<Apex>& apices_vec)
Copy link

Choose a reason for hiding this comment

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

Suggested change
double MassTraceDetection::find_offset_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& input_exp, const std::vector<Apex>& apices_vec)
double MassTraceDetection::find_offset_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& intput_map, const std::vector<Apex>& apices_vec)

input_exp may not be concise name.

{
double centroid_mz = input_exp[apices_vec[peak_index_in_apices_vec].scan_idx][apices_vec[peak_index_in_apices_vec].peak_idx].getMZ(); //create function
// double ftl_sd((centroid_mz / 1e6) * mass_error_ppm_);
double ftl_sd = Math::ppmToMass(mass_error_ppm_,centroid_mz); // mit formel ergänzen header ppm to dalton
Copy link

Choose a reason for hiding this comment

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

what is the name "ftl_sd" supposed to mean?
more precise naming

Copy link

@maxvk79 maxvk79 May 5, 2023

Choose a reason for hiding this comment

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

coding convention! in several function names: instead of foo_bar() do fooBar()

double find_offset_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& input_exp, const std::vector& apices_vec);

Size j{};
while (input_exp[apices_vec[peak_index_in_apices_vec + j].scan_idx][apices_vec[peak_index_in_apices_vec + j].peak_idx].getMZ() <= right_bound)
{
if(peak_index_in_apices_vec + j >= apices_vec.size()) break;
Copy link

@maxvk79 maxvk79 May 5, 2023

Choose a reason for hiding this comment

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

Suggested change
if(peak_index_in_apices_vec + j >= apices_vec.size()) break;
if(peak_index_in_apices_vec + j >= apices_vec.size())
{
break;
}


Size MassTraceDetection::calc_right_border_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& input_exp, const std::vector<Apex>& apices_vec)
{
double right_bound = (input_exp[apices_vec[peak_index_in_apices_vec].scan_idx][apices_vec[peak_index_in_apices_vec].peak_idx].getMZ()) + (3 /* border gerade 3 mal so groß wie "noetig" */ * find_offset_(peak_index_in_apices_vec, mass_error_ppm_, input_exp, apices_vec));
Copy link

@maxvk79 maxvk79 May 5, 2023

Choose a reason for hiding this comment

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

Suggested change
double right_bound = (input_exp[apices_vec[peak_index_in_apices_vec].scan_idx][apices_vec[peak_index_in_apices_vec].peak_idx].getMZ()) + (3 /* border gerade 3 mal so groß wie "noetig" */ * find_offset_(peak_index_in_apices_vec, mass_error_ppm_, input_exp, apices_vec));
double tmp_mz = input_exp[apices_vec[peak_index_in_apices_vec].scan_idx][apices_vec[peak_index_in_apices_vec].peak_idx].getMZ();
double right_bound = tmp_mz + 3 * find_offset_(peak_index_in_apices_vec, mass_error_ppm_, input_exp, apices_vec); //border gerade 3 mal so groß wie "noetig"

return peak_index_in_apices_vec + j;
}

Size MassTraceDetection::calc_left_border_(Size peak_index_in_apices_vec, double mass_error_ppm_, const PeakMap& input_exp, const std::vector<Apex>& apices_vec)
Copy link

Choose a reason for hiding this comment

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

same as in right border :)

for (auto m_it = chrom_apices.crbegin(); m_it != chrom_apices.crend(); ++m_it)

// Size binnumber{1};
Size binnumber = omp_get_max_threads();
Copy link

Choose a reason for hiding this comment

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

Suggested change
Size binnumber = omp_get_max_threads();
Size bin_number = omp_get_max_threads();

double prev_counter(apex_peak.getIntensity() * apex_peak.getMZ());
double prev_denom(apex_peak.getIntensity());
#pragma omp parallel for num_threads(binnumber)
for (Size i = 0; i < binnumber; ++i)
Copy link

Choose a reason for hiding this comment

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

Suggested change
for (Size i = 0; i < binnumber; ++i)
for(Size i = 0; i < binnumber; ++i)

{
return a.intensity > b.intensity;
});
for (auto m_it = chrom_apices_2.cbegin(); m_it != chrom_apices_2.cend(); ++m_it) // iterate reverse from high intensity to low intensity
Copy link

Choose a reason for hiding this comment

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

Suggested change
for (auto m_it = chrom_apices_2.cbegin(); m_it != chrom_apices_2.cend(); ++m_it) // iterate reverse from high intensity to low intensity
for(auto m_it = chrom_apices_2.cbegin(); m_it != chrom_apices_2.cend(); ++m_it) // iterate reverse from high intensity to low intensity

Comment on lines 401 to 405
std::sort(chrom_apices_2.begin(), chrom_apices_2.end(), // sort by intensity
[](const Apex & a, const Apex & b) -> bool
{
return a.intensity > b.intensity;
});
Copy link

Choose a reason for hiding this comment

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

Suggested change
std::sort(chrom_apices_2.begin(), chrom_apices_2.end(), // sort by intensity
[](const Apex & a, const Apex & b) -> bool
{
return a.intensity > b.intensity;
});
std::sort(chrom_apices_2.begin(), chrom_apices_2.end(), // sort by intensity
[](const Apex & a, const Apex & b) -> bool
{
return a.intensity > b.intensity;
});

// Step 2.1 MOVE DOWN in RT dim
// *********************************************************** //
if ((trace_down_idx > 0) && toggle_down)
std::list<PeakType> current_trace;
Copy link

Choose a reason for hiding this comment

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

use std:.vector if possible

std::list<PeakType> current_trace;
double startint = work_exp[apex_scan_idx][apex_peak_idx].getIntensity();
current_trace.push_back(apex_peak);
std::vector<double> fwhms_mz; // peak-FWHM meta values of collected peaks
Copy link

Choose a reason for hiding this comment

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

what does the s mean in fwhms_mz?

double prev_counter(apex_peak.getIntensity() * apex_peak.getMZ());
double prev_denom(apex_peak.getIntensity());

updateIterativeWeightedMeanMZ(apex_peak.getMZ(), apex_peak.getIntensity(), centroid_mz, prev_counter, prev_denom);
Copy link

Choose a reason for hiding this comment

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

Suggested change
updateIterativeWeightedMeanMZ(apex_peak.getMZ(), apex_peak.getIntensity(), centroid_mz, prev_counter, prev_denom);
updateIterativeWeightedMeanMZ(centroid_mz, prev_denom, centroid_mz, prev_counter, prev_denom);

Copy link

Choose a reason for hiding this comment

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

why multiple inputs of the same thing

Comment on lines 476 to 478
while (((trace_down_idx > 0) && toggle_down) ||
((trace_up_idx < work_exp.size() - 1) && toggle_up)
)
Copy link

@maxvk79 maxvk79 May 5, 2023

Choose a reason for hiding this comment

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

Suggested change
while (((trace_down_idx > 0) && toggle_down) ||
((trace_up_idx < work_exp.size() - 1) && toggle_up)
)
while (trace_down_idx > 0 && toggle_down || trace_up_idx < work_exp.size() - 1 && toggle_up)

// *********************************************************** //
// Step 2.1 MOVE DOWN in RT dim
// *********************************************************** //
if ((trace_down_idx > 0) && toggle_down)
Copy link

Choose a reason for hiding this comment

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

Suggested change
if ((trace_down_idx > 0) && toggle_down)
if (trace_down_idx > 0 && toggle_down)

Comment on lines 494 to 497
if ((next_down_peak_mz <= right_bound) &&
(next_down_peak_mz >= left_bound) &&
!peak_visited_1[spec_offsets[trace_down_idx - 1] + next_down_peak_idx]
)
Copy link

Choose a reason for hiding this comment

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

Suggested change
if ((next_down_peak_mz <= right_bound) &&
(next_down_peak_mz >= left_bound) &&
!peak_visited_1[spec_offsets[trace_down_idx - 1] + next_down_peak_idx]
)
if (next_down_peak_mz <= right_bound &&
next_down_peak_mz >= left_bound &&
!peak_visited_1[spec_offsets[trace_down_idx - 1] + next_down_peak_idx])

// Update the m/z mean of the current trace as we added a new peak
updateIterativeWeightedMeanMZ(next_down_peak_mz, next_down_peak_int, centroid_mz, prev_counter, prev_denom);
gathered_idx.emplace_back(trace_down_idx - 1, next_down_peak_idx);
if(next_down_peak_int > startint)
Copy link

Choose a reason for hiding this comment

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

is this for debugging?

// *********************************************************** //
// Step 2.2 MOVE UP in RT dim
// *********************************************************** //
if ((trace_up_idx < work_exp.size() - 1) && toggle_up)
Copy link

Choose a reason for hiding this comment

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

Suggested change
if ((trace_up_idx < work_exp.size() - 1) && toggle_up)
if (trace_up_idx < work_exp.size() - 1 && toggle_up)

Comment on lines 577 to 579
if ((next_up_peak_mz <= right_bound) &&
(next_up_peak_mz >= left_bound) &&
!peak_visited_1[spec_offsets[trace_up_idx + 1] + next_up_peak_idx])
Copy link

Choose a reason for hiding this comment

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

Suggested change
if ((next_up_peak_mz <= right_bound) &&
(next_up_peak_mz >= left_bound) &&
!peak_visited_1[spec_offsets[trace_up_idx + 1] + next_up_peak_idx])
if (next_up_peak_mz <= right_bound &&
next_up_peak_mz >= left_bound &&
!peak_visited_1[spec_offsets[trace_up_idx + 1] + next_up_peak_idx])

Comment on lines 599 to 606
// Update the m/z variance dynamically
if (reestimate_mt_sd_) // && (up_hitting_peak+1 > min_flank_scans))
{
// if (ftl_t > min_fwhm_scans)
{
updateWeightedSDEstimateRobust(next_peak, centroid_mz, ftl_sd, intensity_so_far);
}
}
Copy link

@maxvk79 maxvk79 May 5, 2023

Choose a reason for hiding this comment

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

Suggested change
// Update the m/z variance dynamically
if (reestimate_mt_sd_) // && (up_hitting_peak+1 > min_flank_scans))
{
// if (ftl_t > min_fwhm_scans)
{
updateWeightedSDEstimateRobust(next_peak, centroid_mz, ftl_sd, intensity_so_far);
}
}
// Update the m/z variance dynamically
if (reestimate_mt_sd_)// && (up_hitting_peak+1 > min_flank_scans))
{
updateWeightedSDEstimateRobust(next_peak, centroid_mz, ftl_sd, intensity_so_far);
}

Copy link

@maxvk79 maxvk79 left a comment

Choose a reason for hiding this comment

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

Mainly checked for syntax and coding convention

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