diff --git a/.gitattributes b/.gitattributes index a98a2da..0d12bd7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,8 +2,8 @@ # Force UNIX line endings, so you can use the same repo e.g., on Win and WSL * text=auto eol=lf # batch files specifically need to have CRLF (win endings) -*.{cmd,[cC][mM][dD]} text eol=crlf -*.{bat,[bB][aA][tT]} text eol=crlf +*.[cC][mM][dD] text eol=crlf +*.[bB][aA][tT] text eol=crlf # Denote all files that are truly binary and should not be modified. # Images diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index d3cc722..a3c3557 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -114,7 +114,10 @@ runs: - name: Extract the PR Number or Branch Name id: pr shell: bash - run: echo "name=${{ github.event.pull_request && github.event.number || github.ref_name }}" >>"$GITHUB_OUTPUT" + # through env, not the script text: a branch name may contain shell syntax + env: + PR_OR_BRANCH: ${{ github.event.pull_request && github.event.number || github.ref_name }} + run: echo "name=$PR_OR_BRANCH" >>"$GITHUB_OUTPUT" ############################################################################ # Restore and save are separate steps so that every run saves a fresh cache @@ -230,10 +233,22 @@ runs: ############################################################################ - name: Test + id: test if: ${{ inputs.run_tests == 'true' }} shell: bash run: ctest --preset "${{ steps.preset.outputs.name }}" + ############################################################################ + # The files the failed tests wrote (*.tmp.csv, ...), to compare them with the + # expected ones without a local build. + - name: Upload the Test Outputs + if: ${{ failure() && steps.test.outcome == 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: test-outputs-${{ runner.os }}-${{ runner.arch }}-${{ inputs.compiler }} + path: build/${{ steps.preset.outputs.name }}/src/tests/topp/tmp_path + if-no-files-found: warn + ############################################################################ # Saved only when the build succeeded (a failed build would pin a partial # cache as the newest of the branch); test failures still save. diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 642ad10..f51dd60 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -3,8 +3,8 @@ name: "Nightly" # Every night OpenMS-MetaProSIP is built and tested against the current OpenMS # develop branch, built from source. The CI of OpenMS no longer compiles MetaProSIP, # so this is where a change of the OpenMS API that breaks MetaProSIP shows up. Each -# run also refreshes the cached build of OpenMS develop that the pull requests of -# this repository use. +# run also refreshes the cached build of OpenMS develop, which the pull requests of +# this repository use once OPENMS_CORE_DEFAULT_REF in test.yml is develop again. # # Triggers: # - schedule: the source build and tests against OpenMS develop. diff --git a/README.md b/README.md index ba16819..a0f71a5 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ MetaProSIP -in_mzML .mzML -in_fasta .fasta \ -out_csv .csv -out_peptide_centric_csv .csv ``` -`MetaProSIP --help` lists all parameters. The plots of the optional quality report are +`MetaProSIP --help` lists the common parameters, `MetaProSIP --helphelp` all of them (including the advanced ones such as `qc_output_directory`). The plots of the optional quality report are made with R (`-r_executable`, packages `gplots`), whose scripts MetaProSIP writes itself. ## Citation diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index efec68e..8689e4e 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -53,6 +53,10 @@ function(openms_metaprosip_test_environment) set(_env "OPENMS_DATA_PATH=${OPENMS_DATA_DIR}") if(OPENMS_METAPROSIP_TEST_REGISTRY_PATH AND NOT _arg_NO_REGISTRY) list(APPEND _env "OPENMS_TOOL_REGISTRY_PATH=${OPENMS_METAPROSIP_TEST_REGISTRY_PATH}") + else() + ## not one inherited from the environment of ctest either (e.g. exported for running the + ## build tree by hand): it would register MetaProSIP a second time + set_property(TEST ${_arg_UNPARSED_ARGUMENTS} APPEND PROPERTY ENVIRONMENT_MODIFICATION "OPENMS_TOOL_REGISTRY_PATH=unset:") endif() set_property(TEST ${_arg_UNPARSED_ARGUMENTS} APPEND PROPERTY ENVIRONMENT ${_env}) if(WIN32) diff --git a/src/tests/topp/CMakeLists.txt b/src/tests/topp/CMakeLists.txt index ff68b2b..9cf36c1 100644 --- a/src/tests/topp/CMakeLists.txt +++ b/src/tests/topp/CMakeLists.txt @@ -33,7 +33,7 @@ set(_diff_tests) # The generated tool registry (MetaProSIP.tsv) has to be something ToolHandler can # read, and carry every declared tool. #------------------------------------------------------------------------------ -add_test(NAME TOPP_tool_registry_is_readable +add_test(NAME TOPP_MetaProSIP_tool_registry_is_readable COMMAND ${CMAKE_COMMAND} -DREGISTRY_FILE=${OPENMS_TOOL_REGISTRY_BUILD_FILE} "-DTOOLS=${TOPP_TOOLS}" @@ -74,6 +74,28 @@ add_test(NAME "TOPP_MetaProSIP_3" COMMAND MetaProSIP -test -in_mzML ${DATA_DIR_T set_tests_properties("TOPP_MetaProSIP_3" PROPERTIES PASS_REGULAR_EXPRESSION "heatmap_bins;Out of valid range") ## negative wraps to a huge Size list(APPEND _tool_tests "TOPP_MetaProSIP_2" "TOPP_MetaProSIP_3") +# a second feature whose only identification has no hits is skipped: the results are those of test 1 +add_test(NAME "TOPP_MetaProSIP_4" COMMAND MetaProSIP -test -in_mzML ${DATA_DIR_TOPP}/MetaProSIP_1_input.mzML -in_fasta ${DATA_DIR_TOPP}/MetaProSIP_1_input.fasta -in_featureXML ${DATA_DIR_TOPP}/MetaProSIP_2_input.featureXML -out_csv ${TESTS_TEMP_DIR}/MetaProSIP_4_output_1.tmp.csv -out_peptide_centric_csv ${TESTS_TEMP_DIR}/MetaProSIP_4_output_2.tmp.csv) +list(APPEND _tool_tests "TOPP_MetaProSIP_4") +if(OPENMS_FUZZYDIFF) + add_test(NAME "TOPP_MetaProSIP_4_out1" COMMAND ${DIFF} -in1 ${TESTS_TEMP_DIR}/MetaProSIP_4_output_1.tmp.csv -in2 ${DATA_DIR_TOPP}/MetaProSIP_1_output_1.csv) + set_tests_properties("TOPP_MetaProSIP_4_out1" PROPERTIES DEPENDS "TOPP_MetaProSIP_4") + add_test(NAME "TOPP_MetaProSIP_4_out2" COMMAND ${DIFF} -in1 ${TESTS_TEMP_DIR}/MetaProSIP_4_output_2.tmp.csv -in2 ${DATA_DIR_TOPP}/MetaProSIP_1_output_2.csv) + set_tests_properties("TOPP_MetaProSIP_4_out2" PROPERTIES DEPENDS "TOPP_MetaProSIP_4") + list(APPEND _diff_tests "TOPP_MetaProSIP_4_out1" "TOPP_MetaProSIP_4_out2") +endif() + +# reject a negative merge window: the merge loops would start behind their end +add_test(NAME "TOPP_MetaProSIP_5" COMMAND MetaProSIP -test -in_mzML ${DATA_DIR_TOPP}/MetaProSIP_1_input.mzML -in_fasta ${DATA_DIR_TOPP}/MetaProSIP_1_input.fasta -in_featureXML ${DATA_DIR_TOPP}/MetaProSIP_1_input.featureXML -out_csv ${TESTS_TEMP_DIR}/MetaProSIP_5_output_1.tmp.csv -out_peptide_centric_csv ${TESTS_TEMP_DIR}/MetaProSIP_5_output_2.tmp.csv -weight_merge_window -1) +set_tests_properties("TOPP_MetaProSIP_5" PROPERTIES PASS_REGULAR_EXPRESSION "weight_merge_window;Out of valid range") +list(APPEND _tool_tests "TOPP_MetaProSIP_5") + +# averagine pseudo-features for the unidentified MS2 spectra of the input: with 18O labeling the +# decomposition read past the isotopic patterns (one per oxygen instead of one per isotopic trace) +add_test(NAME "TOPP_MetaProSIP_6" COMMAND MetaProSIP -test -in_mzML ${DATA_DIR_TOPP}/MetaProSIP_1_input.mzML -in_fasta ${DATA_DIR_TOPP}/MetaProSIP_1_input.fasta -in_featureXML ${DATA_DIR_TOPP}/MetaProSIP_1_input.featureXML -out_csv ${TESTS_TEMP_DIR}/MetaProSIP_6_output_1.tmp.csv -out_peptide_centric_csv ${TESTS_TEMP_DIR}/MetaProSIP_6_output_2.tmp.csv -use_averagine_ids -labeling_element O) +add_test(NAME "TOPP_MetaProSIP_7" COMMAND MetaProSIP -test -in_mzML ${DATA_DIR_TOPP}/MetaProSIP_1_input.mzML -in_fasta ${DATA_DIR_TOPP}/MetaProSIP_1_input.fasta -in_featureXML ${DATA_DIR_TOPP}/MetaProSIP_1_input.featureXML -out_csv ${TESTS_TEMP_DIR}/MetaProSIP_7_output_1.tmp.csv -out_peptide_centric_csv ${TESTS_TEMP_DIR}/MetaProSIP_7_output_2.tmp.csv -use_averagine_ids) +list(APPEND _tool_tests "TOPP_MetaProSIP_6" "TOPP_MetaProSIP_7") + openms_metaprosip_test_environment(${_tool_tests}) if(_diff_tests) ## FuzzyDiff is a tool of the core: no tool registry of this build diff --git a/src/tests/topp/MetaProSIP_1_output_1.csv b/src/tests/topp/MetaProSIP_1_output_1.csv index 084d9dc..84e179a 100644 --- a/src/tests/topp/MetaProSIP_1_output_1.csv +++ b/src/tests/topp/MetaProSIP_1_output_1.csv @@ -3,5 +3,5 @@ Group 1 # Distinct Peptides # Unambiguous Proteins Median Global LR median RIA 1 Protein Accession Description # Unique Peptides Median Global LR median RIA 1 median RIA 2 CONTIG23640_802236 length=2326 numreads=28 strand:-1 frame:0 orf_location:136:990 1 0.269627132474428 0.603333333333335 36.4733333333347 Peptide Sequence RT Exp. m/z Theo. m/z Charge Score TIC fraction #non-natural weights RIA 1 INT 1 Cor. 1 RIA 2 INT 2 Cor. 2 Peak intensities Global LR - YGGAVDPTVLGGVK 80.52 666.8623 666.861538013921 2 0.174659044235501 0.831887919884233 7 0.6 1432379 1.00 36.5 146376 0.87 659720 461384 165174 49177 14782 11728 6541 7410 10868 8404 9437 9556 10203 12619 12159 15831 16288 19847 19258 22222 21275 21576 21294 22006 24019 19046 17493 19060 17884 15631 15769 13964 14131 10090 9445 9216 7297 6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.269627132474428 + YGGAVDPTVLGGVK 80.52 666.8623 666.861538013921 2 0.174659044235501 0.825411844249652 7 0.6 1432379 1.00 36.5 134085 0.87 659720 461384 165174 49177 14782 11728 6541 7410 10868 8404 9437 9556 10203 12619 12159 15831 16288 19847 19258 22222 21275 21576 21294 22006 24019 19046 17493 19060 17884 15631 15769 13964 14131 10090 9445 9216 7297 6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.269627132474428 Non-Unique Peptides Accessions Peptide Sequence Descriptions Score RT Exp. m/z Theo. m/z Charge #non-natural weights Peak intensities Global LR diff --git a/src/tests/topp/MetaProSIP_1_output_2.csv b/src/tests/topp/MetaProSIP_1_output_2.csv index 6fc33ac..0d972c9 100644 --- a/src/tests/topp/MetaProSIP_1_output_2.csv +++ b/src/tests/topp/MetaProSIP_1_output_2.csv @@ -1,3 +1,3 @@ Peptide Sequence Feature Quality Report Spectrum Quality report scores Sample Name Protein Accessions Description Unique #Ambiguity members Score RT Exp. m/z Theo. m/z Charge TIC fraction #non-natural weights Peak intensities Group Global Peptide LR RIA 1 LR of RIA 1 INT 1 Cor. 1 RIA 2 LR of RIA 2 INT 2 Cor. 2 RIA 3 LR of RIA 3 INT 3 Cor. 3 RIA 4 LR of RIA 4 INT 4 Cor. 4 RIA 5 LR of RIA 5 INT 5 Cor. 5 RIA 6 LR of RIA 6 INT 6 Cor. 6 RIA 7 LR of RIA 7 INT 7 Cor. 7 RIA 8 LR of RIA 8 INT 8 Cor. 8 RIA 9 LR of RIA 9 INT 9 Cor. 9 RIA 10 LR of RIA 10 INT 10 Cor. 10 -YGGAVDPTVLGGVK feature test_mode_enabled.mzML CONTIG23640_802236 length=2326 numreads=28 strand:-1 frame:0 orf_location:136:990 1 1 0.174659044235501 80.52 666.8623 666.8615 2 0.831887919884232 7 659720 461384 165174 49177 14782 11728 6541 7410 10868 8404 9437 9556 10203 12619 12159 15831 16288 19847 19258 22222 21275 21576 21294 22006 24019 19046 17493 19060 17884 15631 15769 13964 14131 10090 9445 9216 7297 6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.269627132474428 0.6 1.0 1432378.6 1.0 36.5 0.0 146375.7 0.9 +YGGAVDPTVLGGVK feature test_mode_enabled.mzML CONTIG23640_802236 length=2326 numreads=28 strand:-1 frame:0 orf_location:136:990 1 1 0.174659044235501 80.52 666.8623 666.8615 2 0.825411844249652 7 659720 461384 165174 49177 14782 11728 6541 7410 10868 8404 9437 9556 10203 12619 12159 15831 16288 19847 19258 22222 21275 21576 21294 22006 24019 19046 17493 19060 17884 15631 15769 13964 14131 10090 9445 9216 7297 6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.269627132474428 0.6 1.0 1432378.6 1.0 36.5 0.0 134085.5 0.9 diff --git a/src/tests/topp/MetaProSIP_2_input.featureXML b/src/tests/topp/MetaProSIP_2_input.featureXML new file mode 100644 index 0000000..72aa430 --- /dev/null +++ b/src/tests/topp/MetaProSIP_2_input.featureXML @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4831.43346884947 + 666.862287171363 + 3.25608e+06 + 0 + 0 + 0.882314 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4831.43346884947 + 700.5 + 1.0e+05 + 0 + 0 + 0.5 + 2 + + + + + diff --git a/src/topp/MetaProSIP.cpp b/src/topp/MetaProSIP.cpp index 73c4f86..5530988 100644 --- a/src/topp/MetaProSIP.cpp +++ b/src/topp/MetaProSIP.cpp @@ -184,6 +184,13 @@ class MetaProSIP : { } + /// The documentation of MetaProSIP is not part of the OpenMS documentation (the default of + /// TOPPBase): MetaProSIP is developed and documented in its own repository. + std::string getDocumentationURL() const override + { + return "https://github.com/OpenMS/OpenMS-MetaProSIP"; + } + struct RateScorePair { double rate = -1.; @@ -512,7 +519,8 @@ class MetaProSIPReporting for (Size i = 0; i != binned_ria[0].size(); ++i) { - std::string label =StringUtils::toStr(i * (100 / binned_ria[0].size())) + "%-" + StringUtils::toStr((i + 1) * (100 / binned_ria[0].size())) + "%"; + const double bin_width = 100.0 / binned_ria[0].size(); + std::string label = StringUtils::toStr(std::lround(i * bin_width)) + "%-" + StringUtils::toStr(std::lround((i + 1) * bin_width)) + "%"; col_labels.push_back(label); } @@ -541,7 +549,8 @@ class MetaProSIPReporting if (file_extension == "png") { - current_script.addLine("png('" + tmp_path + "/" + filename + "', width=1000, height=" + StringUtils::toStr(10 * binned_ria.size()) + ")"); + // at least 200 pixels high, so that a heat map of one or a few peptides is readable + current_script.addLine("png('" + tmp_path + "/" + filename + "', width=1000, height=" + StringUtils::toStr(std::max(200, 10 * binned_ria.size())) + ")"); } else if (file_extension == "svg") { @@ -565,7 +574,19 @@ class MetaProSIPReporting std::string col_labels_string = StringUtils::concatenate(col_labels, "\",\""); + // heatmap.2 needs at least two rows and two columns (one peptide, or heatmap_bins 1): + // plot those with image() of base R instead + current_script.addLine("if (nrow(mdat) >= 2 && ncol(mdat) >= 2) {"); current_script.addLine(R"(heatmap.2(mdat, dendrogram="none", col=colorRampPalette(c("black","red")), Rowv=FALSE, Colv=FALSE, key=FALSE, labRow=)" + labRowString + ",labCol=c(\"" + col_labels_string + R"("),trace="none", density.info="none"))"); + current_script.addLine("} else {"); + current_script.addLine("par(mar=c(6,10,2,2))"); + current_script.addLine(R"(image(x=seq_len(ncol(mdat)), y=seq_len(nrow(mdat)), z=t(mdat), col=colorRampPalette(c("black","red"))(64), axes=FALSE, xlab="", ylab=""))"); + current_script.addLine("axis(1, at=seq_len(ncol(mdat)), labels=c(\"" + col_labels_string + "\"), las=2)"); + if (!row_labels.empty()) + { + current_script.addLine("axis(2, at=seq_len(nrow(mdat)), labels=" + labRowString + ", las=1)"); + } + current_script.addLine("}"); current_script.addLine("tmp<-dev.off()"); current_script.store(tmp_path + "/" + script_filename); @@ -1369,12 +1390,18 @@ class MetaProSIPDecomposition Matrix basis_matrix(isotopic_intensities.size(), n_bins); + if (patterns.size() < n_bins) + { + throw Exception::InvalidSize(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, patterns.size(), + "fewer isotopic patterns than rate bins of the decomposition (" + StringUtils::toStr(n_bins) + ")"); + } + for (Size row = 0; row != isotopic_intensities.size(); ++row) { for (Size col = 0; col != n_bins; ++col) { const vector& pattern = patterns[col].second; - if (row <= n_bins) + if (row <= n_bins && row < pattern.size()) { basis_matrix(row, col) = pattern[row]; } @@ -1417,10 +1444,10 @@ class MetaProSIPDecomposition S_err += pow(isotopic_intensities[row] - predicted, 2); } - for (Size row = 0; row != 5; ++row) + for (Size row = 0; row != std::min(5, isotopic_intensities.size()); ++row) { double predicted = 0; - for (Size col = 0; col != 3; ++col) + for (Size col = 0; col != std::min(3, n_bins); ++col) { predicted += basis_matrix(row, col) * beta(col, 0); } @@ -1849,7 +1876,10 @@ class MetaProSIPDecomposition // calculate isotope distribution for a given peptide and varying incoperation rates // modification of isotope distribution in static ElementDB - for (double abundance = 0.0; abundance < 100.0 - 1e-8; abundance += 100.0 / (double)element_count) + // one pattern per isotopic trace, i.e. two per oxygen (18O is 2 Da heavier than 16O), as in + // calculateIsotopePatternsFor18ORange: the decomposition and the correlation use 2 * element_count + // rate bins for oxygen + for (double abundance = 0.0; abundance < 100.0 - 1e-8; abundance += 100.0 / (2.0 * element_count)) { double a = abundance / 100.0; IsotopeDistribution isotopes; @@ -2013,28 +2043,20 @@ class RIntegration } OPENMS_LOG_INFO << " success" << std::endl; } - // check dependencies - OPENMS_LOG_INFO << "Checking R dependencies. If package is not found we will try to install it in your temp directory..."; + // check dependencies. Missing packages are reported, never installed: installing would + // download and run code (and update unrelated packages) as a side effect of a QC report. + OPENMS_LOG_INFO << "Checking R dependencies..."; TextFile current_script; - current_script.addLine("LoadOrInstallPackage <-function(x)"); - current_script.addLine("{"); - current_script.addLine(" x <-as.character(substitute(x))"); - current_script.addLine(" if (isTRUE(x %in%.packages(all.available = TRUE)))"); - current_script.addLine(" {"); - current_script.addLine(" eval(parse(text = paste(\"library(\", x, \")\", sep = \"\")))"); - current_script.addLine(" }"); - current_script.addLine(" else"); - current_script.addLine(" {"); - current_script.addLine(" options(repos = structure(c(CRAN = \"http://cran.rstudio.com/\")))"); - current_script.addLine(" update.packages()"); - current_script.addLine(" eval(parse(text = paste(\"install.packages('\", x, \"')\", sep = \"\")))"); - current_script.addLine(" eval(parse(text = paste(\"library(\", x, \")\", sep = \"\")))"); - current_script.addLine(" }"); - current_script.addLine("}"); + current_script.addLine("missing <- character(0)"); for (StringList::const_iterator it = package_names.begin(); it != package_names.end(); ++it) { - current_script.addLine("LoadOrInstallPackage(" + *it + ")"); + current_script.addLine("if (!requireNamespace(\"" + *it + "\", quietly = TRUE)) missing <- c(missing, \"" + *it + "\")"); } + current_script.addLine("if (length(missing) > 0)"); + current_script.addLine("{"); + current_script.addLine(" message(\"Missing R packages: \", paste(missing, collapse = \", \"), \". Install them in R, e.g. install.packages(c(\\\"\", paste(missing, collapse = \"\\\", \\\"\"), \"\\\")).\")"); + current_script.addLine(" quit(status = 1)"); + current_script.addLine("}"); current_script.store(script_filename); @@ -2043,7 +2065,7 @@ class RIntegration if (state != ExternalProcess::RETURNSTATE::SUCCESS) { - OPENMS_LOG_ERROR << "\nProblem finding all R dependencies. Check if R and following libraries are installed:" << std::endl; + OPENMS_LOG_ERROR << "\nProblem finding all R dependencies. Check if R and the following libraries are installed (" << StringUtils::concatenate(package_names, ", ") << "):" << std::endl; for (TextFile::ConstIterator line_it = current_script.begin(); line_it != current_script.end(); ++line_it) { OPENMS_LOG_ERROR << *line_it << std::endl; @@ -2121,6 +2143,7 @@ class RIntegration registerDoubleOption_("decomposition_threshold", "", 0.7, "Minimum R-squared of decomposition that must be achieved for a peptide to be reported.", false, true); registerDoubleOption_("weight_merge_window", "", 5.0, "Decomposition coefficients within +- this rate window will be combined", false, true); + setMinFloat_("weight_merge_window", 0.0); registerDoubleOption_("min_correlation_distance_to_averagine", "", -1.0, "Minimum difference in correlation between incorporation pattern and averagine pattern. Positive values filter all RIAs passing the correlation threshold but that also show a better correlation to an averagine peptide. Disabled for values <= -1", false, true); @@ -2339,8 +2362,11 @@ class RIntegration } } - // remove correlations with only very few peaks - if ((double)zeros / (double)std::distance(intensities_begin, intensities_end) > min_observed_peak_fraction) + // remove correlations with only very few peaks: the fraction of observed (non-zero) peaks + // of the pattern must reach observed_peak_fraction; an empty window has none + const Size n_peaks = std::distance(intensities_begin, intensities_end); + const double observed_fraction = n_peaks == 0 ? 0.0 : 1.0 - (double)zeros / (double)n_peaks; + if (observed_fraction < min_observed_peak_fraction) { map_rate_to_correlation_score[rate] = 0; continue; @@ -2591,7 +2617,7 @@ class RIntegration for (Size i = 1; i <= n_scans; ++i) { double rt_after = max_trace_int_rt; - if (max_trace_int_idx < mono_trace.size() - (Int)i) + if (max_trace_int_idx + i < mono_trace.size()) { rt_after = mono_trace[max_trace_int_idx + i].getRT(); } @@ -2675,16 +2701,12 @@ class RIntegration double int_sum = 0; MapRateToScoreType::const_iterator low = map_rate_to_decomposition_weight.lower_bound(rate - weight_merge_window - 1e-4); MapRateToScoreType::const_iterator high = map_rate_to_decomposition_weight.lower_bound(rate + weight_merge_window + 1e-4); + // [low, high) holds the coefficients within +- weight_merge_window (1e-4 tolerance) for (; low != high; ++low) { int_sum += low->second; } - if (low != map_rate_to_decomposition_weight.end()) - { - int_sum += low->second; - } - sip_incorporation.abundance = int_sum; // calculate abundance as sum of all decompositions sip_incorporation.correlation = min(corr, 1.0); @@ -2857,17 +2879,13 @@ class RIntegration } // Sum up decomposition intensities for quantification in merge window + // [low, high) holds the coefficients within +- weight_merge_window (1e-4 tolerance) double int_sum = 0; for (; low != high; ++low) { int_sum += low->second; } - if (low != map_rate_to_decomposition_weight.end()) - { - int_sum += low->second; - } - sip_incorporation.abundance = int_sum; MapRateToScoreType::const_iterator corr_it = map_rate_to_correlation_score.lower_bound(rate - 1e-6); sip_incorporation.correlation = min(corr_it->second, 1.0); @@ -3251,6 +3269,12 @@ class RIntegration } } + // all identifications of this feature had empty hit lists + if (tmp_pepid.getHits().empty()) + { + continue; + } + tmp_pepid.sort(); SIPPeptide sip_peptide;