libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
msrunxicextractor.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/xicextractor/private/msrunxicextractorpwiz.cpp
3
* \date 07/05/2018
4
* \author Olivier Langella
5
* \brief simple proteowizard based XIC extractor
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2018 Olivier Langella <Olivier.Langella@u-psud.fr>.
10
*
11
* This file is part of the PAPPSOms++ library.
12
*
13
* PAPPSOms++ is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation, either version 3 of the License, or
16
* (at your option) any later version.
17
*
18
* PAPPSOms++ is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25
*
26
* Contributors:
27
* Olivier Langella <Olivier.Langella@u-psud.fr> - initial API and
28
*implementation
29
******************************************************************************/
30
31
#include "
msrunxicextractor.h
"
32
#include <QDebug>
33
#include <QObject>
34
35
#include "
pappsomspp/core/pappsoexception.h
"
36
#include "
pappsomspp/core/exception/exceptioninterrupted.h
"
37
#include "
pappsomspp/core/processing/filters/filterresample.h
"
38
39
namespace
pappso
40
{
41
42
43
MsRunXicExtractor::MsRunXicExtractor
(
MsRunReaderSPtr
&msrun_reader)
44
:
pappso
::
MsRunXicExtractorInterface
(msrun_reader)
45
{
46
47
MsRunXicExtractorReadPoints
get_msrun_points(
m_msrun_points
);
48
49
50
pappso::MsRunReadConfig
config;
51
config.
setNeedPeakList
(
true
);
52
config.
setMsLevels
({1});
53
54
msp_msrun_reader
.get()->readSpectrumCollection2(config, get_msrun_points);
55
56
std::sort(
57
m_msrun_points
.begin(),
58
m_msrun_points
.end(),
59
[](
const
MsRunXicExtractorPoints
&
a
,
const
MsRunXicExtractorPoints
&
b
) { return a.rt < b.rt; });
60
61
62
if
(
m_msrun_points
.size() == 0)
63
{
64
throw
pappso::PappsoException
(
65
QObject::tr(
"error extracting XIC: no MS level 1 in data file"
));
66
}
67
}
68
MsRunXicExtractor::~MsRunXicExtractor
()
69
{
70
}
71
72
73
MsRunXicExtractor::MsRunXicExtractor
(
const
MsRunXicExtractor
&other)
74
:
MsRunXicExtractorInterface
(other)
75
{
76
m_msrun_points
= other.
m_msrun_points
;
77
}
78
79
80
void
81
MsRunXicExtractor::protectedExtractXicCoordSPtrList
(
82
UiMonitorInterface
&monitor,
83
std::vector<XicCoordSPtr>::iterator it_xic_coord_list_begin,
84
std::vector<XicCoordSPtr>::iterator it_xic_coord_list_end)
85
{
86
87
// sort xic by mz:
88
std::sort(it_xic_coord_list_begin, it_xic_coord_list_end, [](
XicCoordSPtr
&
a
,
XicCoordSPtr
&
b
) {
89
return
a
.get()->rtTarget <
b
.get()->rtTarget;
90
});
91
92
for
(
auto
it = it_xic_coord_list_begin; it != it_xic_coord_list_end; it++)
93
{
94
// XicCoord *p_xic_coord = sp_xic_coord.get();
95
extractOneXicCoord
(*(it->get()));
96
monitor.
count
();
97
if
(monitor.
shouldIstop
())
98
{
99
throw
pappso::ExceptionInterrupted
(QObject::tr(
"Xic extraction process interrupted"
));
100
}
101
}
102
}
103
104
105
void
106
MsRunXicExtractor::extractOneXicCoord
(
XicCoord
&xic_coord)
107
{
108
FilterResampleKeepXRange
keep_range(xic_coord.
mzRange
.
lower
(), xic_coord.
mzRange
.
upper
());
109
std::shared_ptr<Xic> msrunxic_sp = xic_coord.
xicSptr
;
110
111
double
rt_begin = xic_coord.
rtTarget
-
m_retentionTimeAroundTarget
;
112
double
rt_end = xic_coord.
rtTarget
+
m_retentionTimeAroundTarget
;
113
114
115
auto
itpoints =
m_msrun_points
.begin();
116
117
// find startint retention time :
118
while
((itpoints !=
m_msrun_points
.end()) && (itpoints->rt < rt_begin))
119
{
120
itpoints++;
121
}
122
MassSpectrumSPtr
spectrum;
123
DataPoint
peak;
124
while
((itpoints !=
m_msrun_points
.end()) && (itpoints->rt <= rt_end))
125
{
126
spectrum =
msp_msrun_reader
.get()->massSpectrumSPtr(itpoints->spectrum_index);
127
// qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
128
// << spectrum->size(); spectrum->debugPrintValues();
129
130
qDebug() <<
" spectrum->size()="
<< spectrum->size();
131
keep_range.
filter
(*(spectrum.get()));
132
qDebug() <<
" spectrum->size()="
<< spectrum->size();
133
134
peak.
x
= itpoints->rt;
135
136
if
(
m_xicExtractMethod
==
Enums::XicExtractMethod::max
)
137
{
138
peak.
y
= 0;
139
if
(spectrum->size() > 0)
140
{
141
peak.
y
=
maxYDataPoint
(spectrum->begin(), spectrum->end())->y;
142
143
qDebug() <<
" peak.y="
<< peak.
y
<<
" spectrum->size()="
<< spectrum->size();
144
}
145
}
146
else
147
{
148
peak.
y
=
sumYTrace
(spectrum->begin(), spectrum->end(), 0);
149
}
150
msrunxic_sp->push_back(peak);
151
152
itpoints++;
153
}
154
}
155
156
}
// namespace pappso
pappso::ExceptionInterrupted
Definition
exceptioninterrupted.h:36
pappso::FilterResampleKeepXRange
Definition
filterresample.h:89
pappso::FilterResampleKeepXRange::filter
Trace & filter(Trace &trace) const override
Definition
filterresample.cpp:159
pappso::MsRunReadConfig
Definition
msrunreadconfig.h:62
pappso::MsRunReadConfig::setNeedPeakList
void setNeedPeakList(bool need_peak_list)
Definition
msrunreadconfig.cpp:173
pappso::MsRunReadConfig::setMsLevels
void setMsLevels(std::vector< std::size_t > ms_levels)
Definition
msrunreadconfig.cpp:89
pappso::MsRunXicExtractorInterface::m_retentionTimeAroundTarget
double m_retentionTimeAroundTarget
Definition
msrunxicextractorinterface.h:120
pappso::MsRunXicExtractorInterface::m_xicExtractMethod
Enums::XicExtractMethod m_xicExtractMethod
Definition
msrunxicextractorinterface.h:119
pappso::MsRunXicExtractorInterface::msp_msrun_reader
MsRunReaderSPtr msp_msrun_reader
Definition
msrunxicextractorinterface.h:118
pappso::MsRunXicExtractorInterface::MsRunXicExtractorInterface
MsRunXicExtractorInterface(MsRunReaderSPtr &msrun_reader)
constructor is private, use the MsRunXicExtractorFactory
Definition
msrunxicextractorinterface.cpp:40
pappso::MsRunXicExtractor::MsRunXicExtractorReadPoints
class to read retention time points of MsRun
Definition
msrunxicextractor.h:68
pappso::MsRunXicExtractor::MsRunXicExtractor
MsRunXicExtractor(const MsRunXicExtractor &other)
Definition
msrunxicextractor.cpp:73
pappso::MsRunXicExtractor::extractOneXicCoord
void extractOneXicCoord(XicCoord &xic_coord)
Definition
msrunxicextractor.cpp:106
pappso::MsRunXicExtractor::m_msrun_points
std::vector< MsRunXicExtractorPoints > m_msrun_points
Definition
msrunxicextractor.h:99
pappso::MsRunXicExtractor::~MsRunXicExtractor
virtual ~MsRunXicExtractor()
Definition
msrunxicextractor.cpp:68
pappso::MsRunXicExtractor::protectedExtractXicCoordSPtrList
virtual void protectedExtractXicCoordSPtrList(UiMonitorInterface &monitor, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_begin, std::vector< XicCoordSPtr >::iterator it_xic_coord_list_end) override
Definition
msrunxicextractor.cpp:81
pappso::MzRange::lower
pappso_double lower() const
Definition
mzrange.h:71
pappso::MzRange::upper
pappso_double upper() const
Definition
mzrange.h:77
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::UiMonitorInterface
Definition
uimonitorinterface.h:50
pappso::UiMonitorInterface::shouldIstop
virtual bool shouldIstop()=0
should the procces be stopped ? If true, then cancel process Use this function at strategic point of ...
pappso::UiMonitorInterface::count
virtual void count()=0
count steps report when a step is computed in an algorithm
exceptioninterrupted.h
filterresample.h
msrunxicextractor.h
pappso::Enums::XicExtractMethod::max
@ max
maximum of intensities
Definition
types.h:266
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::MsRunReaderSPtr
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition
msrunreader.h:57
pappso::maxYDataPoint
std::vector< DataPoint >::const_iterator maxYDataPoint(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end)
Definition
trace.cpp:169
pappso::PeptideIonNter::a
@ a
Definition
peptide.h:77
pappso::PeptideIonNter::b
@ b
Definition
peptide.h:74
pappso::sumYTrace
double sumYTrace(std::vector< DataPoint >::const_iterator begin, std::vector< DataPoint >::const_iterator end, double init)
calculate the sum of y value of a trace
Definition
trace.cpp:226
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition
massspectrum.h:53
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition
xiccoord.h:44
pappsoexception.h
pappso::DataPoint
Definition
datapoint.h:22
pappso::DataPoint::x
pappso_double x
Definition
datapoint.h:24
pappso::DataPoint::y
pappso_double y
Definition
datapoint.h:25
pappso::MsRunXicExtractor::MsRunXicExtractorPoints
Definition
msrunxicextractor.h:60
pappso::XicCoord
coordinates of the XIC to extract and the resulting XIC after extraction
Definition
xiccoord.h:68
pappso::XicCoord::xicSptr
XicSPtr xicSptr
extracted xic
Definition
xiccoord.h:135
pappso::XicCoord::rtTarget
double rtTarget
the targeted retention time to extract around intended in seconds, and related to one msrun....
Definition
xiccoord.h:131
pappso::XicCoord::mzRange
MzRange mzRange
the mass to extract
Definition
xiccoord.h:125
pappsomspp
core
xicextractor
private
msrunxicextractor.cpp
Generated on
for libpappsomspp by
1.17.0