libpappsomspp
Library for mass spectrometry
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::PwizMsRunReader pappso::TimsMsRunReader pappso::TimsMsRunReaderMs2 pappso::XyMsRunReader pappso::TimsMsRunReaderMs2Selected

Public Member Functions

 MsRunReader (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 More...
 
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 More...
 
virtual XicCoordSPtr newXicCoordSPtrFromSpectrumIndex (std::size_t spectrum_index, PrecisionPtr precision) const =0
 get a xic coordinate object from a given spectrum index More...
 
virtual XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum (const QualifiedMassSpectrum &mass_spectrum, PrecisionPtr precision) const =0
 get a xic coordinate object from a given spectrum More...
 
virtual std::size_t spectrumListSize () const =0
 get the totat number of spectrum conained in the MSrun data file More...
 
virtual void readSpectrumCollection (SpectrumCollectionHandlerInterface &handler)=0
 function to visit an MsRunReader and get each Spectrum in a spectrum collection handler More...
 
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 More...
 
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...
 
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 More...
 
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 More...
 
virtual bool acquireDevice ()=0
 acquire data back end device More...
 
virtual std::vector< double > getRetentionTimeLine ()
 retention timeline get retention times along the MSrun in seconds More...
 
virtual Trace getTicChromatogram ()
 
void setMonoThread (bool is_mono_thread)
 set only one is_mono_thread to true More...
 
bool isMonoThread () const
 

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

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 190 of file msrunreader.h.

Constructor & Destructor Documentation

◆ MsRunReader() [1/2]

pappso::MsRunReader::MsRunReader ( MsRunIdCstSPtr ms_run_id)

Definition at line 257 of file msrunreader.cpp.

257  : mcsp_msRunId(ms_run_id)
258 {
259 }
MsRunIdCstSPtr mcsp_msRunId
Definition: msrunreader.h:291

◆ MsRunReader() [2/2]

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

Definition at line 261 of file msrunreader.cpp.

262  : mcsp_msRunId(other.mcsp_msRunId)
263 {
264  mpa_multiMapScanNumber = nullptr;
265  m_isMonoThread = other.m_isMonoThread;
266 }
MsRunReaderScanNumberMultiMap * mpa_multiMapScanNumber
Definition: msrunreader.h:292

References m_isMonoThread, and mpa_multiMapScanNumber.

◆ ~MsRunReader()

pappso::MsRunReader::~MsRunReader ( )
virtual

Definition at line 276 of file msrunreader.cpp.

277 {
278  if(mpa_multiMapScanNumber == nullptr)
279  delete mpa_multiMapScanNumber;
280 }

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::XyMsRunReader, pappso::TimsMsRunReaderMs2Selected, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

◆ acquireDevice()

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

acquire data back end device

Returns
bool true if done

Implemented in pappso::XyMsRunReader, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

◆ getMsRunId()

◆ 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::TimsMsRunReaderMs2.

Definition at line 333 of file msrunreader.cpp.

334 {
335  qDebug();
336 
337  try
338  {
339 
340  MsRunReaderRetentionTimeLine reader_timeline;
341 
342  readSpectrumCollectionByMsLevel(reader_timeline, 1);
343 
344  return reader_timeline.getRetentionTimeLine();
345  }
346 
347  catch(ExceptionNotFound &error)
348  {
349  throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
350  .arg(mcsp_msRunId.get()->getFileName())
351  .arg(error.qwhat()));
352  }
353  catch(PappsoException &error)
354  {
355  throw PappsoException(QObject::tr("error reading file %1 : %2")
356  .arg(mcsp_msRunId.get()->getFileName())
357  .arg(error.qwhat()));
358  }
359 }
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

References pappso::MsRunReaderRetentionTimeLine::getRetentionTimeLine(), mcsp_msRunId, pappso::PappsoException::qwhat(), and readSpectrumCollectionByMsLevel().

◆ getTicChromatogram()

Trace pappso::MsRunReader::getTicChromatogram ( )
virtual

Reimplemented in pappso::TimsMsRunReaderMs2, and pappso::TimsMsRunReader.

Definition at line 363 of file msrunreader.cpp.

364 {
365  qDebug();
366 
367  try
368  {
369  MsRunReaderTicChromatogram ms_run_reader;
370 
371  readSpectrumCollection(ms_run_reader);
372 
373  return ms_run_reader.getTicChromatogram();
374  }
375 
376  catch(ExceptionNotFound &error)
377  {
378  throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
379  .arg(mcsp_msRunId.get()->getFileName())
380  .arg(error.qwhat()));
381  }
382  catch(PappsoException &error)
383  {
384  throw PappsoException(QObject::tr("error reading file %1 : %2")
385  .arg(mcsp_msRunId.get()->getFileName())
386  .arg(error.qwhat()));
387  }
388 }
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler)=0
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler

References pappso::MsRunReaderTicChromatogram::getTicChromatogram(), mcsp_msRunId, pappso::PappsoException::qwhat(), and readSpectrumCollection().

◆ 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::TimsMsRunReaderMs2Selected, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

Definition at line 327 of file msrunreader.cpp.

328 {
329  return false;
330 }

◆ initialize()

virtual void pappso::MsRunReader::initialize ( )
protectedpure virtual

◆ isMonoThread()

bool pappso::MsRunReader::isMonoThread ( ) const

Definition at line 289 of file msrunreader.cpp.

290 {
291  return m_isMonoThread;
292 }

References m_isMonoThread.

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

◆ massSpectrumCstSPtr()

virtual MassSpectrumCstSPtr pappso::MsRunReader::massSpectrumCstSPtr ( std::size_t  spectrum_index)
pure virtual

◆ 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

get a xic coordinate object from a given spectrum

Implemented in pappso::XyMsRunReader, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

◆ newXicCoordSPtrFromSpectrumIndex()

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

get a xic coordinate object from a given spectrum index

Implemented in pappso::XyMsRunReader, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

◆ 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

◆ readSpectrumCollectionByMsLevel()

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

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

Implemented in pappso::XyMsRunReader, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

Referenced by getRetentionTimeLine().

◆ 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::XyMsRunReader, pappso::TimsMsRunReaderMs2, pappso::TimsMsRunReader, and pappso::PwizMsRunReader.

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

Definition at line 296 of file msrunreader.cpp.

297 {
298  qDebug() << " " << mpa_multiMapScanNumber;
299 
300  if(mpa_multiMapScanNumber == nullptr)
301  {
302  mpa_multiMapScanNumber = new MsRunReaderScanNumberMultiMap();
304  }
305  try
306  {
308  scan_number);
309  }
310 
311  catch(ExceptionNotFound &error)
312  {
313  throw ExceptionNotFound(QObject::tr("error reading file %1 : %2")
314  .arg(mcsp_msRunId.get()->getFileName())
315  .arg(error.qwhat()));
316  }
317  catch(PappsoException &error)
318  {
319  throw PappsoException(QObject::tr("error reading file %1 : %2")
320  .arg(mcsp_msRunId.get()->getFileName())
321  .arg(error.qwhat()));
322  }
323 }
std::size_t getSpectrumIndexFromScanNumber(std::size_t scan_number) const

References pappso::MsRunReaderScanNumberMultiMap::getSpectrumIndexFromScanNumber(), mcsp_msRunId, mpa_multiMapScanNumber, pappso::PappsoException::qwhat(), and readSpectrumCollection().

◆ 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 283 of file msrunreader.cpp.

284 {
285  m_isMonoThread = is_mono_thread;
286 }

References m_isMonoThread.

◆ spectrumListSize()

virtual std::size_t pappso::MsRunReader::spectrumListSize ( ) const
pure virtual

Friends And Related Function Documentation

◆ MsFileAccessor

friend class MsFileAccessor
friend

Definition at line 193 of file msrunreader.h.

Member Data Documentation

◆ m_isMonoThread

bool pappso::MsRunReader::m_isMonoThread = false
private

Definition at line 303 of file msrunreader.h.

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

◆ mcsp_msRunId

◆ mpa_multiMapScanNumber

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

Definition at line 292 of file msrunreader.h.

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


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