timsmsrunreader.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/msrun/private/timsmsrunreader.h
* \date 05/09/2019
* \author Olivier Langella
* \brief MSrun file reader for native Bruker TimsTOF raw data
*/
/*******************************************************************************
* Copyright (c) 2019 Olivier Langella <Olivier.Langella@u-psud.fr>.
*
* This file is part of the PAPPSOms++ library.
*
* PAPPSOms++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PAPPSOms++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "timsmsrunreader.h"
#include "../../exception/exceptionnotimplemented.h"
#include <QDebug>
using namespace pappso;
TimsMsRunReader::TimsMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
: MsRunReader(msrun_id_csp)
{
initialize();
}
TimsMsRunReader::~TimsMsRunReader()
{
msp_timsData = nullptr;
}
void
TimsMsRunReader::initialize()
{
msp_timsData = std::make_shared<TimsData>(mcsp_msRunId.get()->getFileName());
if(msp_timsData == nullptr)
{
throw PappsoException(QObject::tr("ERROR in TimsMsRunReader::initialize "
"msp_timsData is null for MsRunId %1")
.arg(mcsp_msRunId.get()->toString()));
}
}
bool
TimsMsRunReader::accept(const QString &file_name) const
{
qDebug() << file_name;
return true;
}
pappso::MassSpectrumSPtr
TimsMsRunReader::massSpectrumSPtr([[maybe_unused]] std::size_t spectrum_index)
{
throw ExceptionNotImplemented(
QObject::tr("Not yet implemented in TimsMsRunReader %1.\n").arg(__LINE__));
return pappso::MassSpectrumSPtr();
}
pappso::MassSpectrumCstSPtr
TimsMsRunReader::massSpectrumCstSPtr(std::size_t spectrum_index)
{
return msp_timsData->getMassSpectrumCstSPtrByRawIndex(spectrum_index);
}
QualifiedMassSpectrum
TimsMsRunReader::qualifiedMassSpectrum(std::size_t spectrum_index,
bool want_binary_data) const
{
QualifiedMassSpectrum mass_spectrum;
msp_timsData->getQualifiedMassSpectrumByRawIndex(
getMsRunId(), mass_spectrum, spectrum_index, want_binary_data);
return mass_spectrum;
}
void
TimsMsRunReader::readSpectrumCollection(
SpectrumCollectionHandlerInterface &handler)
{
readSpectrumCollectionByMsLevel(handler, 0);
}
void
TimsMsRunReader::readSpectrumCollectionByMsLevel(
SpectrumCollectionHandlerInterface &handler, unsigned int ms_level)
{
qDebug();
msp_timsData.get()->rawReaderSpectrumCollectionByMsLevel(
getMsRunId(), handler, ms_level);
// Now let the loading handler know that the loading of the data has ended.
// The handler might need this "signal" to perform additional tasks or to
// cleanup cruft.
// qDebug() << "Loading ended";
handler.loadingEnded();
}
std::size_t
TimsMsRunReader::spectrumListSize() const
{
return msp_timsData->getTotalNumberOfScans();
}
bool
TimsMsRunReader::hasScanNumbers() const
{
return false;
}
bool
TimsMsRunReader::releaseDevice()
{
msp_timsData = nullptr;
return true;
}
bool
TimsMsRunReader::acquireDevice()
{
if(msp_timsData == nullptr)
{
initialize();
}
return true;
}
XicCoordSPtr
TimsMsRunReader::newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index
[[maybe_unused]],
pappso::PrecisionPtr precision
[[maybe_unused]]) const
{
throw ExceptionNotImplemented(QObject::tr("Not implemented %1 %2 %3")
.arg(__FILE__)
.arg(__FUNCTION__)
.arg(__LINE__));
}
XicCoordSPtr
TimsMsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum(
const pappso::QualifiedMassSpectrum &mass_spectrum [[maybe_unused]],
pappso::PrecisionPtr precision [[maybe_unused]]) const
{
throw ExceptionNotImplemented(QObject::tr("Not implemented %1 %2 %3")
.arg(__FILE__)
.arg(__FUNCTION__)
.arg(__LINE__));
}
TimsDataSp
TimsMsRunReader::getTimsDataSPtr()
{
acquireDevice();
return msp_timsData;
}
Trace
TimsMsRunReader::getTicChromatogram()
{
// Use the Sqlite database to fetch the total ion current chromatogram (TIC
// chromatogram).
acquireDevice();
return msp_timsData->getTicChromatogram();
}
pappso::ExceptionNotImplemented
Definition: exceptionnotimplemented.h:32
pappso::MsRunReader
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
Definition: msrunreader.h:191
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition: msrunreader.h:282
pappso::MsRunReader::getMsRunId
const MsRunIdCstSPtr & getMsRunId() const
Definition: msrunreader.cpp:269
pappso::PappsoException
Definition: pappsoexception.h:42
pappso::PrecisionBase
Definition: precision.h:44
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition: qualifiedmassspectrum.h:85
pappso::SpectrumCollectionHandlerInterface
interface to collect spectrums from the MsRunReader class
Definition: msrunreader.h:56
pappso::SpectrumCollectionHandlerInterface::loadingEnded
virtual void loadingEnded()
Definition: msrunreader.cpp:48
pappso::TimsMsRunReader::TimsMsRunReader
TimsMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
Definition: timsmsrunreader.cpp:34
pappso::TimsMsRunReader::readSpectrumCollection
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
Definition: timsmsrunreader.cpp:96
pappso::TimsMsRunReader::readSpectrumCollectionByMsLevel
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
Definition: timsmsrunreader.cpp:104
pappso::TimsMsRunReader::massSpectrumCstSPtr
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
Definition: timsmsrunreader.cpp:76
pappso::TimsMsRunReader::massSpectrumSPtr
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
Definition: timsmsrunreader.cpp:67
pappso::TimsMsRunReader::hasScanNumbers
virtual bool hasScanNumbers() const override
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
Definition: timsmsrunreader.cpp:131
pappso::TimsMsRunReader::newXicCoordSPtrFromSpectrumIndex
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum index
Definition: timsmsrunreader.cpp:156
pappso::TimsMsRunReader::qualifiedMassSpectrum
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
Definition: timsmsrunreader.cpp:83
pappso::TimsMsRunReader::releaseDevice
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
Definition: timsmsrunreader.cpp:138
pappso::TimsMsRunReader::acquireDevice
virtual bool acquireDevice() override
acquire data back end device
Definition: timsmsrunreader.cpp:145
pappso::TimsMsRunReader::accept
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,...
Definition: timsmsrunreader.cpp:59
pappso::TimsMsRunReader::getTimsDataSPtr
virtual TimsDataSp getTimsDataSPtr()
give an access to the underlying raw data pointer
Definition: timsmsrunreader.cpp:179
pappso::TimsMsRunReader::initialize
virtual void initialize() override
Definition: timsmsrunreader.cpp:46
pappso::TimsMsRunReader::spectrumListSize
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
Definition: timsmsrunreader.cpp:124
pappso::TimsMsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
Definition: timsmsrunreader.cpp:168
pappso::TimsMsRunReader::~TimsMsRunReader
virtual ~TimsMsRunReader()
Definition: timsmsrunreader.cpp:40
pappso::TimsMsRunReader::msp_timsData
TimsDataSp msp_timsData
Definition: timsmsrunreader.h:94
pappso::TimsMsRunReader::getTicChromatogram
virtual Trace getTicChromatogram() override
Definition: timsmsrunreader.cpp:187
pappso::Trace
A simple container of DataPoint instances.
Definition: trace.h:148
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:44
pappso::TimsDataSp
std::shared_ptr< TimsData > TimsDataSp
shared pointer on a TimsData object
Definition: timsdata.h:46
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition: massspectrum.h:55
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition: xiccoord.h:41
timsmsrunreader.h
MSrun file reader for native Bruker TimsTOF raw data.