15#include "../exception/exceptionnotfound.h"
16#include "../exception/exceptionnotpossible.h"
17#include "../exception/exceptionnotrecognized.h"
18#include "../msrun/msrunid.h"
19#include "../msrun/private/timsframesmsrunreader.h"
21#include "../msrun/private/pwizmsrunreader.h"
22#include "../msrun/private/timsmsrunreader.h"
23#include "../msrun/private/timsmsrunreaderms2.h"
24#include "../msrun/bafasciimsrunreader.h"
25#include "../msrun/xymsrunreader.h"
35 const QString &xml_prefix)
36 : m_fileName(file_name), m_xmlPrefix(xml_prefix)
38 QFile file(file_name);
41 .arg(QFileInfo(file_name).absoluteFilePath())));
47 "No nativeID format indicates that the file tagged with this term does not "
48 "contain spectra that can have a nativeID format.";
53 : m_fileName(other.m_fileName),
54 m_xmlPrefix(other.m_xmlPrefix),
55 m_fileFormat(other.m_fileFormat),
56 m_fileReaderType(other.m_fileReaderType)
89 term.
m_name =
"SCIEX TOF/TOF T2D format";
91 "Applied Biosystems/MDS Analytical Technologies TOF/TOF instrument "
96 term.
m_name =
"ABI WIFF format";
97 term.
m_definition =
"Applied Biosystems WIFF file format.";
101 term.
m_name =
"Agilent MassHunter format";
103 "A data file format found in an Agilent MassHunter directory which "
104 "contains raw data acquired by an Agilent mass spectrometer.";
110 term.
m_name =
"Bruker FID format";
115 term.
m_name =
"Bruker TDF format";
120 term.
m_name =
"Bruker/Agilent YEP format";
125 term.
m_name =
"Mascot MGF format";
132 term.
m_name =
"mz5 format";
133 term.
m_definition =
"mz5 file format, modelled after mzML.";
137 term.
m_name =
"mzML format";
139 "Proteomics Standards Inititative mzML file format.";
143 term.
m_name =
"ISB mzXML format";
144 term.
m_definition =
"Institute of Systems Biology mzXML file format.";
151 term.
m_name =
"Thermo RAW format";
152 term.
m_definition =
"Thermo Scientific RAW file format.";
158 term.
m_name =
"Waters raw format";
160 "Waters data file format found in a Waters RAW directory, generated "
161 "from an MS acquisition.";
165 term.
m_name =
"BafAscii text format";
167 "Simple text file format obtained by exporting Bruker Baf to ascii "
168 "using Bruker software";
172 term.
m_name =
"text format";
174 "Simple text file format of \"m/z<separator>intensity\" value pairs "
175 "for a single mass spectrum, a PMF (or single MS2) search.";
194std::vector<MsRunIdCstSPtr>
203 std::vector<MsRunIdCstSPtr> ms_run_ids =
205 if(ms_run_ids.size())
207 qDebug() <<
"Might well be handled using the Pwiz code.";
223 qDebug() <<
"The Pwiz reader did not work.";
228 if(!QFileInfo(tims_dir).isDir())
230 tims_dir = QFileInfo(
m_fileName).absolutePath();
237 if(ms_run_ids.size())
239 qDebug() <<
"Might well be handled using the Bruker code";
251 qDebug() <<
"Returning Bruker::tims ms run(s)."
252 <<
"with preferred reader type:"
258 qDebug() <<
"The Tims reader did not work.";
269 if(ms_run_ids.size())
271 qDebug() <<
"Might well be handled using the BafAscii code";
289 qDebug() <<
"This is not a BafAscii code file" << error.
qwhat();
293 qDebug() <<
"The BafAscii reader did not work.";
301 if(ms_run_ids.size())
303 qDebug() <<
"Might well be handled using the XY code";
312 qDebug() <<
"The XY reader did not work.";
325 std::pair<MsDataFormat, FileReaderType>(format, reader_type));
330 ret.first->second = reader_type;
376 if(!QFileInfo(tims_dir).isDir())
378 tims_dir = QFileInfo(
m_fileName).absolutePath();
382 std::vector<MsRunIdCstSPtr> ms_run_ids =
385 if(ms_run_ids.size())
392 return std::make_shared<TimsMsRunReaderMs2>(ms_run_ids.front());
397 QObject::tr(
"Unable to read mz data directory %1 with TimsTOF reader.")
413 QObject::tr(
"The MsRunId instance must have the name file name as the "
414 "MsFileAccessor.")));
419 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
421 pwiz_reader->getOboPsiModTermNativeIDFormat();
428 return std::make_shared<XyMsRunReader>(ms_run_id);
434 return std::make_shared<TimsMsRunReader>(ms_run_id);
441 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
447 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
453 return std::make_shared<BafAsciiMsRunReader>(ms_run_id);
459 return std::make_shared<XyMsRunReader>(ms_run_id);
463 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
465 pwiz_reader->getOboPsiModTermNativeIDFormat();
481 std::vector<MsRunIdCstSPtr> ms_run_ids =
getMsRunIds();
482 if(ms_run_id_index >= ms_run_ids.size())
483 throw PappsoException(QObject::tr(
"MsRunId request out-of-bound error."));
508 QFile file(ms_run_id.get()->getFileName());
511 QObject::tr(
"unable to build a reader : file %1 not found.")
512 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
514 MsDataFormat file_format = ms_run_id.get()->getMsDataFormat();
520 return std::make_shared<XyMsRunReader>(ms_run_id);
526 return std::make_shared<BafAsciiMsRunReader>(ms_run_id);
531 QObject::tr(
"unable to build a reader for %1 : unknown file format")
532 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
539 return std::make_shared<TimsMsRunReader>(ms_run_id);
543 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
548 <<
"returning std::make_shared<TimsFramesMsRunReader>(ms_run_id).";
549 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
552 return std::make_shared<TimsMsRunReader>(ms_run_id);
557 return std::make_shared<PwizMsRunReader>(ms_run_id);
564 const QString &xml_id)
566 std::vector<MsRunIdCstSPtr> run_list =
getMsRunIds();
570 if(original_run_id.get()->getRunId() == run_id)
572 MsRunId new_run_id(*original_run_id.get());
579 if((run_id.isEmpty()) && (run_list.size() == 1))
581 MsRunId new_run_id(*run_list[0].get());
588 if(reader_sp ==
nullptr)
593 .arg(QFileInfo(
m_fileName).absoluteFilePath())));
virtual MsDataFormat getFileFormat() override
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
const OboPsiModTerm & getOboPsiModTermNativeIDFormat() const
get OboPsiModTerm corresponding to the nativeID format format of mz data
std::map< MsDataFormat, FileReaderType > m_preferredFileReaderTypeMap
MsRunIdCstSPtr getSelectedMsRunId() const
MsRunReaderSPtr msRunReaderSPtr(MsRunIdCstSPtr ms_run_id)
const QString m_xmlPrefix
void setPreferredFileReaderType(MsDataFormat format, FileReaderType reader_type)
given an mz format, explicitly set the preferred reader
virtual ~MsFileAccessor()
FileReaderType getpreferredFileReaderType(MsDataFormat format)
MsRunReaderSPtr msRunReaderSPtrForSelectedMsRunId()
FileReaderType getFileReaderType() const
get the file reader type
MsRunIdCstSPtr mcsp_selectedMsRunId
MsDataFormat getFileFormat() const
get the raw format of mz data
std::vector< MsRunIdCstSPtr > getMsRunIds()
OboPsiModTerm m_oboPsiModTermNativeIDFormat
void setSelectedMsRunId(MsRunIdCstSPtr ms_run_id_csp)
const OboPsiModTerm getOboPsiModTermFileFormat() const
get OboPsiModTerm corresponding to the raw format of mz data
FileReaderType m_fileReaderType
MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id, const QString &xml_id)
get an msrun reader by finding the run_id in file
MsFileAccessor(const QString &file_name, const QString &xml_prefix)
static MsRunReaderSPtr buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id)
get an MsRunReader directly from a valid MsRun ID
TimsMsRunReaderMs2SPtr buildTimsMsRunReaderMs2SPtr()
if possible, builds directly a dedicated Tims TOF tdf file reader
MsDataFormat m_fileFormat
const QString & getFileName() const
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
virtual const QString & qwhat() const
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
virtual MsDataFormat getFileFormat() override
virtual MsDataFormat getFileFormat() override
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
static QString fileReaderTypeAsString(FileReaderType file_reader_type)
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
virtual MsDataFormat getFileFormat() override
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< MsRunReader > MsRunReaderSPtr
std::shared_ptr< TimsMsRunReaderMs2 > TimsMsRunReaderMs2SPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
@ tims
TimsMsRunReader : each scan is returned as a mass spectrum.
MSrun file reader for native Bruker TimsTOF raw data.