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"
34
35
37 qRegisterMetaType<pappso::MsRunReaderSPtr>("pappso::MsRunReaderSPtr");
38
39
40namespace pappso
41{
42
43
45{
46}
47
53
54
55const MsRunIdCstSPtr &
57{
58 return mcsp_msRunId;
59}
60
61
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 {
89
90 MsRunReadConfig config;
91 std::vector<size_t> ms_levels;
92 for(std::size_t i = 1; i < 9; i++)
93 {
94 ms_levels.push_back(i);
95 }
96 config.setMsLevels(ms_levels);
97 config.setNeedPeakList(false);
99 }
100 try
101 {
102 return mpa_multiMapScanNumber->getSpectrumIndexFromScanNumber(scan_number);
103 }
104
105 catch(ExceptionNotFound &error)
106 {
107 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
108 .arg(mcsp_msRunId.get()->getFileName())
109 .arg(error.qwhat()));
110 }
111 catch(PappsoException &error)
112 {
113 throw PappsoException(QObject::tr("error reading file %1 : %2")
114 .arg(mcsp_msRunId.get()->getFileName())
115 .arg(error.qwhat()));
116 }
117}
118
119
120bool
122{
123 return false;
124}
125
126std::vector<double>
128{
129 qDebug();
130
131 try
132 {
133
134 MsRunReaderRetentionTimeLine reader_timeline;
135 MsRunReadConfig config;
136 config.setMsLevels({1});
137 config.setNeedPeakList(false);
138 // readSpectrumCollectionByMsLevel(reader_timeline, 1);
139 readSpectrumCollection2(config, reader_timeline);
140
141 return reader_timeline.getRetentionTimeLine();
142 }
143
144 catch(ExceptionNotFound &error)
145 {
146 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
147 .arg(mcsp_msRunId.get()->getFileName())
148 .arg(error.qwhat()));
149 }
150 catch(PappsoException &error)
151 {
152 throw PappsoException(QObject::tr("error reading file %1 : %2")
153 .arg(mcsp_msRunId.get()->getFileName())
154 .arg(error.qwhat()));
155 }
156}
157
158
159Trace
161{
162 qDebug();
163
164 try
165 {
166 MsRunReaderTicChromatogram ms_run_reader;
167
168 MsRunReadConfig config;
169 config.setMsLevels({1});
170 config.setNeedPeakList(true);
171 // readSpectrumCollectionByMsLevel(reader_timeline, 1);
172 readSpectrumCollection2(config, ms_run_reader);
173
174 return ms_run_reader.getTicChromatogram();
175 }
176
177 catch(ExceptionNotFound &error)
178 {
179 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
180 .arg(mcsp_msRunId.get()->getFileName())
181 .arg(error.qwhat()));
182 }
183 catch(PappsoException &error)
184 {
185 throw PappsoException(QObject::tr("error reading file %1 : %2")
186 .arg(mcsp_msRunId.get()->getFileName())
187 .arg(error.qwhat()));
188 }
189}
190
191} // namespace pappso
192
195{
196 throw ExceptionNotFound(
197 QObject::tr("instrument model name not found in %1").arg(mcsp_msRunId.get()->getFileName()));
198}
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
MsRunIdCstSPtr mcsp_msRunId
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
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
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
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...
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:152
int msRunReaderSPtrMetaTypeId
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