libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::TimsMsRunReader Class Reference

#include <timsmsrunreader.h>

Inheritance diagram for pappso::TimsMsRunReader:
pappso::MsRunReader

Public Member Functions

 TimsMsRunReader (MsRunIdCstSPtr &msrun_id_csp)
 
virtual ~TimsMsRunReader ()
 
virtual MassSpectrumSPtr massSpectrumSPtr (std::size_t spectrum_index) override
 get a MassSpectrumSPtr class given its spectrum index
 
virtual MassSpectrumCstSPtr massSpectrumCstSPtr (std::size_t spectrum_index) override
 
virtual QualifiedMassSpectrum qualifiedMassSpectrum (std::size_t spectrum_index, bool want_binary_data=true) const override
 get a QualifiedMassSpectrum class given its scan number
 
virtual void readSpectrumCollection (SpectrumCollectionHandlerInterface &handler) override
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
 
virtual void readSpectrumCollection2 (const MsRunReadConfig &config, SpectrumCollectionHandlerInterface &handler) override
 
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
 
virtual pappso::XicCoordSPtr newXicCoordSPtrFromSpectrumIndex (std::size_t spectrum_index, pappso::PrecisionPtr precision) const override
 get a xic coordinate object from a given spectrum index
 
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum (const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
 get a xic coordinate object from a given spectrum
 
virtual std::size_t spectrumListSize () const override
 get the totat number of spectrum conained in the MSrun data file
 
virtual bool hasScanNumbers () const override
 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 releaseDevice () override
 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 () override
 acquire data back end device
 
virtual TimsDataSp getTimsDataSPtr ()
 give an access to the underlying raw data pointer
 
virtual Trace getTicChromatogram () override
 get a TIC chromatogram
 
- Public Member Functions inherited from pappso::MsRunReader
 MsRunReader (MsRunIdCstSPtr &ms_run_id)
 
 MsRunReader (const MsRunReader &other)
 
virtual ~MsRunReader ()
 
const MsRunIdCstSPtrgetMsRunId () const
 
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 std::vector< double > getRetentionTimeLine ()
 retention timeline get retention times along the MSrun in seconds
 
void setMonoThread (bool is_mono_thread)
 set only one is_mono_thread to true
 
bool isMonoThread () const
 

Protected Member Functions

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

Private Attributes

TimsDataSp msp_timsData = nullptr
 

Friends

class MsFileAccessor
 

Additional Inherited Members

- Protected Attributes inherited from pappso::MsRunReader
MsRunIdCstSPtr mcsp_msRunId
 
MsRunReaderScanNumberMultiMapmpa_multiMapScanNumber = nullptr
 

Detailed Description

Definition at line 37 of file timsmsrunreader.h.

Constructor & Destructor Documentation

◆ TimsMsRunReader()

TimsMsRunReader::TimsMsRunReader ( MsRunIdCstSPtr msrun_id_csp)
Todo:
write docs

Definition at line 35 of file timsmsrunreader.cpp.

36 : MsRunReader(msrun_id_csp)
37{
38 initialize();
39}
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
Definition msrunreader.h:63
virtual void initialize() override

References initialize().

◆ ~TimsMsRunReader()

TimsMsRunReader::~TimsMsRunReader ( )
virtual

Definition at line 41 of file timsmsrunreader.cpp.

42{
43 msp_timsData = nullptr;
44}

References msp_timsData.

Member Function Documentation

◆ accept()

bool TimsMsRunReader::accept ( const QString &  file_name) const
overrideprotectedvirtual

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

Implements pappso::MsRunReader.

Definition at line 61 of file timsmsrunreader.cpp.

62{
63 qDebug() << file_name;
64 return true;
65}

◆ acquireDevice()

bool TimsMsRunReader::acquireDevice ( )
overridevirtual

acquire data back end device

Returns
bool true if done

Implements pappso::MsRunReader.

Definition at line 162 of file timsmsrunreader.cpp.

163{
164 if(msp_timsData == nullptr)
165 {
166 initialize();
167 }
168 return true;
169}

References initialize(), and msp_timsData.

Referenced by getTicChromatogram(), and getTimsDataSPtr().

◆ getTicChromatogram()

Trace TimsMsRunReader::getTicChromatogram ( )
overridevirtual

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 from pappso::MsRunReader.

Definition at line 204 of file timsmsrunreader.cpp.

205{
206 // Use the Sqlite database to fetch the total ion current chromatogram (TIC
207 // chromatogram).
208
210
211 // The time unit here is seconds, not minutes!!!
212 return msp_timsData->getTicChromatogram();
213}
virtual bool acquireDevice() override
acquire data back end device

References acquireDevice(), and msp_timsData.

◆ getTimsDataSPtr()

TimsDataSp TimsMsRunReader::getTimsDataSPtr ( )
virtual

give an access to the underlying raw data pointer

Definition at line 196 of file timsmsrunreader.cpp.

197{
199 return msp_timsData;
200}

References acquireDevice(), and msp_timsData.

◆ hasScanNumbers()

bool TimsMsRunReader::hasScanNumbers ( ) const
overridevirtual

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 from pappso::MsRunReader.

Definition at line 148 of file timsmsrunreader.cpp.

149{
150 return false;
151}

◆ initialize()

void TimsMsRunReader::initialize ( )
overrideprotectedvirtual

Implements pappso::MsRunReader.

Definition at line 47 of file timsmsrunreader.cpp.

48{
49 msp_timsData = std::make_shared<TimsData>(mcsp_msRunId.get()->getFileName());
50
51 if(msp_timsData == nullptr)
52 {
53 throw PappsoException(QObject::tr("ERROR in TimsMsRunReader::initialize "
54 "msp_timsData is null for MsRunId %1")
55 .arg(mcsp_msRunId.get()->toString()));
56 }
57}
MsRunIdCstSPtr mcsp_msRunId

References pappso::MsRunReader::mcsp_msRunId, and msp_timsData.

Referenced by TimsMsRunReader(), and acquireDevice().

◆ massSpectrumCstSPtr()

pappso::MassSpectrumCstSPtr TimsMsRunReader::massSpectrumCstSPtr ( std::size_t  spectrum_index)
overridevirtual

Implements pappso::MsRunReader.

Definition at line 78 of file timsmsrunreader.cpp.

79{
80 return msp_timsData->getMassSpectrumCstSPtrByRawIndex(spectrum_index);
81}

References msp_timsData.

◆ massSpectrumSPtr()

pappso::MassSpectrumSPtr TimsMsRunReader::massSpectrumSPtr ( std::size_t  spectrum_index)
overridevirtual

get a MassSpectrumSPtr class given its spectrum index

Implements pappso::MsRunReader.

Definition at line 69 of file timsmsrunreader.cpp.

70{
72 QObject::tr("Not yet implemented in TimsMsRunReader %1.\n").arg(__LINE__));
74}
std::shared_ptr< MassSpectrum > MassSpectrumSPtr

◆ newXicCoordSPtrFromQualifiedMassSpectrum()

XicCoordSPtr TimsMsRunReader::newXicCoordSPtrFromQualifiedMassSpectrum ( const pappso::QualifiedMassSpectrum mass_spectrum,
pappso::PrecisionPtr  precision 
) const
overridevirtual

get a xic coordinate object from a given spectrum

Implements pappso::MsRunReader.

Definition at line 185 of file timsmsrunreader.cpp.

188{
189 throw ExceptionNotImplemented(QObject::tr("Not implemented %1 %2 %3")
190 .arg(__FILE__)
191 .arg(__FUNCTION__)
192 .arg(__LINE__));
193}

◆ newXicCoordSPtrFromSpectrumIndex()

XicCoordSPtr TimsMsRunReader::newXicCoordSPtrFromSpectrumIndex ( std::size_t  spectrum_index,
pappso::PrecisionPtr  precision 
) const
overridevirtual

get a xic coordinate object from a given spectrum index

Implements pappso::MsRunReader.

Definition at line 173 of file timsmsrunreader.cpp.

177{
178 throw ExceptionNotImplemented(QObject::tr("Not implemented %1 %2 %3")
179 .arg(__FILE__)
180 .arg(__FUNCTION__)
181 .arg(__LINE__));
182}

◆ qualifiedMassSpectrum()

QualifiedMassSpectrum TimsMsRunReader::qualifiedMassSpectrum ( std::size_t  spectrum_index,
bool  want_binary_data = true 
) const
overridevirtual

get a QualifiedMassSpectrum class given its scan number

Implements pappso::MsRunReader.

Definition at line 85 of file timsmsrunreader.cpp.

87{
88
89 QualifiedMassSpectrum mass_spectrum;
90
91 msp_timsData->getQualifiedMassSpectrumByRawIndex(
92 getMsRunId(), mass_spectrum, spectrum_index, want_binary_data);
93 return mass_spectrum;
94}
const MsRunIdCstSPtr & getMsRunId() const
Class representing a fully specified mass spectrum.

References pappso::MsRunReader::getMsRunId(), and msp_timsData.

◆ readSpectrumCollection()

void TimsMsRunReader::readSpectrumCollection ( SpectrumCollectionHandlerInterface handler)
overridevirtual

function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

Implements pappso::MsRunReader.

Definition at line 98 of file timsmsrunreader.cpp.

100{
102}
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

References readSpectrumCollectionByMsLevel().

Referenced by readSpectrumCollection2().

◆ readSpectrumCollection2()

void TimsMsRunReader::readSpectrumCollection2 ( const MsRunReadConfig config,
SpectrumCollectionHandlerInterface handler 
)
overridevirtual

Implements pappso::MsRunReader.

Definition at line 105 of file timsmsrunreader.cpp.

108{
109 return readSpectrumCollection(handler);
110}
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

References readSpectrumCollection().

◆ readSpectrumCollectionByMsLevel()

void TimsMsRunReader::readSpectrumCollectionByMsLevel ( SpectrumCollectionHandlerInterface handler,
unsigned int  ms_level 
)
overridevirtual

function to visit an MsRunReader and get each Spectrum in a spectrum collection handler by Ms Levels

Implements pappso::MsRunReader.

Definition at line 113 of file timsmsrunreader.cpp.

115{
116
117 qDebug();
118
119 try
120 {
121
122 msp_timsData.get()->rawReaderSpectrumCollectionByMsLevel(
123 getMsRunId(), handler, ms_level);
124 }
125
126 catch(ExceptionInterrupted &)
127 {
128 qDebug() << "Reading of MS data interrupted by the user.";
129 }
130
131 // Now let the loading handler know that the loading of the data has ended.
132 // The handler might need this "signal" to perform additional tasks or to
133 // cleanup cruft.
134
135 // qDebug() << "Loading ended";
136 handler.loadingEnded();
137}

References pappso::MsRunReader::getMsRunId(), pappso::SpectrumCollectionHandlerInterface::loadingEnded(), and msp_timsData.

Referenced by readSpectrumCollection().

◆ releaseDevice()

bool TimsMsRunReader::releaseDevice ( )
overridevirtual

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

Implements pappso::MsRunReader.

Definition at line 155 of file timsmsrunreader.cpp.

156{
157 msp_timsData = nullptr;
158 return true;
159}

References msp_timsData.

◆ spectrumListSize()

std::size_t TimsMsRunReader::spectrumListSize ( ) const
overridevirtual

get the totat number of spectrum conained in the MSrun data file

Implements pappso::MsRunReader.

Definition at line 141 of file timsmsrunreader.cpp.

142{
143 return msp_timsData->getTotalNumberOfScans();
144}

References msp_timsData.

Friends And Related Symbol Documentation

◆ MsFileAccessor

friend class MsFileAccessor
friend

Definition at line 39 of file timsmsrunreader.h.

Member Data Documentation

◆ msp_timsData


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