Loading...
Searching...
No Matches
msrunreader.cpp
Go to the documentation of this file.
/**
* \file pappsomspp/msrun/msrunreader.cpp
* \date 29/05/2018
* \author Olivier Langella
* \brief base interface to read MSrun files
*/
/*******************************************************************************
* Copyright (c) 2018 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 <QDebug>
#include <QObject>
#include "msrunreader.h"
#include "../../pappsomspp/exception/exceptionnotfound.h"
int msRunReaderSPtrMetaTypeId =
qRegisterMetaType<pappso::MsRunReaderSPtr>("pappso::MsRunReaderSPtr");
namespace pappso
{
MsRunReader::MsRunReader(MsRunIdCstSPtr &ms_run_id) : mcsp_msRunId(ms_run_id)
{
}
MsRunReader::MsRunReader(const MsRunReader &other)
: mcsp_msRunId(other.mcsp_msRunId)
{
mpa_multiMapScanNumber = nullptr;
m_isMonoThread = other.m_isMonoThread;
}
const MsRunIdCstSPtr &
MsRunReader::getMsRunId() const
{
return mcsp_msRunId;
}
MsRunReader::~MsRunReader()
{
if(mpa_multiMapScanNumber == nullptr)
delete mpa_multiMapScanNumber;
}
void
MsRunReader::setMonoThread(bool is_mono_thread)
{
m_isMonoThread = is_mono_thread;
}
bool
MsRunReader::isMonoThread() const
{
return m_isMonoThread;
}
std::size_t
MsRunReader::scanNumber2SpectrumIndex(std::size_t scan_number)
{
qDebug() << " " << mpa_multiMapScanNumber;
if(mpa_multiMapScanNumber == nullptr)
{
mpa_multiMapScanNumber = new MsRunReaderScanNumberMultiMap();
readSpectrumCollection(*mpa_multiMapScanNumber);
}
try
{
return mpa_multiMapScanNumber->getSpectrumIndexFromScanNumber(
scan_number);
}
catch(ExceptionNotFound &error)
{
throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
.arg(mcsp_msRunId.get()->getFileName())
.arg(error.qwhat()));
}
catch(PappsoException &error)
{
throw PappsoException(QObject::tr("error reading file %1 : %2")
.arg(mcsp_msRunId.get()->getFileName())
.arg(error.qwhat()));
}
}
bool
MsRunReader::hasScanNumbers() const
{
return false;
}
std::vector<double>
MsRunReader::getRetentionTimeLine()
{
qDebug();
try
{
MsRunReaderRetentionTimeLine reader_timeline;
readSpectrumCollectionByMsLevel(reader_timeline, 1);
return reader_timeline.getRetentionTimeLine();
}
catch(ExceptionNotFound &error)
{
throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
.arg(mcsp_msRunId.get()->getFileName())
.arg(error.qwhat()));
}
catch(PappsoException &error)
{
throw PappsoException(QObject::tr("error reading file %1 : %2")
.arg(mcsp_msRunId.get()->getFileName())
.arg(error.qwhat()));
}
}
Trace
MsRunReader::getTicChromatogram()
{
qDebug();
try
{
MsRunReaderTicChromatogram ms_run_reader;
readSpectrumCollection(ms_run_reader);
return ms_run_reader.getTicChromatogram();
}
catch(ExceptionNotFound &error)
{
throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
.arg(mcsp_msRunId.get()->getFileName())
.arg(error.qwhat()));
}
catch(PappsoException &error)
{
throw PappsoException(QObject::tr("error reading file %1 : %2")
.arg(mcsp_msRunId.get()->getFileName())
.arg(error.qwhat()));
}
}
} // namespace pappso
pappso::ExceptionNotFound
Definition exceptionnotfound.h:32
pappso::MsRunReaderRetentionTimeLine
collect retention times along MS run
Definition spectrumcollectionhandlerinterface.h:151
pappso::MsRunReaderRetentionTimeLine::getRetentionTimeLine
const std::vector< double > & getRetentionTimeLine() const
Definition spectrumcollectionhandlerinterface.cpp:246
pappso::MsRunReaderScanNumberMultiMap
provides a multimap to find quickly spectrum index from scan number
Definition spectrumcollectionhandlerinterface.h:133
pappso::MsRunReaderScanNumberMultiMap::getSpectrumIndexFromScanNumber
std::size_t getSpectrumIndexFromScanNumber(std::size_t scan_number) const
Definition spectrumcollectionhandlerinterface.cpp:191
pappso::MsRunReaderTicChromatogram
calculate a TIC chromatogram
Definition spectrumcollectionhandlerinterface.h:169
pappso::MsRunReaderTicChromatogram::getTicChromatogram
Trace getTicChromatogram() const
Definition spectrumcollectionhandlerinterface.cpp:305
pappso::MsRunReader
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
Definition msrunreader.h:63
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition msrunreader.h:175
pappso::MsRunReader::mpa_multiMapScanNumber
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
Definition msrunreader.h:176
pappso::MsRunReader::hasScanNumbers
virtual bool hasScanNumbers() const
tells if spectra can be accessed using scan numbers by default, it returns false. Only overrided func...
Definition msrunreader.cpp:113
pappso::MsRunReader::setMonoThread
void setMonoThread(bool is_mono_thread)
set only one is_mono_thread to true
Definition msrunreader.cpp:69
pappso::MsRunReader::getRetentionTimeLine
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
Definition msrunreader.cpp:119
pappso::MsRunReader::~MsRunReader
virtual ~MsRunReader()
Definition msrunreader.cpp:62
pappso::MsRunReader::m_isMonoThread
bool m_isMonoThread
Definition msrunreader.h:187
pappso::MsRunReader::scanNumber2SpectrumIndex
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
pappso::MsRunReader::readSpectrumCollection
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
pappso::MsRunReader::isMonoThread
bool isMonoThread() const
Definition msrunreader.cpp:75
pappso::MsRunReader::getTicChromatogram
virtual Trace getTicChromatogram()
get a TIC chromatogram
Definition msrunreader.cpp:149
pappso::MsRunReader::MsRunReader
MsRunReader(MsRunIdCstSPtr &ms_run_id)
Definition msrunreader.cpp:43
pappso::MsRunReader::readSpectrumCollectionByMsLevel
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
pappso::MsRunReader::getMsRunId
const MsRunIdCstSPtr & getMsRunId() const
Definition msrunreader.cpp:56
pappso::PappsoException
Definition pappsoexception.h:42
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition pappsoexception.h:68
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:148
msRunReaderSPtrMetaTypeId
int msRunReaderSPtrMetaTypeId
Definition msrunreader.cpp:35
msrunreader.h
base interface to read MSrun files
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:46