libpappsomspp
Library for mass spectrometry
|
Go to the documentation of this file.
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;
MassSpectrumSPtr makeMassSpectrumSPtr() const
double pappso_double
A type definition for doubles.
std::shared_ptr< const MassSpectrum > MassSpectrumCstSPtr
MassSpectrumSPtr getMassSpectrumSPtr() const
Get the MassSpectrumSPtr.
base class to read MSrun the only way to build a MsRunReader object is to use the MsRunReaderFactory
virtual MassSpectrumCstSPtr massSpectrumCstSPtr(std::size_t spectrum_index) override
XyMsRunReader(MsRunIdCstSPtr &msrun_id_csp)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Class to represent a mass spectrum.
virtual void initialize() override
static QRegularExpression endOfLineRegExp
Regular expression that tracks the end of line in text files.
virtual void setQualifiedMassSpectrum(const QualifiedMassSpectrum &spectrum)=0
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
virtual MassSpectrumSPtr massSpectrumSPtr(std::size_t spectrum_index) override
get a MassSpectrumSPtr class given its spectrum index
virtual bool releaseDevice() override
release data back end device if a the data back end is released, the developper has to use acquireDev...
MsRunIdCstSPtr mcsp_msRunId
void setMassSpectrumSPtr(MassSpectrumSPtr massSpectrum)
Set the MassSpectrumSPtr.
virtual void loadingEnded()
QualifiedMassSpectrum qualifiedMassSpectrumFromXyMSDataFile(MassSpectrumId mass_spectrum_id) const
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,...
void setMsLevel(uint ms_level)
Set the mass spectrum level.
void setRtInSeconds(pappso_double rt)
Set the retention time in seconds.
Class representing a fully specified mass spectrum.
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const override
get a QualifiedMassSpectrum class given its scan number
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
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
virtual std::size_t spectrumListSize() const override
get the totat number of spectrum conained in the MSrun data file
static QRegularExpression xyMassDataFormatRegExp
interface to collect spectrums from the MsRunReader class
std::shared_ptr< MassSpectrum > MassSpectrumSPtr