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 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
 
MsDataFormat m_fileFormat = 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 28 of file pwizmsfilereader.cpp.

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

◆ ~PwizMsFileReader()

pappso::PwizMsFileReader::~PwizMsFileReader ( )
virtual

Definition at line 34 of file pwizmsfilereader.cpp.

35{
36}

Member Function Documentation

◆ getFileFormat()

MsDataFormat pappso::PwizMsFileReader::getFileFormat ( )
overridevirtual

Implements pappso::MsFileReader.

Definition at line 164 of file pwizmsfilereader.cpp.

165{
166 // std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
167 // << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
168 // << std::endl;
169
170 return m_fileFormat;
171}
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 175 of file pwizmsfilereader.cpp.

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

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 40 of file pwizmsfilereader.cpp.

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

References pappso::abSciexT2D, pappso::abSciexWiff, pappso::agilentMassHunter, pappso::brukerBaf, pappso::brukerFid, pappso::brukerYep, pappso::MsFileReader::m_fileFormat, pappso::MsFileReader::m_fileName, m_msDataPtrVector, pappso::MGF, pappso::msn, pappso::mz5, pappso::mzML, pappso::mzXML, pappso::thermoRaw, pappso::Utils::toUtf8StandardString(), pappso::unknown, and pappso::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: