11 #include <pwiz/data/msdata/DefaultReaderList.hpp>
17 #include "../pappsoexception.h"
18 #include "../exception/exceptionnotfound.h"
19 #include "../exception/exceptionnotpossible.h"
58 std::size_t line_count = 0;
60 QFile file(file_name);
62 if(!file.open(QFile::ReadOnly | QFile::Text))
64 qDebug() << __FILE__ << __LINE__ <<
"Failed to open file" << file_name;
69 QRegularExpressionMatch regExpMatch;
72 bool file_reading_failed =
false;
76 line = file.readLine();
79 if(line.startsWith(
'#') || line.isEmpty() ||
89 file_reading_failed =
true;
96 if(!file_reading_failed && line_count >= 1)
142 return qualified_mass_spectrum;
145 if(!file.open(QFile::ReadOnly | QFile::Text))
149 return qualified_mass_spectrum;
152 QRegularExpressionMatch regExpMatch;
158 line = file.readLine();
160 if(line.startsWith(
'#') || line.isEmpty() ||
169 QRegularExpressionMatch regExpMatch =
172 if(!regExpMatch.hasMatch())
174 QObject::tr(
"Failed to create data point with line %1.\n")
179 x = regExpMatch.captured(1).toDouble(&ok);
183 QObject::tr(
"Failed to create data point with line %1.\n")
188 y = regExpMatch.captured(3).toDouble(&ok);
192 QObject::tr(
"Failed to create data point with line %1.\n")
197 mass_spectrum.emplace_back(
x,
y);
209 return qualified_mass_spectrum;
215 [[maybe_unused]] std::size_t spectrum_index,
bool want_binary_data)
const
232 if(!want_binary_data)
237 return qualified_mass_spectrum;
285 if(qualified_mass_spectrum.
getMsLevel() == ms_level)
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.
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 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