libpappsomspp
Library for mass spectrometry
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"
33
34
36 qRegisterMetaType<pappso::MsRunReaderSPtr>("pappso::MsRunReaderSPtr");
37
38
39namespace pappso
40{
41
42
44 : mcsp_msRunId(ms_run_id)
45{
46}
47
49 : mcsp_msRunId(other.mcsp_msRunId)
50{
51 mpa_multiMapScanNumber = nullptr;
53}
54
55
56const MsRunIdCstSPtr &
58{
59 return mcsp_msRunId;
60}
61
62
68
69void
70MsRunReader::setMonoThread(bool is_mono_thread)
71{
72 m_isMonoThread = is_mono_thread;
73}
74
75bool
77{
78 return m_isMonoThread;
79}
80
81
82std::size_t
84{
85 qDebug() << " " << mpa_multiMapScanNumber;
86
87 if(mpa_multiMapScanNumber == nullptr)
88 {
91 }
92 try
93 {
95 scan_number);
96 }
97
98 catch(ExceptionNotFound &error)
99 {
100 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
101 .arg(mcsp_msRunId.get()->getFileName())
102 .arg(error.qwhat()));
103 }
104 catch(PappsoException &error)
105 {
106 throw PappsoException(QObject::tr("error reading file %1 : %2")
107 .arg(mcsp_msRunId.get()->getFileName())
108 .arg(error.qwhat()));
109 }
110}
111
112
113bool
115{
116 return false;
117}
118
119std::vector<double>
121{
122 qDebug();
123
124 try
125 {
126
127 MsRunReaderRetentionTimeLine reader_timeline;
128 MsRunReadConfig config;
129 config.setMsLevels({1});
130 config.setNeedPeakList(false);
131 // readSpectrumCollectionByMsLevel(reader_timeline, 1);
132 readSpectrumCollection2(config, reader_timeline);
133
134 return reader_timeline.getRetentionTimeLine();
135 }
136
137 catch(ExceptionNotFound &error)
138 {
139 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
140 .arg(mcsp_msRunId.get()->getFileName())
141 .arg(error.qwhat()));
142 }
143 catch(PappsoException &error)
144 {
145 throw PappsoException(QObject::tr("error reading file %1 : %2")
146 .arg(mcsp_msRunId.get()->getFileName())
147 .arg(error.qwhat()));
148 }
149}
150
151
152Trace
154{
155 qDebug();
156
157 try
158 {
159 MsRunReaderTicChromatogram ms_run_reader;
160
161 readSpectrumCollection(ms_run_reader);
162
163 return ms_run_reader.getTicChromatogram();
164 }
165
166 catch(ExceptionNotFound &error)
167 {
168 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
169 .arg(mcsp_msRunId.get()->getFileName())
170 .arg(error.qwhat()));
171 }
172 catch(PappsoException &error)
173 {
174 throw PappsoException(QObject::tr("error reading file %1 : %2")
175 .arg(mcsp_msRunId.get()->getFileName())
176 .arg(error.qwhat()));
177 }
178}
179
180
181} // namespace pappso
void setNeedPeakList(bool need_peak_list)
void setMsLevels(std::vector< std::size_t > ms_levels)
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
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
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
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
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...
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
bool isMonoThread() const
virtual Trace getTicChromatogram()
get a TIC chromatogram
const MsRunIdCstSPtr & getMsRunId() const
virtual const QString & qwhat() const
A simple container of DataPoint instances.
Definition trace.h:148
int msRunReaderSPtrMetaTypeId
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