libpappsomspp
Library for mass spectrometry
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/exception/exceptionnotfound.h"
33
34
36 qRegisterMetaType<pappso::MsRunReaderSPtr>("pappso::MsRunReaderSPtr");
37
38
39namespace pappso
40{
41
42
43MsRunReader::MsRunReader(MsRunIdCstSPtr &ms_run_id) : mcsp_msRunId(ms_run_id)
44{
45}
46
48 : mcsp_msRunId(other.mcsp_msRunId)
49{
50 mpa_multiMapScanNumber = nullptr;
52}
53
54
55const MsRunIdCstSPtr &
57{
58 return mcsp_msRunId;
59}
60
61
63{
64 if(mpa_multiMapScanNumber == nullptr)
66}
67
68void
69MsRunReader::setMonoThread(bool is_mono_thread)
70{
71 m_isMonoThread = is_mono_thread;
72}
73
74bool
76{
77 return m_isMonoThread;
78}
79
80
81std::size_t
83{
84 qDebug() << " " << mpa_multiMapScanNumber;
85
86 if(mpa_multiMapScanNumber == nullptr)
87 {
90 }
91 try
92 {
94 scan_number);
95 }
96
97 catch(ExceptionNotFound &error)
98 {
99 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
100 .arg(mcsp_msRunId.get()->getFileName())
101 .arg(error.qwhat()));
102 }
103 catch(PappsoException &error)
104 {
105 throw PappsoException(QObject::tr("error reading file %1 : %2")
106 .arg(mcsp_msRunId.get()->getFileName())
107 .arg(error.qwhat()));
108 }
109}
110
111
112bool
114{
115 return false;
116}
117
118std::vector<double>
120{
121 qDebug();
122
123 try
124 {
125
126 MsRunReaderRetentionTimeLine reader_timeline;
127
128 readSpectrumCollectionByMsLevel(reader_timeline, 1);
129
130 return reader_timeline.getRetentionTimeLine();
131 }
132
133 catch(ExceptionNotFound &error)
134 {
135 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
136 .arg(mcsp_msRunId.get()->getFileName())
137 .arg(error.qwhat()));
138 }
139 catch(PappsoException &error)
140 {
141 throw PappsoException(QObject::tr("error reading file %1 : %2")
142 .arg(mcsp_msRunId.get()->getFileName())
143 .arg(error.qwhat()));
144 }
145}
146
147
148Trace
150{
151 qDebug();
152
153 try
154 {
155 MsRunReaderTicChromatogram ms_run_reader;
156
157 readSpectrumCollection(ms_run_reader);
158
159 return ms_run_reader.getTicChromatogram();
160 }
161
162 catch(ExceptionNotFound &error)
163 {
164 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
165 .arg(mcsp_msRunId.get()->getFileName())
166 .arg(error.qwhat()));
167 }
168 catch(PappsoException &error)
169 {
170 throw PappsoException(QObject::tr("error reading file %1 : %2")
171 .arg(mcsp_msRunId.get()->getFileName())
172 .arg(error.qwhat()));
173 }
174}
175
176
177} // namespace pappso
const std::vector< double > & getRetentionTimeLine() const
provides a multimap to find quickly spectrum index from scan number
std::size_t getSpectrumIndexFromScanNumber(std::size_t scan_number) const
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
Definition: msrunreader.h:63
MsRunIdCstSPtr mcsp_msRunId
Definition: msrunreader.h:175
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
Definition: msrunreader.h:176
virtual bool hasScanNumbers() const
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
void setMonoThread(bool is_mono_thread)
set only one is_mono_thread to true
Definition: msrunreader.cpp:69
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
virtual ~MsRunReader()
Definition: msrunreader.cpp:62
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:82
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
bool isMonoThread() const
Definition: msrunreader.cpp:75
virtual Trace getTicChromatogram()
get a TIC chromatogram
MsRunReader(MsRunIdCstSPtr &ms_run_id)
Definition: msrunreader.cpp:43
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler, unsigned int ms_level)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
const MsRunIdCstSPtr & getMsRunId() const
Definition: msrunreader.cpp:56
virtual const QString & qwhat() const
A simple container of DataPoint instances.
Definition: trace.h:148
int msRunReaderSPtrMetaTypeId
Definition: msrunreader.cpp:35
base interface to read MSrun files
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:46