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 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 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 }
MsRunReader(MsRunIdCstSPtr &ms_run_id)
virtual void initialize() override

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

199 {
200  if(mpa_timsData == nullptr)
201  {
202  initialize();
203  }
204  return true;
205 }

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

184 {
185  return false;
186 }

◆ 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 }
MsRunIdCstSPtr mcsp_msRunId
Definition: msrunreader.h:229

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 }
pappso::MassSpectrumCstSPtr getMassSpectrumCstSPtrByRawIndex(std::size_t raw_index)
get a mass spectrum given its spectrum index
Definition: timsdata.cpp:376

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 }
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
Definition: massspectrum.h:54

◆ 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 }
const MsRunIdCstSPtr & getMsRunId() const
Class representing a fully specified mass spectrum.
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
void setMassSpectrumId(const MassSpectrumId &iD)
Set the MassSpectrumId.
QualifiedMassSpectrum getQualifiedMassSpectrumByRawIndex(std::size_t spectrum_index, bool want_binary_data)
Definition: timsdata.cpp:743

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

Referenced by readSpectrumCollectionByMsLevel().

◆ 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 {
106 }
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().

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

112 {
113 
114  qDebug();
115 
116  const bool want_binary_data = handler.needPeakList();
117 
118  // We'll need it to perform the looping in the spectrum list.
119  std::size_t spectrum_list_size = spectrumListSize();
120 
121  qDebug() << "The spectrum list has size:" << spectrum_list_size;
122 
123  // Inform the handler of the spectrum list so that it can handle feedback to
124  // the user.
125  handler.spectrumListHasSize(spectrum_list_size);
126 
127  // Iterate in the full list of spectra.
128  // mpa_timsData->iterateOnAllScans(mcsp_msRunId, handler);
129 
130  for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
131  {
132  unsigned int current_ms_level =
134 
135  // If the user of this reader instance wants to stop reading the spectra,
136  // then break this loop.
137  if(handler.shouldStop())
138  {
139  qDebug() << "The operation was cancelled. Breaking the loop.";
140  break;
141  }
142 
143  if(ms_level > 0)
144  {
145  if(ms_level != current_ms_level)
146  {
147  continue;
148  }
149  }
150  bool get_data = want_binary_data;
151  if(get_data)
152  {
153  get_data = handler.needMsLevelPeakList(ms_level);
154  }
155  qDebug();
156 
157  QualifiedMassSpectrum qualified_mass_spectrum =
158  qualifiedMassSpectrum(iter, get_data);
159  qDebug();
160  handler.setQualifiedMassSpectrum(qualified_mass_spectrum);
161  qDebug();
162  }
163  // End of
164  // for(std::size_t iter = 0; iter < spectrum_list_size; iter++)
165 
166  // Now let the loading handler know that the loading of the data has ended.
167  // The handler might need this "signal" to perform additional tasks or to
168  // cleanup cruft.
169 
170  // qDebug() << "Loading ended";
171  handler.loadingEnded();
172 }
virtual bool needPeakList() const =0
tells if we need the peak list (if we want the binary data) for each spectrum
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
virtual void spectrumListHasSize(std::size_t size)
Definition: msrunreader.cpp:55
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
unsigned int getMsLevelBySpectrumIndex(std::size_t spectrum_index)
Definition: timsdata.cpp:734
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file

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().

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

191 {
192  delete mpa_timsData;
193  mpa_timsData = nullptr;
194  return true;
195 }

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

177 {
179 }
std::size_t getTotalNumberOfScans() const
get the total number of scans
Definition: timsdata.cpp:592

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

Referenced by readSpectrumCollectionByMsLevel().

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: