libpappsomspp
Library for mass spectrometry
timsmsrunreader.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/msrun/private/timsmsrunreader.h
3 * \date 05/09/2019
4 * \author Olivier Langella
5 * \brief MSrun file reader for native Bruker TimsTOF raw data
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2019 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 "timsmsrunreader.h"
29#include "../../exception/exceptionnotimplemented.h"
30#include "../../exception/exceptioninterrupted.h"
31#include <QDebug>
32
33using namespace pappso;
34
35TimsMsRunReader::TimsMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
36 : MsRunReader(msrun_id_csp)
37{
38 initialize();
39}
40
42{
43 msp_timsData = nullptr;
44}
45
46void
48{
49 msp_timsData = std::make_shared<TimsData>(mcsp_msRunId.get()->getFileName());
50
51 if(msp_timsData == nullptr)
52 {
53 throw PappsoException(QObject::tr("ERROR in TimsMsRunReader::initialize "
54 "msp_timsData is null for MsRunId %1")
55 .arg(mcsp_msRunId.get()->toString()));
56 }
57}
58
59
60bool
61TimsMsRunReader::accept(const QString &file_name) const
62{
63 qDebug() << file_name;
64 return true;
65}
66
67
69TimsMsRunReader::massSpectrumSPtr([[maybe_unused]] std::size_t spectrum_index)
70{
72 QObject::tr("Not yet implemented in TimsMsRunReader %1.\n").arg(__LINE__));
74}
75
76
78TimsMsRunReader::massSpectrumCstSPtr(std::size_t spectrum_index)
79{
80 return msp_timsData->getMassSpectrumCstSPtrByRawIndex(spectrum_index);
81}
82
83
85TimsMsRunReader::qualifiedMassSpectrum(std::size_t spectrum_index,
86 bool want_binary_data) const
87{
88
89 QualifiedMassSpectrum mass_spectrum;
90
91 msp_timsData->getQualifiedMassSpectrumByRawIndex(
92 getMsRunId(), mass_spectrum, spectrum_index, want_binary_data);
93 return mass_spectrum;
94}
95
96
97void
100{
102}
103
104void
107{
108 return readSpectrumCollection(handler);
109}
110
111void
113 SpectrumCollectionHandlerInterface &handler, unsigned int ms_level)
114{
115
116 qDebug();
117
118 try
119 {
120
121 msp_timsData.get()->rawReaderSpectrumCollectionByMsLevel(
122 getMsRunId(), handler, ms_level);
123 }
124
125 catch(ExceptionInterrupted &)
126 {
127 qDebug() << "Reading of MS data interrupted by the user.";
128 }
129
130 // Now let the loading handler know that the loading of the data has ended.
131 // The handler might need this "signal" to perform additional tasks or to
132 // cleanup cruft.
133
134 // qDebug() << "Loading ended";
135 handler.loadingEnded();
136}
137
138
139std::size_t
141{
142 return msp_timsData->getTotalNumberOfScans();
143}
144
145
146bool
148{
149 return false;
150}
151
152
153bool
155{
156 msp_timsData = nullptr;
157 return true;
158}
159
160bool
162{
163 if(msp_timsData == nullptr)
164 {
165 initialize();
166 }
167 return true;
168}
169
170
173 [[maybe_unused]],
174 pappso::PrecisionPtr precision
175 [[maybe_unused]]) const
176{
177 throw ExceptionNotImplemented(QObject::tr("Not implemented %1 %2 %3")
178 .arg(__FILE__)
179 .arg(__FUNCTION__)
180 .arg(__LINE__));
181}
182
185 const pappso::QualifiedMassSpectrum &mass_spectrum [[maybe_unused]],
186 pappso::PrecisionPtr precision [[maybe_unused]]) const
187{
188 throw ExceptionNotImplemented(QObject::tr("Not implemented %1 %2 %3")
189 .arg(__FILE__)
190 .arg(__FUNCTION__)
191 .arg(__LINE__));
192}
193
196{
198 return msp_timsData;
199}
200
201
202Trace
204{
205 // Use the Sqlite database to fetch the total ion current chromatogram (TIC
206 // chromatogram).
207
209
210 // The time unit here is seconds, not minutes!!!
211 return msp_timsData->getTicChromatogram();
212}
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
const MsRunIdCstSPtr & getMsRunId() const
Definition: msrunreader.cpp:56
Class representing a fully specified mass spectrum.
interface to collect spectrums from the MsRunReader class
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler, unsigned int ms_level) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
virtual bool hasScanNumbers() const override
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum index
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
virtual bool acquireDevice() override
acquire data back end device
virtual bool accept(const QString &file_name) const override
tells if the reader is able to handle this file must be implemented by private MS run reader,...
virtual TimsDataSp getTimsDataSPtr()
give an access to the underlying raw data pointer
virtual void initialize() override
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
virtual Trace getTicChromatogram() override
get a TIC chromatogram
A simple container of DataPoint instances.
Definition: trace.h:148
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
std::shared_ptr< TimsData > TimsDataSp
shared pointer on a TimsData object
Definition: timsdata.h:50
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:55
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54
std::shared_ptr< XicCoord > XicCoordSPtr
Definition: xiccoord.h:43
MSrun file reader for native Bruker TimsTOF raw data.