libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::MsRunReader Class Referenceabstract

base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory More...

#include <msrunreader.h>

Inheritance diagram for pappso::MsRunReader:
pappso::BafAsciiMsRunReader pappso::MzcborMsRunReader pappso::PwizMsRunReader pappso::TimsMsRunReaderBase pappso::XyMsRunReader pappso::TimsFramesMsRunReader pappso::TimsMsRunReader pappso::TimsMsRunReaderDia pappso::TimsMsRunReaderMs2 pappso::TimsMsRunReaderMs2Selected

Public Member Functions

 MsRunReader (const MsRunIdCstSPtr &ms_run_id)
 
 MsRunReader (const MsRunReader &other)
 
virtual ~MsRunReader ()
 
const MsRunIdCstSPtrgetMsRunId () const
 
virtual MassSpectrumSPtr massSpectrumSPtr (std::size_t spectrum_index)=0
 get a MassSpectrumSPtr class given its spectrum index
 
virtual MassSpectrumCstSPtr massSpectrumCstSPtr (std::size_t spectrum_index)=0
 
virtual QualifiedMassSpectrum qualifiedMassSpectrum (std::size_t spectrum_index, bool want_binary_data=true) const =0
 get a QualifiedMassSpectrum class given its scan number
 
virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex (std::size_t spectrum_index, PrecisionPtr precision) const =0
 get a xic coordinate object from a given spectrum index
 
virtual XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum (const QualifiedMassSpectrum &mass_spectrum, PrecisionPtr precision) const =0
 get a xic coordinate object from a given spectrum
 
virtual std::size_t spectrumListSize () const =0
 get the totat number of spectrum conained in the MSrun data file
 
virtual void readSpectrumCollection (SpectrumCollectionHandlerInterface &handler)=0
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
 
virtual void readSpectrumCollection2 (const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
 
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
 
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 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 bool hasScanNumbers () const
 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 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 identifier is not found
 
virtual bool releaseDevice ()=0
 release data back end device if a the data back end is released, the developper has to use acquireDevice before using the msrunreader object
 
virtual bool acquireDevice ()=0
 acquire data back end device
 
virtual std::vector< double > getRetentionTimeLine ()
 retention timeline get retention times along the MSrun in seconds
 
virtual Trace getTicChromatogram ()
 get a TIC chromatogram
 
void setMonoThread (bool is_mono_thread)
 set only one is_mono_thread to true
 
bool isMonoThread () const
 
virtual const OboPsiModTerm getOboPsiModTermInstrumentModelName () const
 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
 

Protected Member Functions

virtual void initialize ()=0
 
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, specific of one or more file format
 

Protected Attributes

MsRunIdCstSPtr mcsp_msRunId
 
MsRunReaderScanNumberMultiMapmpa_multiMapScanNumber = nullptr
 

Private Attributes

bool m_isMonoThread = false
 

Friends

class MsFileAccessor
 

Detailed Description

base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory

Definition at line 63 of file msrunreader.h.

Constructor & Destructor Documentation

◆ MsRunReader() [1/2]

pappso::MsRunReader::MsRunReader ( const MsRunIdCstSPtr ms_run_id)

Definition at line 43 of file msrunreader.cpp.

43 : mcsp_msRunId(ms_run_id)
44{
45}
MsRunIdCstSPtr mcsp_msRunId

◆ MsRunReader() [2/2]

pappso::MsRunReader::MsRunReader ( const MsRunReader other)

Definition at line 47 of file msrunreader.cpp.

47 : mcsp_msRunId(other.mcsp_msRunId)
48{
49 mpa_multiMapScanNumber = nullptr;
50 m_isMonoThread = other.m_isMonoThread;
51}
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber

References m_isMonoThread, and mpa_multiMapScanNumber.

◆ ~MsRunReader()

pappso::MsRunReader::~MsRunReader ( )
virtual

Definition at line 61 of file msrunreader.cpp.

62{
63 if(mpa_multiMapScanNumber == nullptr)
65}

References mpa_multiMapScanNumber.

Member Function Documentation

◆ accept()

virtual bool pappso::MsRunReader::accept ( const QString &  file_name) const
protectedpure virtual

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

Implemented in pappso::BafAsciiMsRunReader, pappso::MzcborMsRunReader, pappso::PwizMsRunReader, pappso::TimsMsRunReaderBase, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReaderMs2Selected, and pappso::XyMsRunReader.

◆ acquireDevice()

virtual bool pappso::MsRunReader::acquireDevice ( )
pure virtual

◆ getMsRunId()

◆ getOboPsiModTermInstrumentModelName()

const pappso::OboPsiModTerm pappso::MsRunReader::getOboPsiModTermInstrumentModelName ( ) const
virtual

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

Reimplemented in pappso::MzcborMsRunReader, pappso::PwizMsRunReader, and pappso::TimsMsRunReaderBase.

Definition at line 193 of file msrunreader.cpp.

194{
195 throw ExceptionNotFound(
196 QObject::tr("instrument model name not found in %1").arg(mcsp_msRunId.get()->getFileName()));
197}

References mcsp_msRunId.

◆ getRetentionTimeLine()

std::vector< double > pappso::MsRunReader::getRetentionTimeLine ( )
virtual

retention timeline get retention times along the MSrun in seconds

Returns
vector of retention times (seconds)

Reimplemented in pappso::MzcborMsRunReader, pappso::TimsMsRunReaderBase, and pappso::TimsMsRunReaderMs2.

Definition at line 126 of file msrunreader.cpp.

127{
128 qDebug();
129
130 try
131 {
132
133 MsRunReaderRetentionTimeLine reader_timeline;
134 MsRunReadConfig config;
135 config.setMsLevels({1});
136 config.setNeedPeakList(false);
137 // readSpectrumCollectionByMsLevel(reader_timeline, 1);
138 readSpectrumCollection2(config, reader_timeline);
139
140 return reader_timeline.getRetentionTimeLine();
141 }
142
143 catch(ExceptionNotFound &error)
144 {
145 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
146 .arg(mcsp_msRunId.get()->getFileName())
147 .arg(error.qwhat()));
148 }
149 catch(PappsoException &error)
150 {
151 throw PappsoException(QObject::tr("error reading file %1 : %2")
152 .arg(mcsp_msRunId.get()->getFileName())
153 .arg(error.qwhat()));
154 }
155}
virtual void readSpectrumCollection2(const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

References pappso::MsRunReaderRetentionTimeLine::getRetentionTimeLine(), mcsp_msRunId, pappso::PappsoException::qwhat(), readSpectrumCollection2(), pappso::MsRunReadConfig::setMsLevels(), and pappso::MsRunReadConfig::setNeedPeakList().

Referenced by pappso::MzcborMsRunReader::getRetentionTimeLine().

◆ getTicChromatogram()

Trace pappso::MsRunReader::getTicChromatogram ( )
virtual

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.

Returns
a trace (x=rt, y=intensities)

Reimplemented in pappso::MzcborMsRunReader, pappso::TimsMsRunReaderBase, and pappso::TimsMsRunReaderMs2.

Definition at line 159 of file msrunreader.cpp.

160{
161 qDebug();
162
163 try
164 {
165 MsRunReaderTicChromatogram ms_run_reader;
166
167 MsRunReadConfig config;
168 config.setMsLevels({1});
169 config.setNeedPeakList(true);
170 // readSpectrumCollectionByMsLevel(reader_timeline, 1);
171 readSpectrumCollection2(config, ms_run_reader);
172
173 return ms_run_reader.getTicChromatogram();
174 }
175
176 catch(ExceptionNotFound &error)
177 {
178 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
179 .arg(mcsp_msRunId.get()->getFileName())
180 .arg(error.qwhat()));
181 }
182 catch(PappsoException &error)
183 {
184 throw PappsoException(QObject::tr("error reading file %1 : %2")
185 .arg(mcsp_msRunId.get()->getFileName())
186 .arg(error.qwhat()));
187 }
188}

References pappso::MsRunReaderTicChromatogram::getTicChromatogram(), mcsp_msRunId, pappso::PappsoException::qwhat(), readSpectrumCollection2(), pappso::MsRunReadConfig::setMsLevels(), and pappso::MsRunReadConfig::setNeedPeakList().

Referenced by pappso::MzcborMsRunReader::getTicChromatogram().

◆ hasScanNumbers()

bool pappso::MsRunReader::hasScanNumbers ( ) const
virtual

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

Reimplemented in pappso::MzcborMsRunReader, pappso::PwizMsRunReader, pappso::TimsMsRunReaderBase, pappso::TimsMsRunReaderMs2, and pappso::TimsMsRunReaderMs2Selected.

Definition at line 120 of file msrunreader.cpp.

121{
122 return false;
123}

◆ initialize()

◆ isMonoThread()

bool pappso::MsRunReader::isMonoThread ( ) const

Definition at line 74 of file msrunreader.cpp.

75{
76 return m_isMonoThread;
77}

References m_isMonoThread.

Referenced by pappso::TimsMsRunReaderMs2::readSpectrumCollectionByMsLevel().

◆ massSpectrumCstSPtr()

◆ massSpectrumSPtr()

virtual MassSpectrumSPtr pappso::MsRunReader::massSpectrumSPtr ( std::size_t  spectrum_index)
pure virtual

◆ newXicCoordSPtrFromQualifiedMassSpectrum()

virtual XicCoordSPtr pappso::MsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum ( const QualifiedMassSpectrum mass_spectrum,
PrecisionPtr  precision 
) const
pure virtual

◆ newXicCoordSPtrFromSpectrumIndex()

virtual XicCoordSPtr pappso::MsRunReader::newXicCoordSPtrFromSpectrumIndex ( std::size_t  spectrum_index,
PrecisionPtr  precision 
) const
pure virtual

◆ qualifiedMassSpectrum()

virtual QualifiedMassSpectrum pappso::MsRunReader::qualifiedMassSpectrum ( std::size_t  spectrum_index,
bool  want_binary_data = true 
) const
pure virtual

◆ readSpectrumCollection()

virtual void pappso::MsRunReader::readSpectrumCollection ( SpectrumCollectionHandlerInterface handler)
pure virtual

◆ readSpectrumCollection2()

◆ readSpectrumCollectionByMsLevel()

virtual void pappso::MsRunReader::readSpectrumCollectionByMsLevel ( SpectrumCollectionHandlerInterface handler,
unsigned int  ms_level 
)
pure virtual

◆ releaseDevice()

virtual bool pappso::MsRunReader::releaseDevice ( )
pure virtual

release data back end device if a the data back end is released, the developper has to use acquireDevice before using the msrunreader object

Returns
bool true if done

Implemented in pappso::BafAsciiMsRunReader, pappso::MzcborMsRunReader, pappso::PwizMsRunReader, pappso::TimsMsRunReaderBase, pappso::TimsMsRunReaderMs2, and pappso::XyMsRunReader.

◆ scanNumber2SpectrumIndex()

std::size_t pappso::MsRunReader::scanNumber2SpectrumIndex ( std::size_t  scan_number)
virtual

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.

Reimplemented in pappso::MzcborMsRunReader.

Definition at line 81 of file msrunreader.cpp.

82{
83 qDebug() << " " << mpa_multiMapScanNumber;
84
85 if(mpa_multiMapScanNumber == nullptr)
86 {
87 mpa_multiMapScanNumber = new MsRunReaderScanNumberMultiMap();
88
89 MsRunReadConfig config;
90 std::vector<size_t> ms_levels;
91 for(std::size_t i = 1; i < 9; i++)
92 {
93 ms_levels.push_back(i);
94 }
95 config.setMsLevels(ms_levels);
96 config.setNeedPeakList(false);
98 }
99 try
100 {
102 }
103
104 catch(ExceptionNotFound &error)
105 {
106 throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
107 .arg(mcsp_msRunId.get()->getFileName())
108 .arg(error.qwhat()));
109 }
110 catch(PappsoException &error)
111 {
112 throw PappsoException(QObject::tr("error reading file %1 : %2")
113 .arg(mcsp_msRunId.get()->getFileName())
114 .arg(error.qwhat()));
115 }
116}
std::size_t getSpectrumIndexFromScanNumber(std::size_t scan_number) const

References pappso::MsRunReaderScanNumberMultiMap::getSpectrumIndexFromScanNumber(), mcsp_msRunId, mpa_multiMapScanNumber, pappso::PappsoException::qwhat(), readSpectrumCollection2(), pappso::MsRunReadConfig::setMsLevels(), and pappso::MsRunReadConfig::setNeedPeakList().

◆ setMonoThread()

void pappso::MsRunReader::setMonoThread ( bool  is_mono_thread)

set only one is_mono_thread to true

this avoid to use qtconcurrent

Definition at line 68 of file msrunreader.cpp.

69{
70 m_isMonoThread = is_mono_thread;
71}

References m_isMonoThread.

◆ spectrumListSize()

◆ spectrumStringIdentifier2SpectrumIndex()

virtual std::size_t pappso::MsRunReader::spectrumStringIdentifier2SpectrumIndex ( const QString &  spectrum_identifier)
pure virtual

if possible, get the spectrum index given a string identifier throw a not found exception if spectrum identifier is not found

Parameters
spectrum_identifierstring identifier of a specific spectrum
Returns
the spectrum index

Implemented in pappso::BafAsciiMsRunReader, pappso::MzcborMsRunReader, pappso::PwizMsRunReader, pappso::TimsFramesMsRunReader, pappso::TimsMsRunReader, pappso::TimsMsRunReaderDia, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReaderMs2Selected, and pappso::XyMsRunReader.

Friends And Related Symbol Documentation

◆ MsFileAccessor

friend class MsFileAccessor
friend

Definition at line 66 of file msrunreader.h.

Member Data Documentation

◆ m_isMonoThread

bool pappso::MsRunReader::m_isMonoThread = false
private

Definition at line 206 of file msrunreader.h.

Referenced by MsRunReader(), isMonoThread(), and setMonoThread().

◆ mcsp_msRunId

◆ mpa_multiMapScanNumber

MsRunReaderScanNumberMultiMap* pappso::MsRunReader::mpa_multiMapScanNumber = nullptr
protected

Definition at line 195 of file msrunreader.h.

Referenced by MsRunReader(), ~MsRunReader(), and scanNumber2SpectrumIndex().


The documentation for this class was generated from the following files: