Loading...
Searching...
No Matches
spectrumcollectionhandlerinterface.h
Go to the documentation of this file.
/**
* \file pappsomspp/core/msrun/spectrumcollectionhandlerinterface.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 <map>
/////////////////////// Qt includes
#include <QMutex>
/////////////////////// pappsomspp includes
// #include "pappsomspp/core/trace/maptrace.h"
/////////////////////// Local includes
#include "pappsomspp/core/massspectrum/qualifiedmassspectrum.h"
#include "pappsomspp/export-import-config.h"
namespace pappso
{
/** @brief interface to collect spectrums from the MsRunReader class
*/
class PMSPP_LIB_DECL SpectrumCollectionHandlerInterface
{
public:
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) = 0;
/** @brief tells if we need the peak list (if we want the binary data) for
* each spectrum
*/
virtual bool needPeakList() const = 0;
/** @brief tells if we need the peak list (if we want the binary data) for
* each spectrum, given an MS level
*/
virtual bool needMsLevelPeakList(unsigned int ms_level) const final;
/** @brief tells if we need the peak list given
*/
virtual void setNeedMsLevelPeakList(unsigned int ms_level, bool want_peak_list) final;
virtual bool shouldStop();
virtual void loadingEnded();
virtual void spectrumListHasSize(std::size_t size);
/** @brief use threads to read a spectrum by batch of batch_size
* @param is_read_ahead boolean to use threads or not
*/
virtual void setReadAhead(bool is_read_ahead) final;
/** @brief tells if we want to read ahead spectrum
*/
virtual bool isReadAhead() const;
private:
bool m_isReadAhead = false;
std::vector<bool> m_needPeakListByMsLevel = {
true, true, true, true, true, true, true, true, true, true, true, true, true, true, true};
};
/** @brief example of interface to count MS levels of all spectrum in an MSrun
*/
class PMSPP_LIB_DECL MsRunSimpleStatistics : public SpectrumCollectionHandlerInterface
{
private:
std::vector<unsigned long> m_countMsLevelSpectrum;
public:
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override;
virtual bool needPeakList() const override;
virtual void loadingEnded() override;
unsigned long getMsLevelCount(unsigned int ms_level) const;
unsigned long getTotalCount() const;
};
/** @brief provides a multimap to find quickly spectrum index from scan number
*/
class PMSPP_LIB_DECL MsRunReaderScanNumberMultiMap : public SpectrumCollectionHandlerInterface
{
private:
std::multimap<std::size_t, std::size_t> m_mmap_scan2index;
public:
MsRunReaderScanNumberMultiMap();
virtual ~MsRunReaderScanNumberMultiMap();
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override;
virtual bool needPeakList() const override;
std::size_t getSpectrumIndexFromScanNumber(std::size_t scan_number) const;
};
/** @brief collect retention times along MS run */
class PMSPP_LIB_DECL MsRunReaderRetentionTimeLine : public SpectrumCollectionHandlerInterface
{
private:
std::vector<double> m_retention_time_list;
public:
MsRunReaderRetentionTimeLine();
virtual ~MsRunReaderRetentionTimeLine();
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override;
virtual bool needPeakList() const override;
const std::vector<double> &getRetentionTimeLine() const;
};
/** @brief calculate a TIC chromatogram */
class PMSPP_LIB_DECL MsRunReaderTicChromatogram : public SpectrumCollectionHandlerInterface
{
public:
MsRunReaderTicChromatogram();
virtual ~MsRunReaderTicChromatogram();
virtual void
setQualifiedMassSpectrum(const QualifiedMassSpectrum &qualified_mass_spectrum) override;
virtual bool needPeakList() const override;
Trace getTicChromatogram() const;
private:
// MapTrace m_ticChromMapTrace;
Trace m_ticChromTrace;
};
/** @brief Load all qualified spectrum into a vector */
class PMSPP_LIB_DECL MsRunQualifiedSpectrumLoader : public SpectrumCollectionHandlerInterface
{
public:
MsRunQualifiedSpectrumLoader();
virtual ~MsRunQualifiedSpectrumLoader();
virtual void
setQualifiedMassSpectrum(const QualifiedMassSpectrum &qualified_mass_spectrum) override;
virtual bool needPeakList() const override;
virtual void spectrumListHasSize(std::size_t size) override;
const std::vector<QualifiedMassSpectrum> &getQualifiedMassSpectrumList() const;
void clear();
private:
std::vector<QualifiedMassSpectrum> m_qualifiedSpectrumList;
};
} // namespace pappso
pappso::MsRunQualifiedSpectrumLoader::getQualifiedMassSpectrumList
const std::vector< QualifiedMassSpectrum > & getQualifiedMassSpectrumList() const
Definition spectrumcollectionhandlerinterface.cpp:336
pappso::MsRunQualifiedSpectrumLoader::MsRunQualifiedSpectrumLoader
MsRunQualifiedSpectrumLoader()
Definition spectrumcollectionhandlerinterface.cpp:305
pappso::MsRunQualifiedSpectrumLoader::spectrumListHasSize
virtual void spectrumListHasSize(std::size_t size) override
Definition spectrumcollectionhandlerinterface.cpp:322
pappso::MsRunQualifiedSpectrumLoader::needPeakList
virtual bool needPeakList() const override
tells if we need the peak list (if we want the binary data) for each spectrum
Definition spectrumcollectionhandlerinterface.cpp:316
pappso::MsRunQualifiedSpectrumLoader::clear
void clear()
Definition spectrumcollectionhandlerinterface.cpp:342
pappso::MsRunQualifiedSpectrumLoader::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &qualified_mass_spectrum) override
Definition spectrumcollectionhandlerinterface.cpp:328
pappso::MsRunQualifiedSpectrumLoader::m_qualifiedSpectrumList
std::vector< QualifiedMassSpectrum > m_qualifiedSpectrumList
Definition spectrumcollectionhandlerinterface.h:175
pappso::MsRunReaderRetentionTimeLine::getRetentionTimeLine
const std::vector< double > & getRetentionTimeLine() const
Definition spectrumcollectionhandlerinterface.cpp:237
pappso::MsRunReaderRetentionTimeLine::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override
Definition spectrumcollectionhandlerinterface.cpp:229
pappso::MsRunReaderRetentionTimeLine::needPeakList
virtual bool needPeakList() const override
tells if we need the peak list (if we want the binary data) for each spectrum
Definition spectrumcollectionhandlerinterface.cpp:222
pappso::MsRunReaderRetentionTimeLine::MsRunReaderRetentionTimeLine
MsRunReaderRetentionTimeLine()
Definition spectrumcollectionhandlerinterface.cpp:209
pappso::MsRunReaderRetentionTimeLine::m_retention_time_list
std::vector< double > m_retention_time_list
Definition spectrumcollectionhandlerinterface.h:129
pappso::MsRunReaderScanNumberMultiMap::needPeakList
virtual bool needPeakList() const override
tells if we need the peak list (if we want the binary data) for each spectrum
Definition spectrumcollectionhandlerinterface.cpp:159
pappso::MsRunReaderScanNumberMultiMap::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override
Definition spectrumcollectionhandlerinterface.cpp:165
pappso::MsRunReaderScanNumberMultiMap::getSpectrumIndexFromScanNumber
std::size_t getSpectrumIndexFromScanNumber(std::size_t scan_number) const
Definition spectrumcollectionhandlerinterface.cpp:186
pappso::MsRunReaderScanNumberMultiMap::m_mmap_scan2index
std::multimap< std::size_t, std::size_t > m_mmap_scan2index
Definition spectrumcollectionhandlerinterface.h:113
pappso::MsRunReaderScanNumberMultiMap::MsRunReaderScanNumberMultiMap
MsRunReaderScanNumberMultiMap()
Definition spectrumcollectionhandlerinterface.cpp:146
pappso::MsRunReaderTicChromatogram::m_ticChromTrace
Trace m_ticChromTrace
Definition spectrumcollectionhandlerinterface.h:155
pappso::MsRunReaderTicChromatogram::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &qualified_mass_spectrum) override
Definition spectrumcollectionhandlerinterface.cpp:260
pappso::MsRunReaderTicChromatogram::MsRunReaderTicChromatogram
MsRunReaderTicChromatogram()
Definition spectrumcollectionhandlerinterface.cpp:242
pappso::MsRunReaderTicChromatogram::needPeakList
virtual bool needPeakList() const override
tells if we need the peak list (if we want the binary data) for each spectrum
Definition spectrumcollectionhandlerinterface.cpp:253
pappso::MsRunReaderTicChromatogram::getTicChromatogram
Trace getTicChromatogram() const
Definition spectrumcollectionhandlerinterface.cpp:299
pappso::MsRunSimpleStatistics
example of interface to count MS levels of all spectrum in an MSrun
Definition spectrumcollectionhandlerinterface.h:94
pappso::MsRunSimpleStatistics::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum) override
Definition spectrumcollectionhandlerinterface.cpp:105
pappso::MsRunSimpleStatistics::getTotalCount
unsigned long getTotalCount() const
Definition spectrumcollectionhandlerinterface.cpp:135
pappso::MsRunSimpleStatistics::loadingEnded
virtual void loadingEnded() override
Definition spectrumcollectionhandlerinterface.cpp:97
pappso::MsRunSimpleStatistics::m_countMsLevelSpectrum
std::vector< unsigned long > m_countMsLevelSpectrum
Definition spectrumcollectionhandlerinterface.h:96
pappso::MsRunSimpleStatistics::needPeakList
virtual bool needPeakList() const override
tells if we need the peak list (if we want the binary data) for each spectrum
Definition spectrumcollectionhandlerinterface.cpp:90
pappso::MsRunSimpleStatistics::getMsLevelCount
unsigned long getMsLevelCount(unsigned int ms_level) const
Definition spectrumcollectionhandlerinterface.cpp:124
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::SpectrumCollectionHandlerInterface::shouldStop
virtual bool shouldStop()
Definition spectrumcollectionhandlerinterface.cpp:38
pappso::SpectrumCollectionHandlerInterface::isReadAhead
virtual bool isReadAhead() const
tells if we want to read ahead spectrum
Definition spectrumcollectionhandlerinterface.cpp:57
pappso::SpectrumCollectionHandlerInterface::needPeakList
virtual bool needPeakList() const =0
tells if we need the peak list (if we want the binary data) for each spectrum
pappso::SpectrumCollectionHandlerInterface::loadingEnded
virtual void loadingEnded()
Definition spectrumcollectionhandlerinterface.cpp:43
pappso::SpectrumCollectionHandlerInterface::needMsLevelPeakList
virtual bool needMsLevelPeakList(unsigned int ms_level) const final
tells if we need the peak list (if we want the binary data) for each spectrum, given an MS level
Definition spectrumcollectionhandlerinterface.cpp:63
pappso::SpectrumCollectionHandlerInterface::setReadAhead
virtual void setReadAhead(bool is_read_ahead) final
use threads to read a spectrum by batch of batch_size
Definition spectrumcollectionhandlerinterface.cpp:51
pappso::SpectrumCollectionHandlerInterface::setNeedMsLevelPeakList
virtual void setNeedMsLevelPeakList(unsigned int ms_level, bool want_peak_list) final
tells if we need the peak list given
Definition spectrumcollectionhandlerinterface.cpp:80
pappso::SpectrumCollectionHandlerInterface::m_needPeakListByMsLevel
std::vector< bool > m_needPeakListByMsLevel
Definition spectrumcollectionhandlerinterface.h:86
pappso::SpectrumCollectionHandlerInterface::spectrumListHasSize
virtual void spectrumListHasSize(std::size_t size)
Definition spectrumcollectionhandlerinterface.cpp:47
pappso::SpectrumCollectionHandlerInterface::m_isReadAhead
bool m_isReadAhead
Definition spectrumcollectionhandlerinterface.h:84
pappso::SpectrumCollectionHandlerInterface::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
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
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
qualifiedmassspectrum.h