libpappsomspp
Library for mass spectrometry
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 More...
 
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 More...
 
virtual void readSpectrumCollection (SpectrumCollectionHandlerInterface &handler) override
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler More...
 
virtual std::size_t spectrumListSize () const override
 get the totat number of spectrum conained in the MSrun data file More...
 
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 More...
 
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 More...
 
virtual bool acquireDevice () override
 acquire data back end device More...
 
- 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. More...
 

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 More...
 

Private Attributes

TimsDatampa_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 38 of file timsmsrunreader.h.

Constructor & Destructor Documentation

◆ TimsMsRunReader()

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

Definition at line 34 of file timsmsrunreader.cpp.

35  : MsRunReader(msrun_id_csp)
36 {
37  initialize();
38 }

References initialize().

◆ ~TimsMsRunReader()

TimsMsRunReader::~TimsMsRunReader ( )
virtual

Definition at line 40 of file timsmsrunreader.cpp.

41 {
42  if(mpa_timsData != nullptr)
43  {
44  delete mpa_timsData;
45  }
46 }

References mpa_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 56 of file timsmsrunreader.cpp.

57 {
58  qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
59  << file_name;
60  return true;
61 }

◆ acquireDevice()

bool TimsMsRunReader::acquireDevice ( )
overridevirtual

acquire data back end device

Returns
bool true if done

Implements pappso::MsRunReader.

Definition at line 182 of file timsmsrunreader.cpp.

183 {
184  if(mpa_timsData == nullptr)
185  {
186  initialize();
187  }
188  return true;
189 }

References initialize(), and mpa_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 167 of file timsmsrunreader.cpp.

168 {
169  return false;
170 }

◆ initialize()

void pappso::TimsMsRunReader::initialize ( )
overrideprotectedvirtual

Implements pappso::MsRunReader.

Definition at line 49 of file timsmsrunreader.cpp.

50 {
51  mpa_timsData = new TimsData(mcsp_msRunId.get()->getFileName());
52 }

Referenced by TimsMsRunReader(), and acquireDevice().

◆ massSpectrumCstSPtr()

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

Implements pappso::MsRunReader.

Definition at line 74 of file timsmsrunreader.cpp.

75 {
76  return mpa_timsData->getMassSpectrumCstSPtrByRawIndex(spectrum_index);
77 }

References pappso::TimsData::getMassSpectrumCstSPtrByRawIndex(), and mpa_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 65 of file timsmsrunreader.cpp.

66 {
68  QObject::tr("Not yet implemented in TimsMsRunReader %1.\n").arg(__LINE__));
69  return pappso::MassSpectrumSPtr();
70 }

◆ 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 81 of file timsmsrunreader.cpp.

83 {
84 
85  QualifiedMassSpectrum mass_spectrum =
87  want_binary_data);
88 
89  MassSpectrumId spectrum_id(mass_spectrum.getMassSpectrumId());
90  spectrum_id.setMsRunId(getMsRunId());
91  mass_spectrum.setMassSpectrumId(spectrum_id);
92  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
93  //<< mass_spectrum.toString();
94 
95  // qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
96  //<< mass_spectrum.getMassSpectrumSPtr().get()->toString();
97  return mass_spectrum;
98 }

References pappso::QualifiedMassSpectrum::getMassSpectrumId(), pappso::MsRunReader::getMsRunId(), pappso::TimsData::getQualifiedMassSpectrumByRawIndex(), mpa_timsData, pappso::QualifiedMassSpectrum::setMassSpectrumId(), and pappso::MassSpectrumId::setMsRunId().

Referenced by readSpectrumCollection().

◆ 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 102 of file timsmsrunreader.cpp.

104 {
105  qDebug();
106 
107  const bool want_binary_data = handler.needPeakList();
108 
109  // We'll need it to perform the looping in the spectrum list.
110  std::size_t spectrum_list_size = spectrumListSize();
111 
112  qDebug() << "The spectrum list has size:" << spectrum_list_size;
113 
114  // Inform the handler of the spectrum list so that it can handle feedback to
115  // the user.
116  handler.spectrumListHasSize(spectrum_list_size);
117 
118  // Iterate in the full list of spectra.
119  // mpa_timsData->iterateOnAllScans(mcsp_msRunId, handler);
120 
121  for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
122  {
123 
124  // If the user of this reader instance wants to stop reading the spectra,
125  // then break this loop.
126  if(handler.shouldStop())
127  {
128  qDebug() << "The operation was cancelled. Breaking the loop.";
129  break;
130  }
131 
132 
133  bool get_data = want_binary_data;
134  if(get_data)
135  {
136  get_data = handler.needMsLevelPeakList(
138  }
139  qDebug();
140 
141  QualifiedMassSpectrum qualified_mass_spectrum =
142  qualifiedMassSpectrum(iter, get_data);
143  qDebug();
144  handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
145  qDebug();
146  }
147  // End of
148  // for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
149 
150  // Now let the loading handler know that the loading of the data has ended.
151  // The handler might need this "signal" to perform additional tasks or to
152  // cleanup cruft.
153 
154  // qDebug() << "Loading ended";
155  handler.loadingEnded();
156 }

References pappso::TimsData::getMsLevelBySpectrumIndex(), pappso::SpectrumCollectionHandlerInterface::loadingEnded(), mpa_timsData, pappso::SpectrumCollectionHandlerInterface::needMsLevelPeakList(), pappso::SpectrumCollectionHandlerInterface::needPeakList(), qualifiedMassSpectrum(), pappso::SpectrumCollectionHandlerInterface::setQualifiedMassSpectrum(), pappso::SpectrumCollectionHandlerInterface::shouldStop(), pappso::SpectrumCollectionHandlerInterface::spectrumListHasSize(), and spectrumListSize().

◆ 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 174 of file timsmsrunreader.cpp.

175 {
176  delete mpa_timsData;
177  mpa_timsData = nullptr;
178  return true;
179 }

References mpa_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 160 of file timsmsrunreader.cpp.

161 {
163 }

References pappso::TimsData::getTotalNumberOfScans(), and mpa_timsData.

Referenced by readSpectrumCollection().

Friends And Related Function Documentation

◆ MsFileAccessor

friend class MsFileAccessor
friend

Definition at line 40 of file timsmsrunreader.h.

Member Data Documentation

◆ mpa_timsData

TimsData* pappso::TimsMsRunReader::mpa_timsData = nullptr
private

The documentation for this class was generated from the following files:
pappso::TimsData::getMassSpectrumCstSPtrByRawIndex
pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtrByRawIndex(std::size_t raw_index)
get a mass spectrum given its spectrum index
Definition: timsdata.cpp:305
pappso::SpectrumCollectionHandlerInterface::spectrumListHasSize
virtual void spectrumListHasSize(std::size_t size)
Definition: msrunreader.cpp:55
pappso::SpectrumCollectionHandlerInterface::setQualifiedMassSpectrum
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
pappso::SpectrumCollectionHandlerInterface::shouldStop
virtual bool shouldStop()
Definition: msrunreader.cpp:46
pappso::MsRunReader::mcsp_msRunId
MsRunIdCstSPtr mcsp_msRunId
Definition: msrunreader.h:220
pappso::TimsData::getMsLevelBySpectrumIndex
unsigned int getMsLevelBySpectrumIndex(std::size_t spectrum_index)
Definition: timsdata.cpp:677
pappso::SpectrumCollectionHandlerInterface::loadingEnded
virtual void loadingEnded()
Definition: msrunreader.cpp:51
pappso::TimsData
Definition: timsdata.h:70
pappso::MsRunReader::getMsRunId
const MsRunIdCstSPtr & getMsRunId() const
Definition: msrunreader.cpp:232
pappso::TimsMsRunReader::initialize
virtual void initialize() override
Definition: timsmsrunreader.cpp:49
pappso::QualifiedMassSpectrum
Class representing a fully specified mass spectrum.
Definition: qualifiedmassspectrum.h:85
pappso::TimsData::getQualifiedMassSpectrumByRawIndex
QualifiedMassSpectrum getQualifiedMassSpectrumByRawIndex(std::size_t spectrum_index, bool want_binary_data)
Definition: timsdata.cpp:686
pappso::ExceptionNotImplemented
Definition: exceptionnotimplemented.h:32
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::QualifiedMassSpectrum::setMassSpectrumId
void setMassSpectrumId(const MassSpectrumId &iD)
Set the MassSpectrumId.
Definition: qualifiedmassspectrum.cpp:149
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: msrunreader.cpp:72
pappso::QualifiedMassSpectrum::getMassSpectrumId
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
Definition: qualifiedmassspectrum.cpp:157
pappso::TimsData::getTotalNumberOfScans
std::size_t getTotalNumberOfScans() const
get the total number of scans
Definition: timsdata.cpp:535
pappso::MassSpectrumId
Definition: massspectrumid.h:38
pappso::MsRunReader::MsRunReader
MsRunReader(MsRunIdCstSPtr &ms_run_id)
Definition: msrunreader.cpp:220
pappso::TimsMsRunReader::spectrumListSize
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
Definition: timsmsrunreader.cpp:160
pappso::TimsMsRunReader::qualifiedMassSpectrum
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
Definition: timsmsrunreader.cpp:81
pappso::TimsMsRunReader::mpa_timsData
TimsData * mpa_timsData
Definition: timsmsrunreader.h:74
pappso::MassSpectrumSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54