From 26e29c7785c85357b2e801227b1789045806e761 Mon Sep 17 00:00:00 2001 From: Thomas Renne <thomas.renne@u-psud.fr> Date: Thu, 11 Feb 2021 12:25:14 +0100 Subject: [PATCH 1/4] Add mzExclusion filter --- src/CMakeLists.txt | 1 + .../filters/filterchargedeconvolution.cpp | 11 ++++--- .../filters/filterchargedeconvolution.h | 2 +- .../processing/filters/filtersuitestring.cpp | 30 ++++++++++--------- .../tandemwrapper/xtandempresetsaxhandler.cpp | 12 ++++++-- tests/test_timsframe.cpp | 8 ++--- tests/test_timsxicextractor.cpp | 7 ++--- 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4832eca50..59820fda0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,6 +26,7 @@ set(CPP_FILES pappsomspp/processing/filters/filterchargedeconvolution.cpp pappsomspp/processing/filters/filtercomplementionenhancer.cpp + pappsomspp/processing/filters/filterexclusionmz.cpp pappsomspp/processing/filters/filterlocalmaximum.cpp pappsomspp/processing/filters/filtermorpho.cpp pappsomspp/processing/filters/filternameinterface.cpp diff --git a/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp index 06029816c..8d1c7a17c 100644 --- a/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp @@ -81,7 +81,6 @@ pappso::FilterChargeDeconvolution::buildFilterFromString( PrecisionFactory::fromString(precision.replace("dalton", " dalton") .replace("ppm", " ppm") .replace("res", " res")); - qDebug(); m_precisionPtrZ2 = pappso::PrecisionFactory::getPrecisionPtrFractionInstance( @@ -117,7 +116,7 @@ FilterChargeDeconvolution::filter(Trace &data_points) const qDebug(); std::vector<FilterChargeDeconvolution::DataPointInfoSp> data_points_info; data_points.sortY(); - + qDebug() << data_points.size(); Trace new_trace; for(auto &data_point : data_points) @@ -126,19 +125,19 @@ FilterChargeDeconvolution::filter(Trace &data_points) const } computeBestChargeOfDataPoint(data_points_info); - qDebug() << data_points_info.size(); +// qDebug() << data_points_info.size(); computeIsotopeDeconvolution(data_points_info); - qDebug() << data_points_info.size(); +// qDebug() << data_points_info.size(); transformToMonoChargedForAllDataPoint(data_points_info); for(DataPointInfoSp &dpi : data_points_info) { - qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge; +// qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge; new_trace.push_back(dpi->new_mono_charge_data_point); } new_trace.sortX(); data_points = std::move(new_trace); - + qDebug() << data_points.size(); qDebug(); return data_points; } diff --git a/src/pappsomspp/processing/filters/filterchargedeconvolution.h b/src/pappsomspp/processing/filters/filterchargedeconvolution.h index 3ae2b9c40..83b1f619b 100644 --- a/src/pappsomspp/processing/filters/filterchargedeconvolution.h +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.h @@ -112,7 +112,7 @@ class PMSPP_LIB_DECL FilterChargeDeconvolution : public FilterNameInterface std::vector<FilterChargeDeconvolution::DataPointInfoSp> &points, DataPoint &data_point) const; /** - * @brief For eache datapointInfo add the datapoint to the lists by their + * @brief For each datapointInfo add the datapoint to the lists by their * exclusion range * @return the vecotr of datapointInfo with their lists of isotopics peaks */ diff --git a/src/pappsomspp/processing/filters/filtersuitestring.cpp b/src/pappsomspp/processing/filters/filtersuitestring.cpp index 56adc81bb..963fd53cf 100644 --- a/src/pappsomspp/processing/filters/filtersuitestring.cpp +++ b/src/pappsomspp/processing/filters/filtersuitestring.cpp @@ -32,6 +32,7 @@ #include <QStringList> #include <QDebug> #include "../../exception/exceptionnotrecognized.h" +#include "filterexclusionmz.h" namespace pappso { FilterSuiteString::FilterSuiteString(const QString &strBuildParams) @@ -75,30 +76,31 @@ FilterSuiteString::toString() const void FilterSuiteString::buildFilterFromString(const QString &strBuildParams) { - qDebug() << strBuildParams; + qInfo() << strBuildParams; QStringList filters = strBuildParams.split(" ", QString::SkipEmptyParts); for(QString filter_str : filters) { - qDebug() << filter_str; if(filter_str.startsWith("complementIonEnhancer|")) { m_filterVector.push_back( std::make_shared<FilterComplementIonEnhancer>(filter_str)); } + else if(filter_str.startsWith("chargeDeconvolution|")) + { + m_filterVector.push_back( + std::make_shared<FilterChargeDeconvolution>(filter_str)); + } + else if(filter_str.startsWith("mzExclusion|")) + { + m_filterVector.push_back( + std::make_shared<FilterMzExclusion>(filter_str)); + } else { - if(filter_str.startsWith("chargeDeconvolution|")) - { - m_filterVector.push_back( - std::make_shared<FilterChargeDeconvolution>(filter_str)); - } - else - { - throw pappso::ExceptionNotRecognized( - QString("building Filter from string %1 is " - "not possible") - .arg(filter_str)); - } + throw pappso::ExceptionNotRecognized( + QString("building Filter from string %1 is " + "not possible") + .arg(filter_str)); } } } diff --git a/src/pappsomspp/processing/tandemwrapper/xtandempresetsaxhandler.cpp b/src/pappsomspp/processing/tandemwrapper/xtandempresetsaxhandler.cpp index a052e706f..de622cb38 100644 --- a/src/pappsomspp/processing/tandemwrapper/xtandempresetsaxhandler.cpp +++ b/src/pappsomspp/processing/tandemwrapper/xtandempresetsaxhandler.cpp @@ -261,9 +261,17 @@ XtandemPresetSaxHandler::getNumberOfThreads() const const QString XtandemPresetSaxHandler::getMs2FiltersOptions() const { + QString filter_suite; PrecisionPtr precision = PrecisionFactory::getPrecisionPtrInstance( m_ms2precisionUnit, m_ms2precisionValue); - return QString("chargeDeconvolution|%1") - .arg(precision->toString().replace(" ", "")); + QString charge_decon_filter = QString("chargeDeconvolution|%1") + .arg(precision->toString().replace(" ", "")); + + PrecisionPtr precision_exclu = PrecisionFactory::getPrecisionPtrInstance( + m_ms2precisionUnit, m_ms2precisionValue / 2); + QString mz_exclusion_filter = + QString("mzExclusion|%1").arg(precision_exclu->toString().replace(" ", "")); + filter_suite = charge_decon_filter + " " + mz_exclusion_filter; + return filter_suite; } } // namespace pappso diff --git a/tests/test_timsframe.cpp b/tests/test_timsframe.cpp index b96f680ca..a483b527e 100644 --- a/tests/test_timsframe.cpp +++ b/tests/test_timsframe.cpp @@ -225,9 +225,7 @@ TEST_CASE("test tims frames", "[timsframe]") */ pappso::MsFileAccessor accessor( - "/home/langella/developpement/git/bruker/" - "200ngHeLaPASEF_2min_compressed.d/" - "analysis.tdf", + "/data/test_tdf_quality/2-3-2021_1_HeLa10ng_871.d/analysis.tdf", "a1"); @@ -253,14 +251,14 @@ TEST_CASE("test tims frames", "[timsframe]") } pappso::QualifiedMassSpectrum mass_spectrum = - tims2_reader->qualifiedMassSpectrum(7); + tims2_reader->qualifiedMassSpectrum(33373); INFO("mass_spectrum.getMsLevel()=" << mass_spectrum.getMsLevel()); INFO("mass_spectrum.getPrecursorMz()=" << mass_spectrum.getPrecursorMz()); INFO("mass_spectrum.getMassSpectrumId().getSpectrumIndex()=" << mass_spectrum.getMassSpectrumId().getSpectrumIndex()); - + INFO(mass_spectrum.getMassSpectrumSPtr()->xValues().at(0)); REQUIRE_FALSE(mass_spectrum.getMassSpectrumCstSPtr().get()->back().x < 40.0); diff --git a/tests/test_timsxicextractor.cpp b/tests/test_timsxicextractor.cpp index 9804bc247..842766250 100644 --- a/tests/test_timsxicextractor.cpp +++ b/tests/test_timsxicextractor.cpp @@ -68,9 +68,7 @@ TEST_CASE("Extracting XIC from timsdata.", "[TimsXicExtractor]") */ pappso::MsFileAccessor accessor( - "/home/langella/developpement/git/bruker/" - "200ngHeLaPASEF_2min_compressed.d/" - "analysis.tdf", + "/data/test_tdf_quality/2-3-2021_1_HeLa10ng_871.d/analysis.tdf", "a1"); @@ -91,8 +89,7 @@ TEST_CASE("Extracting XIC from timsdata.", "[TimsXicExtractor]") pappso::TimsDataSp tims_data = tims2_reader->getTimsDataSPtr(); - - + std::vector<std::size_t> precursor_list = {3, 4, 5, 3000, 3001}; std::vector<pappso::TimsXicStructure> xic_list; -- GitLab From e39b62e2f83f1fd5b7d7ab95a550cde73dc5e2a0 Mon Sep 17 00:00:00 2001 From: Thomas Renne <thomas.renne@u-psud.fr> Date: Tue, 16 Feb 2021 13:27:23 +0100 Subject: [PATCH 2/4] correct the double make of the filterSuiteString pointer --- .../filters/filterchargedeconvolution.cpp | 3 +++ .../processing/filters/filterchargedeconvolution.h | 1 + .../processing/tandemwrapper/tandemwrapperrun.cpp | 13 +++++++++++-- .../processing/tandemwrapper/tandemwrapperrun.h | 4 +--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp index 8d1c7a17c..175b7d6c7 100644 --- a/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp @@ -34,6 +34,7 @@ pappso::FilterChargeDeconvolution::FilterChargeDeconvolution( const QString &strBuildParams) { buildFilterFromString(strBuildParams); + qInfo() << "ChargeDeconvolution created"; } @@ -62,6 +63,7 @@ FilterChargeDeconvolution::FilterChargeDeconvolution( FilterChargeDeconvolution::~FilterChargeDeconvolution() { + qInfo() << "ChargeDeconvolution destroyed"; } @@ -316,3 +318,4 @@ pappso::FilterChargeDeconvolution::transformToMonoChargedForAllDataPoint( } } } + diff --git a/src/pappsomspp/processing/filters/filterchargedeconvolution.h b/src/pappsomspp/processing/filters/filterchargedeconvolution.h index 83b1f619b..85c99a039 100644 --- a/src/pappsomspp/processing/filters/filterchargedeconvolution.h +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.h @@ -150,3 +150,4 @@ class PMSPP_LIB_DECL FilterChargeDeconvolution : public FilterNameInterface PrecisionPtr m_precisionPtrZ2; }; } // namespace pappso + diff --git a/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp b/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp index b895b34c8..0dac8a026 100644 --- a/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp +++ b/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp @@ -289,8 +289,17 @@ TandemWrapperRun::readTandemPresetFile(const QString &tandem_preset_file) } QString ms2_filters_str = preset_handler.getMs2FiltersOptions(); - msp_ms2FilterSuiteString = - std::make_shared<pappso::FilterSuiteString>(ms2_filters_str); + if(!ms2_filters_str.isEmpty()) + { + msp_ms2FilterSuiteString = + std::make_shared<pappso::FilterSuiteString>(ms2_filters_str); + } + else + { + msp_ms2FilterSuiteString = + std::make_shared<pappso::FilterSuiteString>( + "chargeDeconvolution|0.02dalton mzExclusion|0.01dalton"); + } } else { diff --git a/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.h b/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.h index 7d66899d7..158eb7b3a 100644 --- a/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.h +++ b/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.h @@ -119,9 +119,7 @@ class PMSPP_LIB_DECL TandemWrapperRun : public QObject int m_maxTandemRunTimeMs = (60000 * 60 * 24); // 1 day QProcess *m_xtProcess = nullptr; - std::shared_ptr<FilterSuiteString> msp_ms2FilterSuiteString = - std::make_shared<pappso::FilterSuiteString>( - "chargeDeconvolution|0.02dalton"); + std::shared_ptr<FilterSuiteString> msp_ms2FilterSuiteString = nullptr; QTextStream *mp_outputStream = nullptr; QTextStream *mp_errorStream = nullptr; -- GitLab From 663d72945e04bdc6e9bbe28c35971f6304b9c71b Mon Sep 17 00:00:00 2001 From: Thomas Renne <thomas.renne@u-psud.fr> Date: Tue, 16 Feb 2021 13:40:41 +0100 Subject: [PATCH 3/4] memory leak corrected in chargeDeconvolution filter shared_ptr --> weak_ptr --- .../filters/filterchargedeconvolution.cpp | 37 +++++++++---------- .../filters/filterchargedeconvolution.h | 7 ++-- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp index 175b7d6c7..be799bf27 100644 --- a/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp @@ -127,13 +127,13 @@ FilterChargeDeconvolution::filter(Trace &data_points) const } computeBestChargeOfDataPoint(data_points_info); -// qDebug() << data_points_info.size(); + // qDebug() << data_points_info.size(); computeIsotopeDeconvolution(data_points_info); -// qDebug() << data_points_info.size(); + // qDebug() << data_points_info.size(); transformToMonoChargedForAllDataPoint(data_points_info); for(DataPointInfoSp &dpi : data_points_info) { -// qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge; + // qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge; new_trace.push_back(dpi->new_mono_charge_data_point); } @@ -179,11 +179,11 @@ pappso::FilterChargeDeconvolution::addDataPointRefByExclusion( // add the datapoint to the list and add the parent pointer i_z1->get()->z1_vect.push_back(new_dpi); new_dpi->parent = *i_z1; - DataPointInfoSp parent_z1 = i_z1->get()->parent; + DataPointInfoSp parent_z1 = i_z1->get()->parent.lock(); while(parent_z1 != nullptr) { parent_z1.get()->z1_vect.push_back(new_dpi); - parent_z1 = parent_z1->parent; + parent_z1 = parent_z1->parent.lock(); } i_z1++; } @@ -203,11 +203,11 @@ pappso::FilterChargeDeconvolution::addDataPointRefByExclusion( // add the datapoint to the list and add the parent pointer i_z2->get()->z2_vect.push_back(new_dpi); new_dpi->parent = *i_z2; - DataPointInfoSp parent_z2 = i_z2->get()->parent; + DataPointInfoSp parent_z2 = i_z2->get()->parent.lock(); while(parent_z2 != nullptr) { parent_z2.get()->z2_vect.push_back(new_dpi); - parent_z2 = parent_z2->parent; + parent_z2 = parent_z2->parent.lock(); } i_z2++; } @@ -224,27 +224,27 @@ pappso::FilterChargeDeconvolution::computeBestChargeOfDataPoint( if(data_point_info.get()->z1_vect.size() >= 1 && data_point_info.get()->z2_vect.size() == 0) { - for(DataPointInfoSp other : data_point_info.get()->z1_vect) + for(std::weak_ptr<DataPointInfo> other : data_point_info.get()->z1_vect) { - other->z_charge = 1; + other.lock()->z_charge = 1; } data_point_info.get()->z_charge = 1; } else if(data_point_info.get()->z1_vect.size() == 0 && data_point_info.get()->z2_vect.size() >= 1) { - for(DataPointInfoSp other : data_point_info.get()->z2_vect) + for(std::weak_ptr<DataPointInfo> other : data_point_info.get()->z2_vect) { - other->z_charge = 2; + other.lock()->z_charge = 2; } data_point_info.get()->z_charge = 2; } else if(data_point_info.get()->z1_vect.size() >= 1 && data_point_info.get()->z2_vect.size() >= 1) { - for(DataPointInfoSp other : data_point_info.get()->z2_vect) + for(std::weak_ptr<DataPointInfo> other : data_point_info.get()->z2_vect) { - other->z_charge = 2; + other.lock()->z_charge = 2; } data_point_info.get()->z_charge = 2; } @@ -268,7 +268,7 @@ pappso::FilterChargeDeconvolution::computeIsotopeDeconvolution( for(DataPointInfoSp &data_point_info : data_points_info) { - if(data_point_info->parent == nullptr) + if(data_point_info->parent.lock() == nullptr) { DataPointInfoSp deconvoluted_point(std::make_shared<DataPointInfo>()); @@ -279,18 +279,18 @@ pappso::FilterChargeDeconvolution::computeIsotopeDeconvolution( if(data_point_info->z_charge == 1) { - for(DataPointInfoSp data : data_point_info->z1_vect) + for(std::weak_ptr<DataPointInfo> data : data_point_info->z1_vect) { deconvoluted_point->new_mono_charge_data_point.y += - data->data_point.y; + data.lock()->data_point.y; } } else if(data_point_info->z_charge == 2) { - for(DataPointInfoSp data : data_point_info->z2_vect) + for(std::weak_ptr<DataPointInfo> data : data_point_info->z2_vect) { deconvoluted_point->new_mono_charge_data_point.y += - data->data_point.y; + data.lock()->data_point.y; } } else // if z.charge == 0 @@ -318,4 +318,3 @@ pappso::FilterChargeDeconvolution::transformToMonoChargedForAllDataPoint( } } } - diff --git a/src/pappsomspp/processing/filters/filterchargedeconvolution.h b/src/pappsomspp/processing/filters/filterchargedeconvolution.h index 85c99a039..144faa632 100644 --- a/src/pappsomspp/processing/filters/filterchargedeconvolution.h +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.h @@ -57,11 +57,11 @@ class PMSPP_LIB_DECL FilterChargeDeconvolution : public FilterNameInterface // range of mass possible for z2 peak (~0.5mz) std::pair<double, double> z2_range; // datapointInfo where the mass is in the range - FilterChargeDeconvolution::DataPointInfoSp parent = nullptr; + std::weak_ptr<DataPointInfo> parent; // list of datapointinfo with 1mz diff multiple - std::vector<FilterChargeDeconvolution::DataPointInfoSp> z1_vect; + std::vector<std::weak_ptr<DataPointInfo>> z1_vect; // list of datapointinfo with 2mz diff multiple - std::vector<FilterChargeDeconvolution::DataPointInfoSp> z2_vect; + std::vector<std::weak_ptr<DataPointInfo>> z2_vect; }; public: @@ -150,4 +150,3 @@ class PMSPP_LIB_DECL FilterChargeDeconvolution : public FilterNameInterface PrecisionPtr m_precisionPtrZ2; }; } // namespace pappso - -- GitLab From c2ea3eb289a9bc23074e0b93ab6e37ec8bdfdd26 Mon Sep 17 00:00:00 2001 From: Thomas Renne <thomas.renne@u-psud.fr> Date: Tue, 16 Feb 2021 13:41:21 +0100 Subject: [PATCH 4/4] Add new filter mzExclusion --- .../processing/filters/filterexclusionmz.cpp | 127 ++++++++++++++++++ .../processing/filters/filterexclusionmz.h | 79 +++++++++++ 2 files changed, 206 insertions(+) create mode 100644 src/pappsomspp/processing/filters/filterexclusionmz.cpp create mode 100644 src/pappsomspp/processing/filters/filterexclusionmz.h diff --git a/src/pappsomspp/processing/filters/filterexclusionmz.cpp b/src/pappsomspp/processing/filters/filterexclusionmz.cpp new file mode 100644 index 000000000..48e73f00b --- /dev/null +++ b/src/pappsomspp/processing/filters/filterexclusionmz.cpp @@ -0,0 +1,127 @@ +/** + * \file pappsomspp/processing/filters/filterexclusionmz.cpp + * \date 09/02/2021 + * \author Thomas Renne + * \brief Delete small peaks in the exclusion range + */ + +/******************************************************************************* + * Copyright (c) 2021 Thomas Renne <thomas.renne@e.email>. + * + * This file is part of the PAPPSOms++ library. + * + * PAPPSOms++ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PAPPSOms++ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#include "filterexclusionmz.h" +#include <QDebug> +#include "../../exception/exceptionnotrecognized.h" + +using namespace pappso; + +FilterMzExclusion::FilterMzExclusion(const QString &strBuildParams) +{ + buildFilterFromString(strBuildParams); +} + +FilterMzExclusion::FilterMzExclusion(pappso::PrecisionPtr precision_ptr) + : m_exclusionPrecision(precision_ptr) +{ +} + +FilterMzExclusion::FilterMzExclusion(const pappso::FilterMzExclusion &other) + : m_exclusionPrecision(other.m_exclusionPrecision) +{ +} + +FilterMzExclusion::~FilterMzExclusion() +{ +} + +void +pappso::FilterMzExclusion::buildFilterFromString(const QString &strBuildParams) +{ + qDebug(); + if(strBuildParams.startsWith("mzExclusion|")) + { + QStringList params = + strBuildParams.split("|").back().split(";", QString::SkipEmptyParts); + + QString precision = params.at(0); + m_exclusionPrecision = + PrecisionFactory::fromString(precision.replace("dalton", " dalton") + .replace("ppm", " ppm") + .replace("res", " res")); + } + else + { + throw pappso::ExceptionNotRecognized( + QString("building mzExclusion from string %1 is not possible") + .arg(strBuildParams)); + } + qDebug(); +} + +pappso::Trace & +pappso::FilterMzExclusion::filter(pappso::Trace &data_points) const +{ + qDebug(); + qDebug() << "before" << data_points.size(); + data_points.sortY(); + + Trace new_trace = removeTraceInExclusionMargin(data_points); + new_trace.sortX(); + data_points = std::move(new_trace); + qDebug() << "after" << data_points.size(); + qDebug(); + return data_points; +} + +QString +pappso::FilterMzExclusion::toString() const +{ + QString strCode = + QString("mzExclusion|%1").arg(m_exclusionPrecision->toString()); + strCode.replace(" ", ""); + + return strCode; +} + +pappso::Trace +pappso::FilterMzExclusion::removeTraceInExclusionMargin( + pappso::Trace &points) const +{ + Trace new_trace; + std::vector<MzRange> excluded_ranges; + + for(auto &data_point : points) + { + auto exclude_index = excluded_ranges.begin(), end = excluded_ranges.end(); + + exclude_index = + std::find_if(exclude_index, end, [&data_point](MzRange range) { + return (data_point.x >= range.lower() && + data_point.x <= range.upper()); + }); + if(exclude_index == end) + { + new_trace.push_back(data_point); + MzRange new_range(data_point.x, m_exclusionPrecision); + excluded_ranges.push_back(new_range); + } + } + + return new_trace; +} diff --git a/src/pappsomspp/processing/filters/filterexclusionmz.h b/src/pappsomspp/processing/filters/filterexclusionmz.h new file mode 100644 index 000000000..bbc117d3b --- /dev/null +++ b/src/pappsomspp/processing/filters/filterexclusionmz.h @@ -0,0 +1,79 @@ +/** + * \file pappsomspp/processing/filters/filterexclusionmz.h + * \date 09/02/2021 + * \author Thomas Renne + * \brief Delete small peaks in the exclusion range + */ + +/******************************************************************************* + * Copyright (c) 2021 Thomas Renne <thomas.renne@e.email>. + * + * This file is part of the PAPPSOms++ library. + * + * PAPPSOms++ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PAPPSOms++ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#pragma once + +#include "filternameinterface.h" +#include "../../trace/trace.h" + +namespace pappso +{ + +class PMSPP_LIB_DECL FilterMzExclusion : public FilterNameInterface +{ + public: + /** + * Default constructor + */ + FilterMzExclusion(PrecisionPtr precision_ptr); + + + /** + * @param strBuildParams string to build the filter + * "mzExclusion|0.02dalton" + */ + FilterMzExclusion(const QString &strBuildParams); + + /** + * Copy constructor + * + * @param other TODO + */ + FilterMzExclusion(const FilterMzExclusion &other); + + /** + * Destructor + */ + virtual ~FilterMzExclusion(); + + /** + * @brief get all the datapoints and remove different isotope and add their + * intensity and change to charge = 1 when the charge is known + * @return a list of datapoint + */ + Trace &filter(Trace &data_points) const override; + QString toString() const override; + + private: + void buildFilterFromString(const QString &strBuildParams) override; + Trace removeTraceInExclusionMargin(Trace &points) const; + + + private: + PrecisionPtr m_exclusionPrecision; +}; +} // namespace pappso -- GitLab