Loading...
Searching...
No Matches
msrunreader.h
Go to the documentation of this file.
/**
* \file pappsomspp/msrun/msrunreader.h
* \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/>.
*
******************************************************************************/
#pragma once
/////////////////////// StdLib includes
#include <memory>
#include <map>
/////////////////////// Qt includes
#include <QMutex>
/////////////////////// pappsomspp includes
#include "../trace/maptrace.h"
/////////////////////// Local includes
#include "spectrumcollectionhandlerinterface.h"
#include "msrunreadconfig.h"
#include "msrunid.h"
#include "../massspectrum/qualifiedmassspectrum.h"
#include "pappsomspp/core/msfile/msfilereader.h"
#include "../obo/obopsimodterm.h"
#include "pappsomspp/export-import-config.h"
#include "xiccoord/xiccoord.h"
namespace pappso
{
class PMSPP_LIB_DECL MsRunReader;
typedef std::shared_ptr<MsRunReader> MsRunReaderSPtr;
typedef std::shared_ptr<const MsRunReader> MsRunReaderCstSPtr;
/** @brief base class to read MSrun
* the only way to build a MsRunReader object is to use the MsRunReaderFactory
*/
class PMSPP_LIB_DECL MsRunReader
{
friend class MsFileAccessor;
public:
MsRunReader(const MsRunIdCstSPtr &ms_run_id);
MsRunReader(const MsRunReader &other);
virtual ~MsRunReader();
const MsRunIdCstSPtr &getMsRunId() const;
/** @brief get a MassSpectrumSPtr class given its spectrum index
*/
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) = 0;
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) = 0;
/** @brief get a QualifiedMassSpectrum class given its scan number
*/
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index,
bool want_binary_data = true) const = 0;
/** @brief get a xic coordinate object from a given spectrum index
*/
virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index,
PrecisionPtr precision) const = 0;
/** @brief get a xic coordinate object from a given spectrum
*/
virtual XicCoordSPtr
newXicCoordSPtrFromQualifiedMassSpectrum(const QualifiedMassSpectrum &mass_spectrum,
PrecisionPtr precision) const = 0;
/** @brief get the totat number of spectrum conained in the MSrun data file
*/
virtual std::size_t spectrumListSize() const = 0;
/** @brief function to visit an MsRunReader and get each Spectrum in a
* spectrum collection handler
*/
[[deprecated]]
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) = 0;
/** @brief function to visit an MsRunReader and get each Spectrum in a
* spectrum collection handler
*/
virtual void readSpectrumCollection2(const MsRunReadConfig &config,
SpectrumCollectionHandlerInterface &handler) = 0;
/** @brief function to visit an MsRunReader and get each Spectrum in a
* spectrum collection handler by Ms Levels
*/
virtual void readSpectrumCollectionByMsLevel(SpectrumCollectionHandlerInterface &handler,
unsigned int ms_level) = 0;
/** @brief if possible, converts a scan number into a spectrum index
* This is a convenient function to help transition from the old scan number
* (not implemented by all vendors) to more secure spectrum index (not vendor
* dependant).
* It is better to not rely on this function.
*/
virtual std::size_t scanNumber2SpectrumIndex(std::size_t scan_number);
/** @brief tells if spectra can be accessed using scan numbers
* by default, it returns false. Only overrided functions can check if scan
* numbers are available in the current file
*/
virtual bool hasScanNumbers() const;
/** @brief if possible, get the spectrum index given a string identifier
* throw a not found exception if spectrum identifier is not found
* @param spectrum_identifier string identifier of a specific spectrum
* @return the spectrum index
*/
virtual std::size_t
spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier) = 0;
/** @brief release data back end device
* if a the data back end is released, the developper has to use acquireDevice
* before using the msrunreader object
* @return bool true if done
*/
virtual bool releaseDevice() = 0;
/** @brief acquire data back end device
* @return bool true if done
*/
virtual bool acquireDevice() = 0;
/** @brief retention timeline
* get retention times along the MSrun in seconds
* @return vector of retention times (seconds)
*/
virtual std::vector<double> getRetentionTimeLine();
/** @brief get a TIC chromatogram
*
* for each retention time, computes the sum of all intensities.
* For IM-MS, combines the mobility spectra
*
* Note that, formally, a TIC chromatogram is computed only for MS1 spectra.
*
* @return a trace (x=rt, y=intensities)
*/
virtual Trace getTicChromatogram();
/** @brief set only one is_mono_thread to true
*
* this avoid to use qtconcurrent
*/
void setMonoThread(bool is_mono_thread);
bool isMonoThread() const;
/** @brief get OboPsiModTerm corresponding to the instrument model name
* child of :
* [Term]
id: MS:1000031
name: instrument model
def: "Instrument model name not including the vendor's name." [PSI:MS]
relationship: part_of MS:1000463 ! instrument
*/
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const;
protected:
MsRunIdCstSPtr mcsp_msRunId;
MsRunReaderScanNumberMultiMap *mpa_multiMapScanNumber = nullptr;
virtual void initialize() = 0;
/** @brief tells if the reader is able to handle this file
* must be implemented by private MS run reader, specific of one or more file
* format
*/
virtual bool accept(const QString &file_name) const = 0;
private:
bool m_isMonoThread = false;
};
} // namespace pappso
Q_DECLARE_METATYPE(pappso::MsRunReaderSPtr);
extern int msRunReaderSPtrMetaTypeId;
pappso::MsRunReadConfig
Definition msrunreadconfig.h:62
pappso::MsRunReaderScanNumberMultiMap
provides a multimap to find quickly spectrum index from scan number
Definition spectrumcollectionhandlerinterface.h:111
pappso::MsRunReader
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
Definition msrunreader.h:64
pappso::MsRunReader::massSpectrumCstSPtr
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index)=0
pappso::MsRunReader::spectrumStringIdentifier2SpectrumIndex
virtual std::size_t spectrumStringIdentifier2SpectrumIndex(const QString &spectrum_identifier)=0
if possible, get the spectrum index given a string identifier throw a not found exception if spectrum...
pappso::MsRunReader::spectrumListSize
virtual std::size_t spectrumListSize() const =0
get the totat number of spectrum conained in the MSrun data file
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition msrunreader.h:194
pappso::MsRunReader::acquireDevice
virtual bool acquireDevice()=0
acquire data back end device
pappso::MsRunReader::getOboPsiModTermInstrumentModelName
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName() const
get OboPsiModTerm corresponding to the instrument model name child of : [Term] id: MS:1000031 name: i...
Definition msrunreader.cpp:193
pappso::MsRunReader::accept
virtual bool accept(const QString &file_name) const =0
tells if the reader is able to handle this file must be implemented by private MS run reader,...
pappso::MsRunReader::MsRunReader
MsRunReader(const MsRunIdCstSPtr &ms_run_id)
Definition msrunreader.cpp:43
pappso::MsRunReader::newXicCoordSPtrFromSpectrumIndex
virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex(std::size_t spectrum_index, PrecisionPtr precision) const =0
get a xic coordinate object from a given spectrum index
pappso::MsRunReader::MsFileAccessor
friend class MsFileAccessor
Definition msrunreader.h:66
pappso::MsRunReader::releaseDevice
virtual bool releaseDevice()=0
release data back end device if a the data back end is released, the developper has to use acquireDev...
pappso::MsRunReader::initialize
virtual void initialize()=0
pappso::MsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum
virtual XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const QualifiedMassSpectrum &mass_spectrum, PrecisionPtr precision) const =0
get a xic coordinate object from a given spectrum
pappso::MsRunReader::mpa_multiMapScanNumber
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
Definition msrunreader.h:195
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:120
pappso::MsRunReader::setMonoThread
void setMonoThread(bool is_mono_thread)
set only one is_mono_thread to true
Definition msrunreader.cpp:68
pappso::MsRunReader::readSpectrumCollection2
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
pappso::MsRunReader::getRetentionTimeLine
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
Definition msrunreader.cpp:126
pappso::MsRunReader::m_isMonoThread
bool m_isMonoThread
Definition msrunreader.h:206
pappso::MsRunReader::massSpectrumSPtr
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index)=0
get a MassSpectrumSPtr class given its spectrum index
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:81
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::qualifiedMassSpectrum
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const =0
get a QualifiedMassSpectrum class given its scan number
pappso::MsRunReader::isMonoThread
bool isMonoThread() const
Definition msrunreader.cpp:74
pappso::MsRunReader::getTicChromatogram
virtual Trace getTicChromatogram()
get a TIC chromatogram
Definition msrunreader.cpp:159
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:55
pappso::OboPsiModTerm
Definition obopsimodterm.h:34
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition qualifiedmassspectrum.h:99
pappso::SpectrumCollectionHandlerInterface
interface to collect spectrums from the MsRunReader class
Definition spectrumcollectionhandlerinterface.h:52
pappso::Trace
A simple container of DataPoint instances.
Definition trace.h:152
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
maptrace.h
msfilereader.h
msrunid.h
msrunreadconfig.h
msRunReaderSPtrMetaTypeId
int msRunReaderSPtrMetaTypeId
Definition msrunreader.cpp:35
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(pappso::MsRunReaderSPtr)
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::MsRunReaderSPtr
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition msrunreader.h:57
pappso::MsRunReaderCstSPtr
std::shared_ptr< const MsRunReader > MsRunReaderCstSPtr
Definition msrunreader.h:58
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
pappso::MassSpectrumCstSPtr
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
Definition massspectrum.h:54
pappso::PrecisionPtr
const PrecisionBase * PrecisionPtr
Definition precision.h:122
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition massspectrum.h:53
pappso::XicCoordSPtr
std::shared_ptr< XicCoord > XicCoordSPtr
Definition xiccoord.h:44
obopsimodterm.h
qualifiedmassspectrum.h
spectrumcollectionhandlerinterface.h
base interface to read MSrun files
xiccoord.h