libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
msrunreader.cpp
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/msrun/msrunreader.cpp
3
* \date 29/05/2018
4
* \author Olivier Langella
5
* \brief base interface to read MSrun files
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
******************************************************************************/
27
28
#include <QDebug>
29
#include <QObject>
30
31
#include "
msrunreader.h
"
32
#include "
pappsomspp/core/exception/exceptionnotfound.h
"
33
34
35
int
msRunReaderSPtrMetaTypeId
=
36
qRegisterMetaType<pappso::MsRunReaderSPtr>(
"pappso::MsRunReaderSPtr"
);
37
38
39
namespace
pappso
40
{
41
42
43
MsRunReader::MsRunReader
(
const
MsRunIdCstSPtr
&ms_run_id) :
mcsp_msRunId
(ms_run_id)
44
{
45
}
46
47
MsRunReader::MsRunReader
(
const
MsRunReader
&other) :
mcsp_msRunId
(other.
mcsp_msRunId
)
48
{
49
mpa_multiMapScanNumber
=
nullptr
;
50
m_isMonoThread
= other.
m_isMonoThread
;
51
}
52
53
54
const
MsRunIdCstSPtr
&
55
MsRunReader::getMsRunId
()
const
56
{
57
return
mcsp_msRunId
;
58
}
59
60
61
MsRunReader::~MsRunReader
()
62
{
63
if
(
mpa_multiMapScanNumber
==
nullptr
)
64
delete
mpa_multiMapScanNumber
;
65
}
66
67
void
68
MsRunReader::setMonoThread
(
bool
is_mono_thread)
69
{
70
m_isMonoThread
= is_mono_thread;
71
}
72
73
bool
74
MsRunReader::isMonoThread
()
const
75
{
76
return
m_isMonoThread
;
77
}
78
79
80
std::size_t
81
MsRunReader::scanNumber2SpectrumIndex
(std::size_t scan_number)
82
{
83
qDebug() <<
" "
<<
mpa_multiMapScanNumber
;
84
85
if
(
mpa_multiMapScanNumber
==
nullptr
)
86
{
87
mpa_multiMapScanNumber
=
new
MsRunReaderScanNumberMultiMap
();
88
89
MsRunReadConfig
config;
90
std::vector<size_t> ms_levels;
91
for
(std::size_t i = 1; i < 9; i++)
92
{
93
ms_levels.push_back(i);
94
}
95
config.
setMsLevels
(ms_levels);
96
config.
setNeedPeakList
(
false
);
97
readSpectrumCollection2
(config, *
mpa_multiMapScanNumber
);
98
}
99
try
100
{
101
return
mpa_multiMapScanNumber
->getSpectrumIndexFromScanNumber(scan_number);
102
}
103
104
catch
(
ExceptionNotFound
&error)
105
{
106
throw
ExceptionNotFound
(QObject::tr(
"error reading file %1 : %2"
)
107
.arg(
mcsp_msRunId
.get()->getFileName())
108
.arg(error.
qwhat
()));
109
}
110
catch
(
PappsoException
&error)
111
{
112
throw
PappsoException
(QObject::tr(
"error reading file %1 : %2"
)
113
.arg(
mcsp_msRunId
.get()->getFileName())
114
.arg(error.
qwhat
()));
115
}
116
}
117
118
119
bool
120
MsRunReader::hasScanNumbers
()
const
121
{
122
return
false
;
123
}
124
125
std::vector<double>
126
MsRunReader::getRetentionTimeLine
()
127
{
128
qDebug();
129
130
try
131
{
132
133
MsRunReaderRetentionTimeLine
reader_timeline;
134
MsRunReadConfig
config;
135
config.
setMsLevels
({1});
136
config.
setNeedPeakList
(
false
);
137
// readSpectrumCollectionByMsLevel(reader_timeline, 1);
138
readSpectrumCollection2
(config, reader_timeline);
139
140
return
reader_timeline.
getRetentionTimeLine
();
141
}
142
143
catch
(
ExceptionNotFound
&error)
144
{
145
throw
ExceptionNotFound
(QObject::tr(
"error reading file %1 : %2"
)
146
.arg(
mcsp_msRunId
.get()->getFileName())
147
.arg(error.
qwhat
()));
148
}
149
catch
(
PappsoException
&error)
150
{
151
throw
PappsoException
(QObject::tr(
"error reading file %1 : %2"
)
152
.arg(
mcsp_msRunId
.get()->getFileName())
153
.arg(error.
qwhat
()));
154
}
155
}
156
157
158
Trace
159
MsRunReader::getTicChromatogram
()
160
{
161
qDebug();
162
163
try
164
{
165
MsRunReaderTicChromatogram
ms_run_reader;
166
167
MsRunReadConfig
config;
168
config.
setMsLevels
({1});
169
config.
setNeedPeakList
(
true
);
170
// readSpectrumCollectionByMsLevel(reader_timeline, 1);
171
readSpectrumCollection2
(config, ms_run_reader);
172
173
return
ms_run_reader.
getTicChromatogram
();
174
}
175
176
catch
(
ExceptionNotFound
&error)
177
{
178
throw
ExceptionNotFound
(QObject::tr(
"error reading file %1 : %2"
)
179
.arg(
mcsp_msRunId
.get()->getFileName())
180
.arg(error.
qwhat
()));
181
}
182
catch
(
PappsoException
&error)
183
{
184
throw
PappsoException
(QObject::tr(
"error reading file %1 : %2"
)
185
.arg(
mcsp_msRunId
.get()->getFileName())
186
.arg(error.
qwhat
()));
187
}
188
}
189
190
}
// namespace pappso
191
192
const
pappso::OboPsiModTerm
193
pappso::MsRunReader::getOboPsiModTermInstrumentModelName
()
const
194
{
195
throw
ExceptionNotFound
(
196
QObject::tr(
"instrument model name not found in %1"
).arg(
mcsp_msRunId
.get()->getFileName()));
197
}
pappso::ExceptionNotFound
Definition
exceptionnotfound.h:32
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::MsRunReaderRetentionTimeLine
collect retention times along MS run
Definition
spectrumcollectionhandlerinterface.h:127
pappso::MsRunReaderRetentionTimeLine::getRetentionTimeLine
const std::vector< double > & getRetentionTimeLine() const
Definition
spectrumcollectionhandlerinterface.cpp:237
pappso::MsRunReaderScanNumberMultiMap
provides a multimap to find quickly spectrum index from scan number
Definition
spectrumcollectionhandlerinterface.h:111
pappso::MsRunReaderTicChromatogram
calculate a TIC chromatogram
Definition
spectrumcollectionhandlerinterface.h:143
pappso::MsRunReaderTicChromatogram::getTicChromatogram
Trace getTicChromatogram() const
Definition
spectrumcollectionhandlerinterface.cpp:299
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition
msrunreader.h:194
pappso::MsRunReader::getOboPsiModTermInstrumentModelName
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
Definition
msrunreader.cpp:193
pappso::MsRunReader::MsRunReader
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
Definition
msrunreader.cpp:43
pappso::MsRunReader::mpa_multiMapScanNumber
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
Definition
msrunreader.h:195
pappso::MsRunReader::hasScanNumbers
virtual bool hasScanNumbers() const
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
Definition
msrunreader.cpp:120
pappso::MsRunReader::setMonoThread
void setMonoThread(bool is_mono_thread)
set only one is_mono_thread to true
Definition
msrunreader.cpp:68
pappso::MsRunReader::readSpectrumCollection2
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
pappso::MsRunReader::getRetentionTimeLine
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
Definition
msrunreader.cpp:126
pappso::MsRunReader::~MsRunReader
virtual ~MsRunReader()
Definition
msrunreader.cpp:61
pappso::MsRunReader::m_isMonoThread
bool m_isMonoThread
Definition
msrunreader.h:206
pappso::MsRunReader::scanNumber2SpectrumIndex
virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number)
if possible, converts a scan number into a spectrum index This is a convenient function to help trans...
Definition
msrunreader.cpp:81
pappso::MsRunReader::isMonoThread
bool isMonoThread() const
Definition
msrunreader.cpp:74
pappso::MsRunReader::getTicChromatogram
virtual Trace getTicChromatogram()
get a TIC chromatogram
Definition
msrunreader.cpp:159
pappso::MsRunReader::getMsRunId
const MsRunIdCstSPtr & getMsRunId() const
Definition
msrunreader.cpp:55
pappso::OboPsiModTerm
Definition
obopsimodterm.h:34
pappso::PappsoException
Definition
pappsoexception.h:41
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition
pappsoexception.h:66
pappso::Trace
A simple container of DataPoint instances.
Definition
trace.h:152
exceptionnotfound.h
msRunReaderSPtrMetaTypeId
int msRunReaderSPtrMetaTypeId
Definition
msrunreader.cpp:35
msrunreader.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition
msrunid.h:46
pappsomspp
core
msrun
msrunreader.cpp
Generated on
for libpappsomspp by
1.17.0