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/private/timsmsrunreaderdia.h"
25#include "../msrun/bafasciimsrunreader.h"
26#include "../msrun/xymsrunreader.h"
36 : m_fileName(file_name), m_xmlPrefix(xml_prefix)
38 QFile file(file_name);
41 QObject::tr(
"File %1 not found.").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";
138 term.
m_definition =
"Proteomics Standards Inititative mzML file format.";
142 term.
m_name =
"ISB mzXML format";
143 term.
m_definition =
"Institute of Systems Biology mzXML file format.";
150 term.
m_name =
"Thermo RAW format";
151 term.
m_definition =
"Thermo Scientific RAW file format.";
157 term.
m_name =
"Waters raw format";
159 "Waters data file format found in a Waters RAW directory, generated "
160 "from an MS acquisition.";
164 term.
m_name =
"BafAscii text format";
166 "Simple text file format obtained by exporting Bruker Baf to ascii "
167 "using Bruker software";
171 term.
m_name =
"text format";
173 "Simple text file format of \"m/z<separator>intensity\" value pairs "
174 "for a single mass spectrum, a PMF (or single MS2) search.";
193std::vector<MsRunIdCstSPtr>
203 if(ms_run_ids.size())
205 qDebug() <<
"Might well be handled using the Pwiz code.";
221 qDebug() <<
"The Pwiz reader did not work.";
226 if(!QFileInfo(tims_dir).isDir())
228 tims_dir = QFileInfo(
m_fileName).absolutePath();
235 if(ms_run_ids.size())
237 qDebug() <<
"Might well be handled using the Bruker code";
249 qDebug() <<
"Returning Bruker::tims ms run(s)."
255 qDebug() <<
"The Tims reader did not work.";
266 if(ms_run_ids.size())
268 qDebug() <<
"Might well be handled using the BafAscii code";
286 qDebug() <<
"This is not a BafAscii code file" << error.
qwhat();
290 qDebug() <<
"The BafAscii reader did not work.";
298 if(ms_run_ids.size())
300 qDebug() <<
"Might well be handled using the XY code";
309 qDebug() <<
"The XY reader did not work.";
321 std::pair<MsDataFormat, FileReaderType>(format, reader_type));
326 ret.first->second = reader_type;
372 if(!QFileInfo(tims_dir).isDir())
374 tims_dir = QFileInfo(
m_fileName).absolutePath();
380 if(ms_run_ids.size())
387 return std::make_shared<TimsMsRunReaderMs2>(ms_run_ids.front());
392 QObject::tr(
"Unable to read mz data directory %1 with TimsTOF reader.").arg(tims_dir)));
408 "MsFileAccessor.")));
413 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
421 return std::make_shared<XyMsRunReader>(ms_run_id);
427 return std::make_shared<TimsMsRunReader>(ms_run_id);
433 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
439 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
446 return std::make_shared<TimsMsRunReaderDia>(ms_run_id);
452 return std::make_shared<BafAsciiMsRunReader>(ms_run_id);
458 return std::make_shared<XyMsRunReader>(ms_run_id);
462 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
479 std::vector<MsRunIdCstSPtr> ms_run_ids =
getMsRunIds();
480 if(ms_run_id_index >= ms_run_ids.size())
481 throw PappsoException(QObject::tr(
"MsRunId request out-of-bound error."));
506 QFile file(ms_run_id.get()->getFileName());
508 throw(
ExceptionNotFound(QObject::tr(
"unable to build a reader : file %1 not found.")
509 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
511 MsDataFormat file_format = ms_run_id.get()->getMsDataFormat();
517 return std::make_shared<XyMsRunReader>(ms_run_id);
523 return std::make_shared<BafAsciiMsRunReader>(ms_run_id);
527 throw(
PappsoException(QObject::tr(
"unable to build a reader for %1 : unknown file format")
528 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
535 return std::make_shared<TimsMsRunReader>(ms_run_id);
539 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
543 qDebug() <<
"returning std::make_shared<TimsFramesMsRunReader>(ms_run_id).";
544 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
547 return std::make_shared<TimsMsRunReader>(ms_run_id);
552 return std::make_shared<PwizMsRunReader>(ms_run_id);
560 std::vector<MsRunIdCstSPtr> run_list =
getMsRunIds();
564 if(original_run_id.get()->getRunId() == run_id)
566 MsRunId new_run_id(*original_run_id.get());
573 if((run_id.isEmpty()) && (run_list.size() == 1))
575 MsRunId new_run_id(*run_list[0].get());
582 if(reader_sp ==
nullptr)
586 .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
void setAccession(const QString &accession)
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.