libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::PwizMsFileReader Class Reference

#include <pwizmsfilereader.h>

Inheritance diagram for pappso::PwizMsFileReader:
pappso::MsFileReader

Public Member Functions

 PwizMsFileReader (const QString &file_name)
virtual ~PwizMsFileReader ()
virtual Enums::MsDataFormat getFileFormat () override
virtual std::vector< MsRunIdCstSPtrgetMsRunIds (const QString &run_prefix) override

Private Member Functions

virtual std::size_t initialize ()
Private Member Functions inherited from pappso::MsFileReader
 MsFileReader (const QString &file_name)
virtual ~MsFileReader ()

Private Attributes

std::vector< pwiz::msdata::MSDataPtr > m_msDataPtrVector
Private Attributes inherited from pappso::MsFileReader
QString m_fileName
Enums::MsDataFormat m_fileFormat = Enums::MsDataFormat::unknown

Detailed Description

Definition at line 17 of file pwizmsfilereader.h.

Constructor & Destructor Documentation

◆ PwizMsFileReader()

pappso::PwizMsFileReader::PwizMsFileReader ( const QString & file_name)

Definition at line 27 of file pwizmsfilereader.cpp.

28 : MsFileReader{file_name}
29{
30}
MsFileReader(const QString &file_name)

References pappso::MsFileReader::MsFileReader().

◆ ~PwizMsFileReader()

pappso::PwizMsFileReader::~PwizMsFileReader ( )
virtual

Definition at line 32 of file pwizmsfilereader.cpp.

33{
34}

Member Function Documentation

◆ getFileFormat()

Enums::MsDataFormat pappso::PwizMsFileReader::getFileFormat ( )
overridevirtual

Implements pappso::MsFileReader.

Definition at line 160 of file pwizmsfilereader.cpp.

161{
162 // std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
163 // << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
164 // << std::endl;
165
166 return m_fileFormat;
167}
Enums::MsDataFormat m_fileFormat

References pappso::MsFileReader::m_fileFormat.

Referenced by pappso::MsFileAccessor::getMsRunIds().

◆ getMsRunIds()

std::vector< MsRunIdCstSPtr > pappso::PwizMsFileReader::getMsRunIds ( const QString & run_prefix)
overridevirtual

Implements pappso::MsFileReader.

Definition at line 170 of file pwizmsfilereader.cpp.

171{
172 std::vector<MsRunIdCstSPtr> ms_run_ids;
173
174 if(!initialize())
175 return ms_run_ids;
176
177 std::size_t iter = 0;
178
179 for(const pwiz::msdata::MSDataPtr &ms_data_ptr : m_msDataPtrVector)
180 {
181 MsRunId ms_run_id(m_fileName,
182 QString::fromStdString(ms_data_ptr->run.id));
183
184 // Set the MS data format as determined in initialize().
185 ms_run_id.setMsDataFormat(m_fileFormat);
186
187 // We need to set the unambiguous xmlId string.
188 ms_run_id.setXmlId(QString("%1%2")
189 .arg(run_prefix)
191
192 // Now set the sample name to the run id : we can not do that, this is not
193 // the use sample name
194 // ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
195
196 // And if it is possible, the real sample name because this one is for the
197 // end user to recognize his sample:
198 if(ms_data_ptr->run.samplePtr != nullptr)
199 {
200 ms_run_id.setSampleName(
201 QString::fromStdString(ms_data_ptr->run.samplePtr->name));
202 }
203
204 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "()"
205 //<< "Current ms_run_id:" << ms_run_id.toString();
206
207 // Finally make a shared pointer out of it and append it to the vector.
208 ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
209
210 ++iter;
211 }
212
213 return ms_run_ids;
214}
std::vector< pwiz::msdata::MSDataPtr > m_msDataPtrVector
virtual std::size_t initialize()
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72

References pappso::Utils::getLexicalOrderedString(), initialize(), pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, m_msDataPtrVector, pappso::MsRunId::setMsDataFormat(), pappso::MsRunId::setSampleName(), and pappso::MsRunId::setXmlId().

Referenced by pappso::MsFileAccessor::getMsRunIds().

◆ initialize()

std::size_t pappso::PwizMsFileReader::initialize ( )
privatevirtual

Definition at line 37 of file pwizmsfilereader.cpp.

38{
39 pwiz::msdata::DefaultReaderList defaultReaderList;
40 std::string readerName;
41 try
42 {
43 // qDebug() << m_fileName;
44 readerName = defaultReaderList.identify(m_fileName.toStdString());
45 }
46 catch(std::runtime_error &error)
47 {
48 qDebug() << error.what() << " " << typeid(error).name();
49
50 throw PappsoException(
51 QObject::tr(
52 "libpwiz ERROR reading MS data file %1 "
53 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
54 .arg(m_fileName)
55 .arg(error.what())
56 .arg(__FILE__)
57 .arg(__LINE__));
58 }
59 catch(std::exception &error)
60 {
61 qDebug() << error.what() << " " << typeid(error).name();
62
63 throw PappsoException(
64 QObject::tr(
65 "libpwiz ERROR reading MS data file %1 "
66 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
67 .arg(m_fileName)
68 .arg(error.what())
69 .arg(__FILE__)
70 .arg(__LINE__));
71 }
72
73 if(readerName.empty())
74 {
75 // qDebug() << "Failed to identify the file.";
76
77 return 0;
78 }
79
80 // Now convert the string to Enums::MsDataFormat.
81 if(readerName == "mzML")
83 else if(readerName == "mzXML")
85 else if(readerName == "Mascot Generic")
87 else if(readerName == "MZ5")
89 else if(readerName == "MSn")
91 else if(readerName == "ABSciex WIFF")
93 else if(readerName == "ABSciex T2D")
95 else if(readerName == "Agilent MassHunter")
97 else if(readerName == "Thermo RAW")
99 else if(readerName == "Water RAW")
101 else if(readerName == "Bruker FID")
103 else if(readerName == "Bruker YEP")
105 else if(readerName == "Bruker BAF")
107 else
108 {
110 return 0;
111 }
112
113 // std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
114 // << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
115 // << std::endl;
116
117 // At this point we know pwiz could be able to read the file. Actually fill-in
118 // the MSDataPtr vector!
119 try
120 {
121 defaultReaderList.read(Utils::toUtf8StandardString(m_fileName),
123 }
124 catch(std::runtime_error &error)
125 {
126 qDebug() << error.what() << " " << typeid(error).name();
127
128 throw PappsoException(
129 QObject::tr(
130 "libpwiz ERROR reading MS data file %1 "
131 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
132 .arg(m_fileName)
133 .arg(error.what())
134 .arg(__FILE__)
135 .arg(__LINE__));
136 }
137 catch(std::exception &error)
138 {
139 qDebug() << error.what() << " " << typeid(error).name();
140
141 throw PappsoException(
142 QObject::tr(
143 "libpwiz ERROR reading MS data file %1 "
144 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
145 .arg(m_fileName)
146 .arg(error.what())
147 .arg(__FILE__)
148 .arg(__LINE__));
149 }
150
151 // qDebug() << "The number of runs is:" << m_msDataPtrVector.size()
152 //<< "The reader type is:" << QString::fromStdString(readerName)
153 //<< "The number of spectra in first run is:"
154 //<< m_msDataPtrVector.at(0)->run.spectrumListPtr->size();
155
156 return m_msDataPtrVector.size();
157}
static std::string toUtf8StandardString(const QString &text)
Definition utils.cpp:166
@ unknown
unknown format
Definition types.h:149
@ MGF
Mascot format.
Definition types.h:152

References pappso::Enums::abSciexT2D, pappso::Enums::abSciexWiff, pappso::Enums::agilentMassHunter, pappso::Enums::brukerBaf, pappso::Enums::brukerFid, pappso::Enums::brukerYep, pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, m_msDataPtrVector, pappso::Enums::MGF, pappso::Enums::msn, pappso::Enums::mz5, pappso::Enums::mzML, pappso::Enums::mzXML, pappso::Enums::thermoRaw, pappso::Utils::toUtf8StandardString(), pappso::Enums::unknown, and pappso::Enums::watersRaw.

Referenced by getMsRunIds().

Member Data Documentation

◆ m_msDataPtrVector

std::vector<pwiz::msdata::MSDataPtr> pappso::PwizMsFileReader::m_msDataPtrVector
private

Definition at line 20 of file pwizmsfilereader.h.

Referenced by getMsRunIds(), and initialize().


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