14 #include "../exception/exceptionnotfound.h"
15 #include "../exception/exceptionnotpossible.h"
17 #include "../msrun/msrunid.h"
18 #include "../msrun/private/pwizmsrunreader.h"
19 #include "../msrun/private/timsmsrunreader.h"
20 #include "../msrun/private/timsmsrunreaderms2.h"
21 #include "../msrun/xymsrunreader.h"
29 const QString &xml_prefix)
30 : m_fileName(file_name), m_xmlPrefix(xml_prefix)
32 QFile file(file_name);
35 .arg(QFileInfo(file_name).absoluteFilePath())));
40 : m_fileName(other.m_fileName),
41 m_xmlPrefix(other.m_xmlPrefix),
42 m_fileFormat(other.m_fileFormat),
43 m_fileReaderType(other.m_fileReaderType)
66 std::vector<MsRunIdCstSPtr>
75 std::vector<MsRunIdCstSPtr> ms_run_ids =
92 if(!QFileInfo(tims_dir).isDir())
94 tims_dir = QFileInfo(
m_fileName).absolutePath();
100 if(ms_run_ids.size())
125 if(ms_run_ids.size())
147 if(!QFileInfo(tims_dir).isDir())
149 tims_dir = QFileInfo(
m_fileName).absolutePath();
153 std::vector<MsRunIdCstSPtr> ms_run_ids =
156 if(ms_run_ids.size())
163 return std::make_shared<TimsMsRunReaderMs2>(ms_run_ids.front());
168 QObject::tr(
"Unable to read mz data directory %1 with TimsTOF reader.")
178 QObject::tr(
"The MsRunId instance must have the name file name as the "
179 "MsFileAccessor.")));
183 qDebug() <<
"Returning a PwizMsRunReader.";
185 return std::make_shared<PwizMsRunReader>(ms_run_id);
189 qDebug() <<
"Returning a XyMsRunReader.";
191 return std::make_shared<XyMsRunReader>(ms_run_id);
196 qDebug() <<
"Returning a TimsMsRunReader.";
198 return std::make_shared<TimsMsRunReader>(ms_run_id);
202 qDebug() <<
"Returning a TimsMsRunReaderMs2.";
204 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
209 if(ms_run_id.get()->getMzFormat() == MzFormat::xy)
211 return std::make_shared<XyMsRunReader>(ms_run_id);
215 return std::make_shared<PwizMsRunReader>(ms_run_id);
226 QFile file(ms_run_id.get()->getFileName());
229 QObject::tr(
"unable to build a reader : file %1 not found.")
230 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
232 MzFormat file_format = ms_run_id.get()->getMzFormat();
234 if(file_format == MzFormat::xy)
236 qDebug() <<
"Returning a XyMsRunReader.";
238 return std::make_shared<XyMsRunReader>(ms_run_id);
240 else if(file_format == MzFormat::unknown)
243 QObject::tr(
"unable to build a reader for %1 : unknown file format")
244 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
246 else if(file_format == MzFormat::brukerTims)
248 qDebug() <<
"by default, build a TimsMsRunReader.";
249 return std::make_shared<TimsMsRunReader>(ms_run_id);
253 qDebug() <<
"Returning a PwizMsRunReader .";
255 return std::make_shared<PwizMsRunReader>(ms_run_id);
261 const QString &xml_id)
263 qDebug() <<
"GGGGGGGGG1";
264 std::vector<MsRunIdCstSPtr> run_list =
getMsRunIds();
266 qDebug() <<
"GGGGGGGGG";
269 if(original_run_id.get()->getRunId() == run_id)
271 MsRunId new_run_id(*original_run_id.get());
278 if((run_id.isEmpty()) && (run_list.size() == 1))
280 MsRunId new_run_id(*run_list[0].get());
287 if(reader_sp ==
nullptr)
292 .arg(QFileInfo(
m_fileName).absoluteFilePath())));
302 std::pair<MzFormat, FileReaderType>(format, reader_type));
306 ret.first->second = reader_type;