libpappsomspp
Library for mass spectrometry
filtersuitestring.cpp
Go to the documentation of this file.
1 /**
2  * \file pappsomspp/processing/filers/filtersuitestring.cpp
3  * \date 17/11/2020
4  * \author Olivier Langella
5  * \brief build a filter suite from a string
6  */
7 
8 /*******************************************************************************
9  * Copyright (c) 2020 Olivier Langella
10  *<olivier.langella@universite-paris-saclay.fr>
11  *
12  * This file is part of the PAPPSOms++ library.
13  *
14  * PAPPSOms++ is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * PAPPSOms++ is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
26  *
27  ******************************************************************************/
28 
29 #include "filtersuitestring.h"
32 #include "filterpass.h"
33 #include "filtermorpho.h"
34 #include <QStringList>
35 #include <QDebug>
36 #include "../../exception/exceptionnotrecognized.h"
37 #include "filterexclusionmz.h"
38 
39 
40 namespace pappso
41 {
42 FilterSuiteString::FilterSuiteString(const QString &strBuildParams)
43 {
44  buildFilterFromString(strBuildParams);
45 }
46 
48 {
49 }
50 
51 
54 {
55 
56  qDebug();
57  for(auto &&filter : m_filterVector)
58  {
59 
60  qDebug() << filter.get();
61  qDebug() << filter->toString();
62  filter->filter(data_points);
63  }
64 
65  qDebug();
66  return data_points;
67 }
68 
69 
70 QString
72 {
73  // FIXME: check if this makes sense
74  return "Suite of filters";
75 }
76 
77 
78 QString
80 {
81  QStringList filter_str_list;
82  for(auto &&filter : m_filterVector)
83  {
84  filter_str_list << filter->toString();
85  }
86 
87  return filter_str_list.join(" ");
88 }
89 
90 
91 void
92 FilterSuiteString::buildFilterFromString(const QString &strBuildParams)
93 {
94  // qInfo() << strBuildParams;
95  QStringList filters = strBuildParams.split(" ", Qt::SkipEmptyParts);
96  for(QString filter_str : filters)
97  {
98  if(filter_str.startsWith("complementIonEnhancer|"))
99  {
100  m_filterVector.push_back(
101  std::make_shared<FilterComplementIonEnhancer>(filter_str));
102  }
103  else if(filter_str.startsWith("chargeDeconvolution|"))
104  {
105  m_filterVector.push_back(
106  std::make_shared<FilterChargeDeconvolution>(filter_str));
107  }
108  else if(filter_str.startsWith("mzExclusion|"))
109  {
110  m_filterVector.push_back(
111  std::make_shared<FilterMzExclusion>(filter_str));
112  }
113  else if(filter_str.startsWith("passQuantileBasedRemoveY|"))
114  {
115  m_filterVector.push_back(
116  std::make_shared<FilterQuantileBasedRemoveY>(filter_str));
117  }
118 
119  else if(filter_str.startsWith("antiSpike|"))
120  {
121  m_filterVector.push_back(
122  std::make_shared<FilterMorphoAntiSpike>(filter_str));
123  }
124  else
125  {
127  QString("building Filter from string %1 is "
128  "not possible")
129  .arg(filter_str));
130  }
131  }
132 }
133 
134 void
135 FilterSuiteString::addFilterFromString(const QString &strBuildParams)
136 {
137  buildFilterFromString(strBuildParams);
138 }
139 
140 
141 FilterSuiteString::FilterNameType::const_iterator
143 {
144  return m_filterVector.begin();
145 };
146 FilterSuiteString::FilterNameType::const_iterator
148 {
149  return m_filterVector.end();
150 };
151 
152 } // namespace pappso
excetion to use when an item type is not recognized
pappso::Trace & filter(pappso::Trace &data_points) const override
FilterNameType::const_iterator begin()
void buildFilterFromString(const QString &strBuildParams) override
build this filter using a string
std::vector< FilterNameInterfaceCstSPtr > m_filterVector
FilterNameType::const_iterator end()
FilterSuiteString(const QString &strBuildParams)
QString toString() const override
void addFilterFromString(const QString &strBuildParams)
takes a string that describes filters to add
virtual QString name() const override
A simple container of DataPoint instances.
Definition: trace.h:148
virtual Trace & filter(const FilterInterface &filter) final
apply a filter on this trace
Definition: trace.cpp:1001
QString toString() const
Definition: trace.cpp:984
Sum peaks and transform mz to fit charge = 1.
enhance ion intensity of ion fragment complement
Delete small peaks in the exclusion range.
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39