diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d7f17d338946513268fb8a27d193797458e8e81..aa0c782d8aec5ccbd1e5f032b66c7e591ad329e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,7 @@ set(CPP_FILES pappsomspp/processing/combiners/traceminuscombiner.cpp pappsomspp/processing/combiners/tracepluscombiner.cpp + pappsomspp/processing/filters/filterchargedeconvolution.cpp pappsomspp/processing/filters/filtercomplementionenhancer.cpp pappsomspp/processing/filters/filterlocalmaximum.cpp pappsomspp/processing/filters/filtermorpho.cpp @@ -32,7 +33,6 @@ set(CPP_FILES pappsomspp/processing/filters/filterresample.cpp pappsomspp/processing/filters/filtersuite.cpp pappsomspp/processing/filters/filtertandemremovec13.cpp - pappsomspp/processing/filters/filtertdfcorrectpeak.cpp pappsomspp/processing/filters/filtertriangle.cpp pappsomspp/processing/filters/savgolfilter.cpp diff --git a/src/pappsomspp/processing/filters/filtertdfcorrectpeak.cpp b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp similarity index 75% rename from src/pappsomspp/processing/filters/filtertdfcorrectpeak.cpp rename to src/pappsomspp/processing/filters/filterchargedeconvolution.cpp index cf21b037082f754dbb3ed2128103fdcf51411b34..0bb4c720c2bbd50ad8292626ff7e0275b0c609fc 100644 --- a/src/pappsomspp/processing/filters/filtertdfcorrectpeak.cpp +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.cpp @@ -24,33 +24,34 @@ * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ -#include "filtertdfcorrectpeak.h" +#include "filterchargedeconvolution.h" #include <QDebug> using namespace pappso; -FilterCorrectTdfPeaks::FilterCorrectTdfPeaks(PrecisionPtr precision_ptr) +FilterChargeDeconvolution::FilterChargeDeconvolution(PrecisionPtr precision_ptr) : m_precisionPtr(precision_ptr) { m_diffC12C13_z1 = DIFFC12C13; m_diffC12C13_z2 = DIFFC12C13 / 2; } -FilterCorrectTdfPeaks::FilterCorrectTdfPeaks(const FilterCorrectTdfPeaks &other) +FilterChargeDeconvolution::FilterChargeDeconvolution( + const FilterChargeDeconvolution &other) : m_precisionPtr(other.m_precisionPtr) { m_diffC12C13_z1 = DIFFC12C13; m_diffC12C13_z2 = DIFFC12C13 / 2; } -FilterCorrectTdfPeaks::~FilterCorrectTdfPeaks() +FilterChargeDeconvolution::~FilterChargeDeconvolution() { } Trace & -FilterCorrectTdfPeaks::filter(Trace &data_points) const +FilterChargeDeconvolution::filter(Trace &data_points) const { - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> data_points_info; + std::vector<FilterChargeDeconvolution::DataPointInfoSp> data_points_info; data_points.sortY(); Trace new_trace; @@ -68,11 +69,11 @@ FilterCorrectTdfPeaks::filter(Trace &data_points) const qDebug() << data_points_info.size(); computeIsotopeDeconvolution(data_points_info); qDebug() << data_points_info.size(); - transformToZ1ForAllDataPoint(data_points_info); + transformToMonoChargedForAllDataPoint(data_points_info); for(DataPointInfoSp &dpi : data_points_info) { - qDebug() << dpi->C12_point.x << dpi->z_charge; - new_trace.push_back(dpi->C12_point); + qDebug() << dpi->new_mono_charge_data_point.x << dpi->z_charge; + new_trace.push_back(dpi->new_mono_charge_data_point); } new_trace.sortX(); @@ -82,8 +83,8 @@ FilterCorrectTdfPeaks::filter(Trace &data_points) const } void -pappso::FilterCorrectTdfPeaks::addDataPointToList( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &points, +pappso::FilterChargeDeconvolution::addDataPointToList( + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &points, pappso::DataPoint &data_point) const { DataPointInfoSp new_dpi(std::make_shared<DataPointInfo>()); @@ -98,9 +99,9 @@ pappso::FilterCorrectTdfPeaks::addDataPointToList( } void -pappso::FilterCorrectTdfPeaks::addDataPointRefByExclusion( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &points, - FilterCorrectTdfPeaks::DataPointInfoSp &new_dpi) const +pappso::FilterChargeDeconvolution::addDataPointRefByExclusion( + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &points, + FilterChargeDeconvolution::DataPointInfoSp &new_dpi) const { auto i_z1 = points.begin(), end = points.end(); while(i_z1 != end) @@ -146,8 +147,9 @@ pappso::FilterCorrectTdfPeaks::addDataPointRefByExclusion( } void -pappso::FilterCorrectTdfPeaks::computeBestChargeOfDataPoint( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &data_points_info) const +pappso::FilterChargeDeconvolution::computeBestChargeOfDataPoint( + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &data_points_info) + const { for(DataPointInfoSp &data_point_info : data_points_info) { @@ -189,10 +191,12 @@ pappso::FilterCorrectTdfPeaks::computeBestChargeOfDataPoint( } void -pappso::FilterCorrectTdfPeaks::computeIsotopeDeconvolution( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &data_points_info) const +pappso::FilterChargeDeconvolution::computeIsotopeDeconvolution( + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &data_points_info) + const { - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> deconvoluted_points_info; + std::vector<FilterChargeDeconvolution::DataPointInfoSp> + deconvoluted_points_info; for(DataPointInfoSp &data_point_info : data_points_info) { @@ -201,29 +205,27 @@ pappso::FilterCorrectTdfPeaks::computeIsotopeDeconvolution( DataPointInfoSp deconvoluted_point(std::make_shared<DataPointInfo>()); deconvoluted_point->z_charge = data_point_info->z_charge; + deconvoluted_point->new_mono_charge_data_point = + data_point_info->data_point; if(data_point_info->z_charge == 1) { - deconvoluted_point->C12_point = data_point_info->data_point; for(DataPointInfoSp data : data_point_info->z1_vect) { - deconvoluted_point->C12_point.incrementY(data->data_point.y); + deconvoluted_point->data_point.y += data->data_point.y; } } else if(data_point_info->z_charge == 2) { - deconvoluted_point->C12_point = data_point_info->data_point; for(DataPointInfoSp data : data_point_info->z2_vect) { - deconvoluted_point->C12_point.incrementY(data->data_point.y); - // qInfo() << data->data_point.y << "++ " - // << - // deconvoluted_point->C12_point.y; + deconvoluted_point->data_point.y += data->data_point.y; } } else // if z.charge == 0 { - deconvoluted_point->C12_point = data_point_info->data_point; + deconvoluted_point->new_mono_charge_data_point = + data_point_info->data_point; } deconvoluted_points_info.push_back(deconvoluted_point); } @@ -232,14 +234,16 @@ pappso::FilterCorrectTdfPeaks::computeIsotopeDeconvolution( } void -pappso::FilterCorrectTdfPeaks::transformToZ1ForAllDataPoint( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &data_points_info) const +pappso::FilterChargeDeconvolution::transformToMonoChargedForAllDataPoint( + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &data_points_info) + const { for(DataPointInfoSp &dpi : data_points_info) { if(dpi->z_charge == 2) { - dpi->C12_point.incrementX(dpi->C12_point.x - 1); + dpi->new_mono_charge_data_point.x += + dpi->new_mono_charge_data_point.x - MHPLUS; } } } diff --git a/src/pappsomspp/processing/filters/filtertdfcorrectpeak.h b/src/pappsomspp/processing/filters/filterchargedeconvolution.h similarity index 66% rename from src/pappsomspp/processing/filters/filtertdfcorrectpeak.h rename to src/pappsomspp/processing/filters/filterchargedeconvolution.h index c7122d663f71031985ab4c068bdd36c467572005..4003736d9e5e95c8566efa0231ac0bd49214541a 100644 --- a/src/pappsomspp/processing/filters/filtertdfcorrectpeak.h +++ b/src/pappsomspp/processing/filters/filterchargedeconvolution.h @@ -1,5 +1,5 @@ /** - * \file pappsomspp/processing/filters/filtertdfcorrectpeak.h + * \file pappsomspp/processing/filters/filterchargedeconvolution.h * \date 30/09/2020 * \author Thomas Renne * \brief Sum peaks and transform mz to fit charge = 1 @@ -33,7 +33,7 @@ /** * @brief tries to keep as much as possible monoisotopes, removing any possible - * C13 peaks + * C13 peaks and monocharges each z=2 peaks * * first sort peaks by decreasing intensities, then keep most intense ones and * avoid any peaks in possible C13 windows after @@ -42,7 +42,7 @@ namespace pappso { -class PMSPP_LIB_DECL FilterCorrectTdfPeaks : public FilterInterface +class PMSPP_LIB_DECL FilterChargeDeconvolution : public FilterInterface { private: struct DataPointInfo; @@ -51,50 +51,50 @@ class PMSPP_LIB_DECL FilterCorrectTdfPeaks : public FilterInterface { int z_charge = -1; DataPoint data_point; - DataPoint C12_point; + DataPoint new_mono_charge_data_point; std::pair<double, double> z1_range; std::pair<double, double> z2_range; - FilterCorrectTdfPeaks::DataPointInfoSp parent = nullptr; - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> z1_vect; - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> z2_vect; + FilterChargeDeconvolution::DataPointInfoSp parent = nullptr; + std::vector<FilterChargeDeconvolution::DataPointInfoSp> z1_vect; + std::vector<FilterChargeDeconvolution::DataPointInfoSp> z2_vect; }; public: /** * Default constructor */ - FilterCorrectTdfPeaks(PrecisionPtr precision_ptr); + FilterChargeDeconvolution(PrecisionPtr precision_ptr); /** * Copy constructor * * @param other TODO */ - FilterCorrectTdfPeaks(const FilterCorrectTdfPeaks &other); + FilterChargeDeconvolution(const FilterChargeDeconvolution &other); /** * Destructor */ - virtual ~FilterCorrectTdfPeaks(); + virtual ~FilterChargeDeconvolution(); Trace &filter(Trace &data_points) const override; private: void addDataPointToList( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &points, + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &points, DataPoint &data_point) const; void addDataPointRefByExclusion( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &points, - FilterCorrectTdfPeaks::DataPointInfoSp &new_dpi) const; + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &points, + FilterChargeDeconvolution::DataPointInfoSp &new_dpi) const; void computeBestChargeOfDataPoint( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &data_points_info) + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &data_points_info) const; void computeIsotopeDeconvolution( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &data_points_info) + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &data_points_info) const; - void transformToZ1ForAllDataPoint( - std::vector<FilterCorrectTdfPeaks::DataPointInfoSp> &data_points_info) + void transformToMonoChargedForAllDataPoint( + std::vector<FilterChargeDeconvolution::DataPointInfoSp> &data_points_info) const; private: diff --git a/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp b/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp index b189592211b384c52949340611f7b74642952d96..73239df3d0fea46b3a4c4ce92b18eacda2a350f5 100644 --- a/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp +++ b/src/pappsomspp/processing/tandemwrapper/tandemwrapperrun.cpp @@ -36,7 +36,7 @@ #include "../../msrun/private/timsmsrunreaderms2.h" #include "../../processing/filters/filterpseudocentroid.h" #include "../../processing/filters/filtertriangle.h" -#include "../../processing/filters/filtertdfcorrectpeak.h" +#include "../../processing/filters/filterchargedeconvolution.h" #include "../../msrun/output/mzxmloutput.h" #include "xtandeminputsaxhandler.h" #include "xtandemoutputsaxhandler.h" @@ -365,8 +365,9 @@ TandemWrapperRun::convertOrginalMsData2mzXmlData(const QString &origin, std::shared_ptr<FilterSuite> ms2filter = std::make_shared<FilterSuite>(); - ms2filter.get()->push_back(std::make_shared<FilterCorrectTdfPeaks>( - pappso::PrecisionFactory::getDaltonInstance(0.01))); + ms2filter.get()->push_back( + std::make_shared<FilterChargeDeconvolution>( + pappso::PrecisionFactory::getDaltonInstance(0.01))); tims2_reader->setMs2FilterCstSPtr(ms2filter); }