11 #include <pwiz/data/msdata/DefaultReaderList.hpp>
17 #include "../pappsoexception.h"
18 #include "../exception/exceptionnotfound.h"
19 #include "../exception/exceptionnotpossible.h"
20 #include "../exception/exceptionnotimplemented.h"
59 std::size_t line_count = 0;
61 QFile file(file_name);
63 if(!file.open(QFile::ReadOnly | QFile::Text))
65 qDebug() << __FILE__ << __LINE__ <<
"Failed to open file" << file_name;
70 QRegularExpressionMatch regExpMatch;
73 bool file_reading_failed =
false;
77 line = file.readLine();
80 if(line.startsWith(
'#') || line.isEmpty() ||
90 file_reading_failed =
true;
97 if(!file_reading_failed && line_count >= 1)
143 return qualified_mass_spectrum;
146 if(!file.open(QFile::ReadOnly | QFile::Text))
150 return qualified_mass_spectrum;
153 QRegularExpressionMatch regExpMatch;
159 line = file.readLine();
161 if(line.startsWith(
'#') || line.isEmpty() ||
170 QRegularExpressionMatch regExpMatch =
173 if(!regExpMatch.hasMatch())
175 QObject::tr(
"Failed to create data point with line %1.\n")
180 x = regExpMatch.captured(1).toDouble(&ok);
184 QObject::tr(
"Failed to create data point with line %1.\n")
189 y = regExpMatch.captured(3).toDouble(&ok);
193 QObject::tr(
"Failed to create data point with line %1.\n")
198 mass_spectrum.emplace_back(
x,
y);
210 return qualified_mass_spectrum;
216 [[maybe_unused]] std::size_t spectrum_index,
bool want_binary_data)
const
233 if(!want_binary_data)
238 return qualified_mass_spectrum;
286 if(qualified_mass_spectrum.
getMsLevel() == ms_level)
317 [[maybe_unused]])
const
Class to represent a mass spectrum.
MassSpectrumSPtr makeMassSpectrumSPtr() const
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
MsRunIdCstSPtr mcsp_msRunId
Class representing a fully specified mass spectrum.
uint getMsLevel() const
Get the mass spectrum level.
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
void setMsLevel(uint ms_level)
Set the mass spectrum level.
MassSpectrumSPtr getMassSpectrumSPtr() const
Get the MassSpectrumSPtr.
void setMassSpectrumSPtr(MassSpectrumSPtr massSpectrum)
Set the MassSpectrumSPtr.
void setRtInSeconds(pappso_double rt)
Set the retention time in seconds.
interface to collect spectrums from the MsRunReader class
virtual void loadingEnded()
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
static QRegularExpression xyMassDataFormatRegExp
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
virtual pappso::XicCoordSPtr newXicCoordSPtrFromQualifiedMassSpectrum(const pappso::QualifiedMassSpectrum &mass_spectrum, pappso::PrecisionPtr precision) const override
get a xic coordinate object from a given spectrum
QualifiedMassSpectrum qualifiedMassSpectrumFromXyMSDataFile(MassSpectrumId mass_spectrum_id) const
virtual void readSpectrumCollection(SpectrumCollectionHandlerInterface &handler) override
function to visit an MsRunReader and get each Spectrum in a spectrum collection handler
virtual bool acquireDevice() override
acquire data back end device
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,...
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
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 bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
XyMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
virtual void initialize() override
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 MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
double pappso_double
A type definition for doubles.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
std::shared_ptr< MassSpectrum > MassSpectrumSPtr
std::shared_ptr< XicCoord > XicCoordSPtr