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

34{
35}

Member Function Documentation

◆ getFileFormat()

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

Implements pappso::MsFileReader.

Definition at line 158 of file pwizmsfilereader.cpp.

159{
160 // std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
161 // << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
162 // << std::endl;
163
164 return m_fileFormat;
165}
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 169 of file pwizmsfilereader.cpp.

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

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

40{
41 pwiz::msdata::DefaultReaderList defaultReaderList;
42 std::string readerName;
43 try
44 {
45 qDebug() << m_fileName;
46 readerName = defaultReaderList.identify(m_fileName.toStdString());
47 }
48 catch(std::runtime_error &error)
49 {
50 qDebug() << error.what() << " " << typeid(error).name();
51
52 throw PappsoException(
53 QObject::tr("libpwiz ERROR reading MS data file %1 "
54 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
55 .arg(m_fileName)
56 .arg(error.what())
57 .arg(__FILE__)
58 .arg(__LINE__));
59 }
60 catch(std::exception &error)
61 {
62 qDebug() << error.what() << " " << typeid(error).name();
63
64 throw PappsoException(
65 QObject::tr("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 {
122 }
123 catch(std::runtime_error &error)
124 {
125 qDebug() << error.what() << " " << typeid(error).name();
126
127 throw PappsoException(
128 QObject::tr("libpwiz ERROR reading MS data file %1 "
129 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
130 .arg(m_fileName)
131 .arg(error.what())
132 .arg(__FILE__)
133 .arg(__LINE__));
134 }
135 catch(std::exception &error)
136 {
137 qDebug() << error.what() << " " << typeid(error).name();
138
139 throw PappsoException(
140 QObject::tr("libpwiz ERROR reading MS data file %1 "
141 "(std::runtime_error):\n%2\nsource file:%3 - source line:%4")
142 .arg(m_fileName)
143 .arg(error.what())
144 .arg(__FILE__)
145 .arg(__LINE__));
146 }
147
148 // qDebug() << "The number of runs is:" << m_msDataPtrVector.size()
149 //<< "The reader type is:" << QString::fromStdString(readerName)
150 //<< "The number of spectra in first run is:"
151 //<< m_msDataPtrVector.at(0)->run.spectrumListPtr->size();
152
153 return m_msDataPtrVector.size();
154}
static std::string toUtf8StandardString(const QString &text)
Definition utils.cpp:167
@ 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: