diff --git a/src/openms/source/CHEMISTRY/MASSDECOMPOSITION/IMS/IMSAlphabet.cpp b/src/openms/source/CHEMISTRY/MASSDECOMPOSITION/IMS/IMSAlphabet.cpp index 5ebaeb8fe2a..392140c504b 100644 --- a/src/openms/source/CHEMISTRY/MASSDECOMPOSITION/IMS/IMSAlphabet.cpp +++ b/src/openms/source/CHEMISTRY/MASSDECOMPOSITION/IMS/IMSAlphabet.cpp @@ -41,12 +41,9 @@ #include #include -namespace OpenMS +namespace OpenMS::ims { - namespace ims - { - const IMSAlphabet::name_type & IMSAlphabet::getName(size_type index) const { return getElement(index).getName(); @@ -174,5 +171,4 @@ namespace OpenMS return os; } - } // namespace ims -} // namespace OpenMS +} // namespace OpenMS // namespace ims diff --git a/src/openms/source/COMPARISON/SPECTRA/BinnedSpectrum.cpp b/src/openms/source/COMPARISON/SPECTRA/BinnedSpectrum.cpp index c94d1127a65..9b086e5de33 100644 --- a/src/openms/source/COMPARISON/SPECTRA/BinnedSpectrum.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/BinnedSpectrum.cpp @@ -81,7 +81,10 @@ namespace OpenMS { OPENMS_PRECONDITION(ps.isSorted(), "Spectrum needs to be sorted by m/z."); - if (ps.empty()) { return; } + if (ps.empty()) + { + return; + } bins_ = EmptySparseVector; @@ -120,15 +123,20 @@ namespace OpenMS } // efficient look-up of number of non-zero entries, so we use this as-well - if (bins_.nonZeros() != rhs.bins_.nonZeros()) { return false; } + if (bins_.nonZeros() != rhs.bins_.nonZeros()) + { + return false; + } // test non-sparse (non-zero) elements for equality SparseVectorIteratorType it(bins_); SparseVectorIteratorType rhs_it(rhs.bins_); while (it) { - if (it.index() != rhs_it.index() - || it.value() != rhs_it.value()) { return false; } + if (it.index() != rhs_it.index() || it.value() != rhs_it.value()) + { + return false; + } ++it; ++rhs_it; } diff --git a/src/openms/source/COMPARISON/SPECTRA/PeakAlignment.cpp b/src/openms/source/COMPARISON/SPECTRA/PeakAlignment.cpp index 6caddb4a2fe..ec995e1c8aa 100644 --- a/src/openms/source/COMPARISON/SPECTRA/PeakAlignment.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/PeakAlignment.cpp @@ -85,10 +85,14 @@ namespace OpenMS // shortcut similarity calculation by comparing PrecursorPeaks (PrecursorPeaks more than delta away from each other are supposed to be from another peptide) double pre_mz1 = 0.0; if (!spec1.getPrecursors().empty()) + { pre_mz1 = spec1.getPrecursors()[0].getMZ(); + } double pre_mz2 = 0.0; if (!spec2.getPrecursors().empty()) + { pre_mz2 = spec2.getPrecursors()[0].getMZ(); + } if (fabs(pre_mz1 - pre_mz2) > (double)param_.getValue("precursor_mass_tolerance")) { return 0; diff --git a/src/openms/source/COMPARISON/SPECTRA/SpectrumAlignmentScore.cpp b/src/openms/source/COMPARISON/SPECTRA/SpectrumAlignmentScore.cpp index 87bfd8dad25..07255de7fcf 100644 --- a/src/openms/source/COMPARISON/SPECTRA/SpectrumAlignmentScore.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/SpectrumAlignmentScore.cpp @@ -97,11 +97,16 @@ namespace OpenMS // calculate sum of squared intensities double sum1(0); - for (auto const & p : s1) { sum1 += pow(p.getIntensity(), 2); } + for (auto const & p : s1) + { + sum1 += pow(p.getIntensity(), 2); + } double sum2(0); - for (auto const & p : s2) { sum2 += pow(p.getIntensity(), 2); } - + for (auto const & p : s2) + { + sum2 += pow(p.getIntensity(), 2); + } for (auto const & ap : alignment) { const double mz_tolerance = is_relative_tolerance ? tolerance * s1[ap.first].getMZ() * 1e-6 : tolerance; diff --git a/src/openms/source/COMPARISON/SPECTRA/SpectrumCheapDPCorr.cpp b/src/openms/source/COMPARISON/SPECTRA/SpectrumCheapDPCorr.cpp index e1b9635c7d0..d5b397d4ff0 100644 --- a/src/openms/source/COMPARISON/SPECTRA/SpectrumCheapDPCorr.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/SpectrumCheapDPCorr.cpp @@ -111,9 +111,13 @@ namespace OpenMS lastconsensus_ = PeakSpectrum(); Precursor p1, p2; if (!x.getPrecursors().empty()) + { p1 = x.getPrecursors()[0]; + } if (!y.getPrecursors().empty()) + { p2 = y.getPrecursors()[0]; + } lastconsensus_.getPrecursors().resize(1); lastconsensus_.getPrecursors()[0].setMZ((p1.getMZ() + p2.getMZ()) / 2); lastconsensus_.getPrecursors()[0].setCharge(p1.getCharge()); @@ -174,9 +178,13 @@ namespace OpenMS yrun++; } if (xit + xrun == x.end()) + { break; + } if (yit + yrun == y.end()) + { break; + } } //dynamic programming necessary to calculate optimal pairing @@ -292,7 +300,9 @@ namespace OpenMS consensuspeak.setMZ(x[xstart + i - 1].getMZ()); consensuspeak.setIntensity((x[xstart + i - 1].getIntensity()) * (1 - factor_)); if (keeppeaks_) + { lastconsensus_.push_back(consensuspeak); + } i--; } else if (trace[i][j] == -1) @@ -301,11 +311,15 @@ namespace OpenMS consensuspeak.setMZ(y[ystart + j - 1].getMZ()); consensuspeak.setIntensity((y[ystart + j - 1].getIntensity()) * factor_); if (keeppeaks_) + { lastconsensus_.push_back(consensuspeak); + } j--; } if (!i || !j) + { break; + } } return dparray[xend - xstart + 1][yend - ystart + 1]; diff --git a/src/openms/source/COMPARISON/SPECTRA/SpectrumPrecursorComparator.cpp b/src/openms/source/COMPARISON/SPECTRA/SpectrumPrecursorComparator.cpp index 2e8e89954d7..0a082743dfa 100644 --- a/src/openms/source/COMPARISON/SPECTRA/SpectrumPrecursorComparator.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/SpectrumPrecursorComparator.cpp @@ -78,10 +78,14 @@ namespace OpenMS double mz1 = 0.0; if (!x.getPrecursors().empty()) + { mz1 = x.getPrecursors()[0].getMZ(); + } double mz2 = 0.0; if (!y.getPrecursors().empty()) + { mz2 = y.getPrecursors()[0].getMZ(); + } if (fabs(mz1 - mz2) > window) { diff --git a/src/openms/source/COMPARISON/SPECTRA/SteinScottImproveScore.cpp b/src/openms/source/COMPARISON/SPECTRA/SteinScottImproveScore.cpp index e8bfc9fe321..9d995d999f9 100644 --- a/src/openms/source/COMPARISON/SPECTRA/SteinScottImproveScore.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/SteinScottImproveScore.cpp @@ -103,16 +103,16 @@ namespace OpenMS std::cout << std::endl; std::cout << s2 << std::endl;*/ - for (PeakSpectrum::ConstIterator it1 = s1.begin(); it1 != s1.end(); ++it1) + for (const Peak1D& it1 : s1) { - double temp = it1->getIntensity(); + double temp = it1.getIntensity(); sum1 += temp * temp; sum3 += temp; } - for (PeakSpectrum::ConstIterator it1 = s2.begin(); it1 != s2.end(); ++it1) + for (const Peak1D& it1 : s2) { - double temp = it1->getIntensity(); + double temp = it1.getIntensity(); sum2 += temp * temp; sum4 += temp; } diff --git a/src/openms/source/COMPARISON/SPECTRA/ZhangSimilarityScore.cpp b/src/openms/source/COMPARISON/SPECTRA/ZhangSimilarityScore.cpp index 1734b3d8053..38e4f6c5676 100644 --- a/src/openms/source/COMPARISON/SPECTRA/ZhangSimilarityScore.cpp +++ b/src/openms/source/COMPARISON/SPECTRA/ZhangSimilarityScore.cpp @@ -93,9 +93,9 @@ namespace OpenMS throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION); } - for (PeakSpectrum::ConstIterator it1 = s1.begin(); it1 != s1.end(); ++it1) + for (const Peak1D& it1 : s1) { - sum1 += it1->getIntensity(); + sum1 += it1.getIntensity(); /* for (PeakSpectrum::ConstIterator it2 = s1.begin(); it2 != s1.end(); ++it2) { @@ -158,9 +158,9 @@ for (PeakSpectrum::ConstIterator it2 = s1.begin(); it2 != s1.end(); ++it2) } }*/ - for (PeakSpectrum::ConstIterator it1 = s2.begin(); it1 != s2.end(); ++it1) + for (const Peak1D& it1 : s2) { - sum2 += it1->getIntensity(); + sum2 += it1.getIntensity(); /* for (PeakSpectrum::ConstIterator it2 = s2.begin(); it2 != s2.end(); ++it2) { diff --git a/src/openms/source/CONCEPT/ClassTest.cpp b/src/openms/source/CONCEPT/ClassTest.cpp index 07481f7d80d..2f309c951d5 100644 --- a/src/openms/source/CONCEPT/ClassTest.cpp +++ b/src/openms/source/CONCEPT/ClassTest.cpp @@ -55,12 +55,9 @@ #include -namespace OpenMS +namespace OpenMS::Internal::ClassTest { - namespace Internal - { - namespace ClassTest - { + bool all_tests = true; bool equal_files; bool newline = false; @@ -91,10 +88,6 @@ namespace OpenMS std::vector tmp_file_list; std::vector failed_lines_list; StringList whitelist; - } - - namespace ClassTest - { void mainInit(const char* version, const char* class_name, int argc, const char* argv0) { @@ -443,8 +436,7 @@ namespace OpenMS } } - bool - isRealSimilar(long double number_1, long double number_2) + bool isRealSimilar(long double number_1, long double number_2) { // Note: The original version of the stuff below was copied from // FuzzyStringComparator and then heavily modified for ClassTest. @@ -571,8 +563,7 @@ namespace OpenMS } } - void - testStringEqual(const char* /*file*/, int line, + void testStringEqual(const char* /*file*/, int line, const std::string& string_1, const char* string_1_stringified, const std::string& string_2, @@ -684,7 +675,4 @@ namespace OpenMS return result; } - - } - } } diff --git a/src/openms/source/CONCEPT/FuzzyStringComparator.cpp b/src/openms/source/CONCEPT/FuzzyStringComparator.cpp index 2b7df499e8f..b827271a6ed 100644 --- a/src/openms/source/CONCEPT/FuzzyStringComparator.cpp +++ b/src/openms/source/CONCEPT/FuzzyStringComparator.cpp @@ -300,8 +300,10 @@ namespace OpenMS bool FuzzyStringComparator::compareLines_(std::string const& line_str_1, std::string const& line_str_2) { // in most cases, results will be identical. If not, do the expensive fuzzy compare - if (line_str_1 == line_str_2) return true; - + if (line_str_1 == line_str_2) + { + return true; + } for (StringList::const_iterator slit = whitelist_.begin(); slit != whitelist_.end(); ++slit) { @@ -350,8 +352,10 @@ namespace OpenMS #ifdef DEBUG_FUZZY std::cout << "cmp number: " << String(element_1_.number) << " : " << String(element_2_.number) << std::endl; #endif - if (element_1_.number == element_2_.number) continue; - + if (element_1_.number == element_2_.number) + { + continue; + } // check if absolute difference is small double absdiff = element_1_.number - element_2_.number; if (absdiff < 0) @@ -666,7 +670,9 @@ namespace OpenMS wlcit != whitelist_cases_.end(); ++wlcit) { if (wlcit->first.size() > length) + { length = wlcit->first.size(); + } } for (std::map::const_iterator wlcit = whitelist_cases_.begin(); wlcit != whitelist_cases_.end(); ++wlcit) diff --git a/src/openms/source/CONCEPT/GlobalExceptionHandler.cpp b/src/openms/source/CONCEPT/GlobalExceptionHandler.cpp index edeb7d9b728..d6a1e0cc27d 100644 --- a/src/openms/source/CONCEPT/GlobalExceptionHandler.cpp +++ b/src/openms/source/CONCEPT/GlobalExceptionHandler.cpp @@ -53,12 +53,9 @@ #define OPENMS_CORE_DUMP_ENVNAME "OPENMS_DUMP_CORE" -namespace OpenMS +namespace OpenMS::Exception { - namespace Exception - { - GlobalExceptionHandler::GlobalExceptionHandler() throw() { std::set_terminate(terminate); @@ -143,6 +140,5 @@ namespace OpenMS GlobalExceptionHandler::line_() = line; } - } // namespace Exception -} // namespace OpenMS +} // namespace OpenMS // namespace Exception diff --git a/src/openms/source/CONCEPT/Init.cpp b/src/openms/source/CONCEPT/Init.cpp index 888851fa582..6c7e9c0bb88 100644 --- a/src/openms/source/CONCEPT/Init.cpp +++ b/src/openms/source/CONCEPT/Init.cpp @@ -36,28 +36,25 @@ #include -namespace OpenMS +namespace OpenMS::Internal { - namespace Internal - { - // Initialize xerces - // see ticket #352 for more details - struct xerces_init + // Initialize xerces + // see ticket #352 for more details + struct xerces_init + { + xerces_init() { - xerces_init() - { - xercesc::XMLPlatformUtils::Initialize(); - } + xercesc::XMLPlatformUtils::Initialize(); + } - ~xerces_init() - { - xercesc::XMLPlatformUtils::Terminate(); - } + ~xerces_init() + { + xercesc::XMLPlatformUtils::Terminate(); + } - }; - const xerces_init xinit; + }; + const xerces_init xinit; - } -} +} //OpenMS //Internal diff --git a/src/openms/source/CONCEPT/LogStream.cpp b/src/openms/source/CONCEPT/LogStream.cpp index 88cb537fd42..78b1c47d335 100644 --- a/src/openms/source/CONCEPT/LogStream.cpp +++ b/src/openms/source/CONCEPT/LogStream.cpp @@ -82,7 +82,9 @@ namespace OpenMS { clearCache(); if (incomplete_line_.size() > 0) + { distribute_(incomplete_line_); + } delete[] pbuf_; pbuf_ = nullptr; } @@ -293,8 +295,9 @@ namespace OpenMS // send outline (and extra_message) to attached streams if (!extra_message.empty()) + { distribute_(extra_message); - + } distribute_(outstring); } @@ -413,8 +416,9 @@ namespace OpenMS { if (registered_at_ == nullptr) + { return; - + } registered_at_->remove(stream_); registered_at_ = nullptr; } @@ -479,8 +483,9 @@ namespace OpenMS void LogStream::insertNotification(std::ostream & s, LogStreamNotifier & target) { if (!bound_()) + { return; - + } insert(s); StreamIterator it = findStream_(s); @@ -504,16 +509,18 @@ namespace OpenMS bool LogStream::hasStream_(std::ostream & stream) { if (!bound_()) + { return false; - + } return findStream_(stream) != rdbuf()->stream_list_.end(); } void LogStream::setPrefix(const std::ostream & s, const string & prefix) { if (!bound_()) + { return; - + } StreamIterator it = findStream_(s); if (it != rdbuf()->stream_list_.end()) { @@ -524,8 +531,9 @@ namespace OpenMS void LogStream::setPrefix(const string & prefix) { if (!bound_()) + { return; - + } for (StreamIterator it = rdbuf()->stream_list_.begin(); it != rdbuf()->stream_list_.end(); ++it) { (*it).prefix = prefix; diff --git a/src/openms/source/CONCEPT/ProgressLogger.cpp b/src/openms/source/CONCEPT/ProgressLogger.cpp index d23636f8903..357019b2e9b 100644 --- a/src/openms/source/CONCEPT/ProgressLogger.cpp +++ b/src/openms/source/CONCEPT/ProgressLogger.cpp @@ -174,11 +174,17 @@ namespace OpenMS switch (type) { case NONE: + { return "NONE"; + } case CMD: + { return "CMD"; + } case GUI: + { return "GUI"; + } } // should never happen but gcc emits a warning/error @@ -205,7 +211,10 @@ namespace OpenMS ProgressLogger& ProgressLogger::operator=(const ProgressLogger& other) { - if (&other == this) return *this; + if (&other == this) + { + return *this; + } this->last_invoke_ = other.last_invoke_; this->type_ = other.type_; @@ -249,8 +258,10 @@ namespace OpenMS void ProgressLogger::setProgress(SignedSize value) const { // update only if at least 1 second has passed - if (last_invoke_ == time(nullptr)) return; - + if (last_invoke_ == time(nullptr)) + { + return; + } last_invoke_ = time(nullptr); current_logger_->setProgress(value, recursion_depth_); } @@ -258,7 +269,10 @@ namespace OpenMS { auto p = current_logger_->nextProgress(); // update only if at least 1 second has passed - if (last_invoke_ == time(nullptr)) return; + if (last_invoke_ == time(nullptr)) + { + return; + } last_invoke_ = time(nullptr); current_logger_->setProgress(p, recursion_depth_); diff --git a/src/openms/source/CONCEPT/Types.cpp b/src/openms/source/CONCEPT/Types.cpp index a6b879157ca..b3d82fd8e00 100644 --- a/src/openms/source/CONCEPT/Types.cpp +++ b/src/openms/source/CONCEPT/Types.cpp @@ -35,10 +35,7 @@ #include #include -namespace OpenMS +namespace OpenMS::Internal { - namespace Internal - { - const char * OpenMS_locale = setlocale(LC_ALL, "C"); - } -} + const char * OpenMS_locale = setlocale(LC_ALL, "C"); +} // OpenMS // Internal diff --git a/src/openms/source/CONCEPT/UniqueIdInterface.cpp b/src/openms/source/CONCEPT/UniqueIdInterface.cpp index e77cbe91302..f78030df9f0 100644 --- a/src/openms/source/CONCEPT/UniqueIdInterface.cpp +++ b/src/openms/source/CONCEPT/UniqueIdInterface.cpp @@ -37,8 +37,7 @@ namespace OpenMS { - void - UniqueIdInterface::setUniqueId(const String & rhs) + void UniqueIdInterface::setUniqueId(const String & rhs) { clearUniqueId(); diff --git a/src/openms/source/DATASTRUCTURES/Compomer.cpp b/src/openms/source/DATASTRUCTURES/Compomer.cpp index 127e49e449a..d805f13084e 100644 --- a/src/openms/source/DATASTRUCTURES/Compomer.cpp +++ b/src/openms/source/DATASTRUCTURES/Compomer.cpp @@ -237,16 +237,18 @@ namespace OpenMS String Compomer::getAdductsAsString(UInt side) const { if (side >= BOTH) + { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Compomer::getAdductsAsString() does not support this value for 'side'!", String(side)); - + } String r; for (const auto& [formula, adduct] : cmp_[side]) { Int f = adduct.getAmount(); if (formula.has('+')) + { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "An Adduct contains implicit charge. This is not allowed!", formula); - + } EmpiricalFormula ef(formula); ef = ef * f; r += ef.toString(); @@ -258,8 +260,9 @@ namespace OpenMS bool Compomer::isSingleAdduct(Adduct& a, const UInt side) const { if (side >= BOTH) + { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Compomer::isSimpleAdduct() does not support this value for 'side'!", String(side)); - + } if (cmp_[side].size() != 1) { return false; @@ -281,8 +284,9 @@ namespace OpenMS Compomer Compomer::removeAdduct(const Adduct& a, const UInt side) const { if (side >= BOTH) + { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Compomer::removeAdduct() does not support this value for 'side'!", String(side)); - + } Compomer tmp(*this); if (tmp.cmp_[side].count(a.getFormula()) > 0) { @@ -307,8 +311,9 @@ namespace OpenMS StringList Compomer::getLabels(const UInt side) const { if (side >= BOTH) + { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Compomer::getLabels() does not support this value for 'side'!", String(side)); - + } StringList tmp; for (CompomerSide::const_iterator it = this->cmp_[side].begin(); it != this->cmp_[side].end(); ++it) diff --git a/src/openms/source/DATASTRUCTURES/ConvexHull2D.cpp b/src/openms/source/DATASTRUCTURES/ConvexHull2D.cpp index db63e356026..c20e9a89265 100644 --- a/src/openms/source/DATASTRUCTURES/ConvexHull2D.cpp +++ b/src/openms/source/DATASTRUCTURES/ConvexHull2D.cpp @@ -244,8 +244,9 @@ namespace OpenMS } compressed_map[middle_it->first] = middle_it->second; // copy last scan if (succ_it != map_points_.end()) + { throw Exception::BufferOverflow(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION); - + } //std::cout << "compressed CH from " << map_points_.size() << " to " << compressed_map.size() << "\n"; Size saved_points = map_points_.size() - compressed_map.size(); //copy diff --git a/src/openms/source/FILTERING/CALIBRATION/InternalCalibration.cpp b/src/openms/source/FILTERING/CALIBRATION/InternalCalibration.cpp index 1a5b007cf36..af2606f0c89 100644 --- a/src/openms/source/FILTERING/CALIBRATION/InternalCalibration.cpp +++ b/src/openms/source/FILTERING/CALIBRATION/InternalCalibration.cpp @@ -145,7 +145,10 @@ namespace OpenMS Size s_left = it->findNearest(mz_iso_left); if (Math::getPPMAbs(mz_iso_left, (*it)[s_left].getMZ()) < 0.5) // intra-scan ppm should be very good! { // peak nearby lock mass was not the monoisotopic - if (verbose) OPENMS_LOG_INFO << "peak at [RT, m/z] " << it->getRT() << ", " << (*it)[s].getMZ() << " is NOT monoisotopic. Skipping it!\n"; + if (verbose) + { + OPENMS_LOG_INFO << "peak at [RT, m/z] " << it->getRT() << ", " << (*it)[s].getMZ() << " is NOT monoisotopic. Skipping it!\n"; + } failed_lock_masses.insertCalibrationPoint(it->getRT(), itl->mz, 1.0, itl->mz, 0.0, std::distance(ref_masses.begin(), itl)); continue; } @@ -157,7 +160,10 @@ namespace OpenMS Size s_right = it->findNearest(mz_iso_right); if (!(Math::getPPMAbs(mz_iso_right, (*it)[s_right].getMZ()) < 0.5)) // intra-scan ppm should be very good! { // peak has no +1iso.. weird - if (verbose) OPENMS_LOG_INFO << "peak at [RT, m/z] " << it->getRT() << ", " << (*it)[s].getMZ() << " has no +1 isotope (ppm to closest: " << Math::getPPM(mz_iso_right, (*it)[s_right].getMZ()) << ")... Skipping it!\n"; + if (verbose) + { + OPENMS_LOG_INFO << "peak at [RT, m/z] " << it->getRT() << ", " << (*it)[s].getMZ() << " has no +1 isotope (ppm to closest: " << Math::getPPM(mz_iso_right, (*it)[s_right].getMZ()) << ")... Skipping it!\n"; + } failed_lock_masses.insertCalibrationPoint(it->getRT(), itl->mz, 2.0, itl->mz, 0.0, std::distance(ref_masses.begin(), itl)); continue; } @@ -261,8 +267,14 @@ namespace OpenMS double delta = Math::getPPMAbs(mz_obs, mz_ref); if (tol_ppm < delta) { - if (stats.cnt_decal < 10) OPENMS_LOG_INFO << "Peptide " << pid.getHits()[0].getSequence().toString() << " is " << delta << " (>" << tol_ppm << ") ppm away from theoretical mass and is omitted as calibration point.\n"; - else if (stats.cnt_decal == 10) OPENMS_LOG_INFO << "More than 10 peptides are at least " << tol_ppm << " ppm away from theoretical mass and are omitted as calibration point."; + if (stats.cnt_decal < 10) + { + OPENMS_LOG_INFO << "Peptide " << pid.getHits()[0].getSequence().toString() << " is " << delta << " (>" << tol_ppm << ") ppm away from theoretical mass and is omitted as calibration point.\n"; + } + else if (stats.cnt_decal == 10) + { + OPENMS_LOG_INFO << "More than 10 peptides are at least " << tol_ppm << " ppm away from theoretical mass and are omitted as calibration point."; + } ++stats.cnt_decal; return true; } @@ -439,9 +451,18 @@ namespace OpenMS for (Size i = 0; i < tms.size(); ++i) { sv << tms[i].getRT() << tms[i].toString(); - if (!MZTrafoModel::isValidModel(tms[i])) sv << "invalid"; // this only happens if ALL models are invalid (since otherwise they would use 'neighbour') - else if (invalid_models.count(i) > 0) sv << "neighbor"; - else sv << "local"; + if (!MZTrafoModel::isValidModel(tms[i])) + { + sv << "invalid"; // this only happens if ALL models are invalid (since otherwise they would use 'neighbour') + } + else if (invalid_models.count(i) > 0) + { + sv << "neighbor"; + } + else + { + sv << "local"; + } sv << nl; } } @@ -473,8 +494,11 @@ namespace OpenMS std::vector vec_ppm_before, vec_ppm_after; vec_ppm_before.reserve(cal_data_.size()); vec_ppm_after.reserve(cal_data_.size()); - if (sv != nullptr) *sv << "# residual error after calibration" << nl + if (sv != nullptr) + { + *sv << "# residual error after calibration" << nl << "RT" << "intensity" << "mz ref" << "mz before" << "mz after" << "ppm before" << "ppm after" << nl; + } Size ii(0); for (CalibrationData::const_iterator itc = cal_data_.begin(); itc != cal_data_.end(); ++itc, ++ii) { @@ -483,7 +507,10 @@ namespace OpenMS Size idx = (global_model ? 0 : MZTrafoModel::findNearest(tms, rt)); double mz_corrected = std::numeric_limits::quiet_NaN(); - if (MZTrafoModel::isValidModel(tms[idx])) mz_corrected = tms[idx].predict(itc->getMZ()); + if (MZTrafoModel::isValidModel(tms[idx])) + { + mz_corrected = tms[idx].predict(itc->getMZ()); + } double mz_ref = cal_data_.getRefMZ(ii); double ppm_before = Math::getPPM(itc->getMZ(), mz_ref); double ppm_after = Math::getPPM(mz_corrected, mz_ref); @@ -517,8 +544,10 @@ namespace OpenMS if (!hasValidModels) { // QC tables are done; quit OPENMS_LOG_ERROR << "Error: Could not build a single local calibration model! Check your calibrants and/or extend the search window!" << std::endl; - if (use_RANSAC) OPENMS_LOG_ERROR << " Since you are using RANSAC, check the parameters as well and test different setups." << std::endl; - + if (use_RANSAC) + { + OPENMS_LOG_ERROR << " Since you are using RANSAC, check the parameters as well and test different setups." << std::endl; + } return false; } diff --git a/src/openms/source/FILTERING/CALIBRATION/MZTrafoModel.cpp b/src/openms/source/FILTERING/CALIBRATION/MZTrafoModel.cpp index 70c6f2fef6c..dcc10f933f0 100644 --- a/src/openms/source/FILTERING/CALIBRATION/MZTrafoModel.cpp +++ b/src/openms/source/FILTERING/CALIBRATION/MZTrafoModel.cpp @@ -102,10 +102,18 @@ namespace OpenMS if (trafo.coeff_.empty()) return false; // go through coefficients and see if they are too extreme - if (limit_offset_ < fabs(trafo.coeff_[0])) return false; - if (limit_scale_ < fabs(trafo.coeff_[1])) return false; - if (limit_power_ < fabs(trafo.coeff_[2])) return false; - + if (limit_offset_ < fabs(trafo.coeff_[0])) + { + return false; + } + if (limit_scale_ < fabs(trafo.coeff_[1])) + { + return false; + } + if (limit_power_ < fabs(trafo.coeff_[2])) + { + return false; + } return (true); } @@ -197,8 +205,10 @@ namespace OpenMS { if (md == LINEAR) { - if (obs_mz.size() < 2) return false; - + if (obs_mz.size() < 2) + { + return false; + } if (use_RANSAC && (obs_mz.size() > ransac_params_->n)) // with fewer points, RANSAC will fail { @@ -230,8 +240,10 @@ namespace OpenMS } else if (md == LINEAR_WEIGHTED) { - if (obs_mz.size() < 2) return false; - + if (obs_mz.size() < 2) + { + return false; + } double confidence_interval_P(0.0); Math::LinearRegression lr; lr.computeRegressionWeighted(confidence_interval_P, theo_mz.begin(), theo_mz.end(), obs_mz.begin(), weights.begin(), false); @@ -241,8 +253,10 @@ namespace OpenMS } else if (md == QUADRATIC) { - if (obs_mz.size() < 3) return false; - + if (obs_mz.size() < 3) + { + return false; + } if (use_RANSAC && (obs_mz.size() > ransac_params_->n)) // with fewer points, RANSAC will fail { @@ -270,8 +284,10 @@ namespace OpenMS } else if (md == QUADRATIC_WEIGHTED) { - if (obs_mz.size() < 3) return false; - + if (obs_mz.size() < 3) + { + return false; + } // Quadratic fit (weighted) Math::QuadraticRegression qr; qr.computeRegressionWeighted(theo_mz.begin(), theo_mz.end(), obs_mz.begin(), weights.begin()); @@ -292,12 +308,19 @@ namespace OpenMS std::vector st_ppm_before, st_ppm_after; for (Size i = 0; i < obs_mz.size(); i++) { - if (use_ppm_) st_ppm_before.push_back(obs_mz[i]); - else st_ppm_before.push_back(Math::getPPM(theo_mz[i], obs_mz[i])); - + if (use_ppm_) + { + st_ppm_before.push_back(obs_mz[i]); + } + else + { + st_ppm_before.push_back(Math::getPPM(theo_mz[i], obs_mz[i])); + } double obs_mz_v = obs_mz[i]; - if (use_ppm_) obs_mz_v = Math::ppmToMass(obs_mz_v, theo_mz[i]) + theo_mz[i]; // - + if (use_ppm_) + { + obs_mz_v = Math::ppmToMass(obs_mz_v, theo_mz[i]) + theo_mz[i]; + } st_ppm_after.push_back(Math::getPPM(theo_mz[i], predict(obs_mz_v))); // predict() is ppm-aware itself printf("%4.5f %4.5f %2.1f | %2.1f\n", theo_mz[i], obs_mz_v, st_ppm_before.back(), st_ppm_after.back()); @@ -379,8 +402,10 @@ namespace OpenMS void MZTrafoModel::getCoefficients( double& intercept, double& slope, double& power ) { - if (!isTrained()) throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Model is not trained yet."); - + if (!isTrained()) + { + throw Exception::Precondition(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Model is not trained yet."); + } intercept = coeff_[0]; slope = coeff_[1]; power = coeff_[2]; diff --git a/src/openms/source/FILTERING/CALIBRATION/PrecursorCorrection.cpp b/src/openms/source/FILTERING/CALIBRATION/PrecursorCorrection.cpp index 33330092d07..474ae349bb8 100644 --- a/src/openms/source/FILTERING/CALIBRATION/PrecursorCorrection.cpp +++ b/src/openms/source/FILTERING/CALIBRATION/PrecursorCorrection.cpp @@ -269,8 +269,10 @@ namespace OpenMS for (Size f = 0; f != features.size(); ++f) { // feature is incompatible if believe_charge is set and charges don't match - if (believe_charge && features[f].getCharge() != pc_charge) continue; - + if (believe_charge && features[f].getCharge() != pc_charge) + { + continue; + } // check if precursor/MS2 position overlap with feature if (overlaps_(features[f], rt, pc_mz, rt_tolerance_s)) { diff --git a/src/openms/source/FILTERING/CALIBRATION/TOFCalibration.cpp b/src/openms/source/FILTERING/CALIBRATION/TOFCalibration.cpp index 6018dc43c15..1ca1edc429a 100644 --- a/src/openms/source/FILTERING/CALIBRATION/TOFCalibration.cpp +++ b/src/openms/source/FILTERING/CALIBRATION/TOFCalibration.cpp @@ -213,20 +213,20 @@ namespace OpenMS // iterate through all spectra - for (spec_iter = calib_peaks.begin(); spec_iter != calib_peaks.end(); ++spec_iter) + for (MSSpectrum& spec_iter : calib_peaks) { - peak_iter = spec_iter->begin(); + peak_iter = spec_iter.begin(); help_iter = peak_iter; std::vector vec; // go through current scan - while (peak_iter < spec_iter->end()) + while (peak_iter < spec_iter.end()) { - while (peak_iter + 1 < spec_iter->end() && ((peak_iter + 1)->getMZ() - peak_iter->getMZ() < 1.2)) + while (peak_iter + 1 < spec_iter.end() && ((peak_iter + 1)->getMZ() - peak_iter->getMZ() < 1.2)) { ++peak_iter; } - vec.push_back(distance(spec_iter->begin(), help_iter)); + vec.push_back(distance(spec_iter.begin(), help_iter)); help_iter = peak_iter + 1; ++peak_iter; @@ -263,9 +263,9 @@ namespace OpenMS //two point conversion if (ml3s_.empty()) { - for (PeakMap::iterator spec_iter = calib_spectra.begin(); spec_iter != calib_spectra.end(); ++spec_iter) + for (MSSpectrum& spec_iter : calib_spectra) { - peak_iter = spec_iter->begin(); + peak_iter = spec_iter.begin(); double ml1, ml2; if (ml1s_.size() == 1) { @@ -279,7 +279,7 @@ namespace OpenMS } // go through current scan - for (; peak_iter != spec_iter->end(); ++peak_iter) + for (; peak_iter != spec_iter.end(); ++peak_iter) { double time = peak_iter->getMZ(); peak_iter->setPos(ml1 / 1E12 * (time * 1000 - ml2)); @@ -290,9 +290,9 @@ namespace OpenMS else { // three point conversion - for (PeakMap::iterator spec_iter = calib_spectra.begin(); spec_iter != calib_spectra.end(); ++spec_iter) + for (MSSpectrum& spec_iter : calib_spectra) { - peak_iter = spec_iter->begin(); + peak_iter = spec_iter.begin(); double ml1, ml2, ml3; if (ml1s_.size() == 1) { @@ -308,7 +308,7 @@ namespace OpenMS } // go through current scan - for (; peak_iter != spec_iter->end(); ++peak_iter) + for (; peak_iter != spec_iter.end(); ++peak_iter) { double time = peak_iter->getMZ(); peak_iter->setPos((-ml2 - (0.1E7 * (-5E5 + sqrt(0.25E12 - ml1 * ml2 * ml3 + ml1 * ml3 * time))) / (ml1 * ml3) + time) / ml3); @@ -352,9 +352,13 @@ namespace OpenMS { double xi = mQ_(calib_peaks_ft_[spec][monoiso[p]].getMZ(), spec); if (xi > calib_masses[error_medians_.size() - 1]) + { continue; + } if (xi < calib_masses[0]) + { continue; + } std::cout << exp_masses[p] << "\t" << Math::getPPM(xi - spline(xi), exp_masses[p]) << std::endl; diff --git a/src/openms/source/FILTERING/DATAREDUCTION/DataFilters.cpp b/src/openms/source/FILTERING/DATAREDUCTION/DataFilters.cpp index 611b4bc07ac..7e0ff32811f 100644 --- a/src/openms/source/FILTERING/DATAREDUCTION/DataFilters.cpp +++ b/src/openms/source/FILTERING/DATAREDUCTION/DataFilters.cpp @@ -136,7 +136,9 @@ namespace OpenMS tmp.split(' ', parts); SignedSize size = parts.size(); if (size < 2) + { throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "invalid filter format", tmp); + } //field tmp = parts[0]; tmp.toLower(); diff --git a/src/openms/source/FILTERING/DATAREDUCTION/FeatureFindingMetabo.cpp b/src/openms/source/FILTERING/DATAREDUCTION/FeatureFindingMetabo.cpp index 96c2b0d582a..26606a69270 100644 --- a/src/openms/source/FILTERING/DATAREDUCTION/FeatureFindingMetabo.cpp +++ b/src/openms/source/FILTERING/DATAREDUCTION/FeatureFindingMetabo.cpp @@ -925,8 +925,10 @@ namespace OpenMS { // traces are sorted by m/z, so we can break when we leave the allowed window double diff_mz = std::fabs(input_mtraces[ext_idx].getCentroidMZ() - ref_trace_mz); - if (diff_mz > local_mz_range_) break; - + if (diff_mz > local_mz_range_) + { + break; + } double diff_rt = std::fabs(input_mtraces[ext_idx].getCentroidRT() - ref_trace_rt); if (diff_rt <= local_rt_range_) { diff --git a/src/openms/source/FILTERING/DATAREDUCTION/IsotopeDistributionCache.cpp b/src/openms/source/FILTERING/DATAREDUCTION/IsotopeDistributionCache.cpp index 9a64498f372..48fe1a11b67 100644 --- a/src/openms/source/FILTERING/DATAREDUCTION/IsotopeDistributionCache.cpp +++ b/src/openms/source/FILTERING/DATAREDUCTION/IsotopeDistributionCache.cpp @@ -61,10 +61,10 @@ namespace OpenMS isotope_distributions_[index].trimmed_left = size_before - d.size(); d.trimRight(intensity_percentage_optional); - for (IsotopeDistribution::Iterator it = d.begin(); it != d.end(); ++it) + for (Peak1D& it : d) { - isotope_distributions_[index].intensity.push_back(it->getIntensity()); - //log_ << " - " << it->second << std::endl; + isotope_distributions_[index].intensity.push_back(it.getIntensity()); + //log_ << " - " << it.second << std::endl; } //determine the number of optional peaks at the beginning/end @@ -77,11 +77,17 @@ namespace OpenMS if (isotope_distributions_[index].intensity[i] < intensity_percentage) { if (!is_end && !is_begin) + { is_end = true; + } if (is_begin) + { ++begin; + } else if (is_end) + { ++end; + } } else if (is_begin) { diff --git a/src/openms/source/FILTERING/DATAREDUCTION/MassTraceDetection.cpp b/src/openms/source/FILTERING/DATAREDUCTION/MassTraceDetection.cpp index e2e8c471e2d..1c98d84447b 100644 --- a/src/openms/source/FILTERING/DATAREDUCTION/MassTraceDetection.cpp +++ b/src/openms/source/FILTERING/DATAREDUCTION/MassTraceDetection.cpp @@ -211,15 +211,17 @@ namespace OpenMS // *********************************************************** // // Step 1: Detecting potential chromatographic apices // *********************************************************** // - for (PeakMap::ConstIterator it = input_exp.begin(); it != input_exp.end(); ++it) + for (const MSSpectrum& it : input_exp) { // check if this is a MS1 survey scan - if (it->getMSLevel() != 1) continue; - + if (it.getMSLevel() != 1) + { + continue; + } std::vector indices_passing; - for (Size peak_idx = 0; peak_idx < it->size(); ++peak_idx) + for (Size peak_idx = 0; peak_idx < it.size(); ++peak_idx) { - double tmp_peak_int((*it)[peak_idx].getIntensity()); + double tmp_peak_int((it)[peak_idx].getIntensity()); if (tmp_peak_int > noise_threshold_int_) { // Assume that noise_threshold_int_ contains the noise level of the @@ -233,7 +235,7 @@ namespace OpenMS ++total_peak_count; } } - PeakMap::SpectrumType tmp_spec(*it); + PeakMap::SpectrumType tmp_spec(it); tmp_spec.select(indices_passing); work_exp.addSpectrum(tmp_spec); spec_offsets.push_back(spec_offsets.back() + tmp_spec.size()); @@ -541,7 +543,10 @@ namespace OpenMS MassTrace new_trace(current_trace); new_trace.updateWeightedMeanRT(); new_trace.updateWeightedMeanMZ(); - if (!fwhms_mz.empty()) new_trace.fwhm_mz_avg = Math::median(fwhms_mz.begin(), fwhms_mz.end()); + if (!fwhms_mz.empty()) + { + new_trace.fwhm_mz_avg = Math::median(fwhms_mz.begin(), fwhms_mz.end()); + } new_trace.setQuantMethod(quant_method_); //new_trace.setCentroidSD(ftl_sd); new_trace.updateWeightedMZsd(); @@ -554,7 +559,10 @@ namespace OpenMS this->setProgress(peaks_detected); // check if we already reached the (optional) maximum number of traces - if (max_traces > 0 && found_masstraces.size() == max_traces) break; + if (max_traces > 0 && found_masstraces.size() == max_traces) + { + break; + } } }