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 const QString &xml_prefix)
37 : m_fileName(file_name), m_xmlPrefix(xml_prefix)
39 QFile file(file_name);
42 .arg(QFileInfo(file_name).absoluteFilePath())));
48 "No nativeID format indicates that the file tagged with this term does not "
49 "contain spectra that can have a nativeID format.";
54 : m_fileName(other.m_fileName),
55 m_xmlPrefix(other.m_xmlPrefix),
56 m_fileFormat(other.m_fileFormat),
57 m_fileReaderType(other.m_fileReaderType)
90 term.
m_name =
"SCIEX TOF/TOF T2D format";
92 "Applied Biosystems/MDS Analytical Technologies TOF/TOF instrument "
97 term.
m_name =
"ABI WIFF format";
98 term.
m_definition =
"Applied Biosystems WIFF file format.";
102 term.
m_name =
"Agilent MassHunter format";
104 "A data file format found in an Agilent MassHunter directory which "
105 "contains raw data acquired by an Agilent mass spectrometer.";
111 term.
m_name =
"Bruker FID format";
116 term.
m_name =
"Bruker TDF format";
121 term.
m_name =
"Bruker/Agilent YEP format";
126 term.
m_name =
"Mascot MGF format";
133 term.
m_name =
"mz5 format";
134 term.
m_definition =
"mz5 file format, modelled after mzML.";
138 term.
m_name =
"mzML format";
140 "Proteomics Standards Inititative mzML file format.";
144 term.
m_name =
"ISB mzXML format";
145 term.
m_definition =
"Institute of Systems Biology mzXML file format.";
152 term.
m_name =
"Thermo RAW format";
153 term.
m_definition =
"Thermo Scientific RAW file format.";
159 term.
m_name =
"Waters raw format";
161 "Waters data file format found in a Waters RAW directory, generated "
162 "from an MS acquisition.";
166 term.
m_name =
"BafAscii text format";
168 "Simple text file format obtained by exporting Bruker Baf to ascii "
169 "using Bruker software";
173 term.
m_name =
"text format";
175 "Simple text file format of \"m/z<separator>intensity\" value pairs "
176 "for a single mass spectrum, a PMF (or single MS2) search.";
195std::vector<MsRunIdCstSPtr>
204 std::vector<MsRunIdCstSPtr> ms_run_ids =
206 if(ms_run_ids.size())
208 qDebug() <<
"Might well be handled using the Pwiz code.";
224 qDebug() <<
"The Pwiz reader did not work.";
229 if(!QFileInfo(tims_dir).isDir())
231 tims_dir = QFileInfo(
m_fileName).absolutePath();
238 if(ms_run_ids.size())
240 qDebug() <<
"Might well be handled using the Bruker code";
252 qDebug() <<
"Returning Bruker::tims ms run(s)."
253 <<
"with preferred reader type:"
259 qDebug() <<
"The Tims reader did not work.";
270 if(ms_run_ids.size())
272 qDebug() <<
"Might well be handled using the BafAscii code";
290 qDebug() <<
"This is not a BafAscii code file" << error.
qwhat();
294 qDebug() <<
"The BafAscii reader did not work.";
302 if(ms_run_ids.size())
304 qDebug() <<
"Might well be handled using the XY code";
313 qDebug() <<
"The XY reader did not work.";
326 std::pair<MsDataFormat, FileReaderType>(format, reader_type));
331 ret.first->second = reader_type;
377 if(!QFileInfo(tims_dir).isDir())
379 tims_dir = QFileInfo(
m_fileName).absolutePath();
383 std::vector<MsRunIdCstSPtr> ms_run_ids =
386 if(ms_run_ids.size())
393 return std::make_shared<TimsMsRunReaderMs2>(ms_run_ids.front());
398 QObject::tr(
"Unable to read mz data directory %1 with TimsTOF reader.")
414 QObject::tr(
"The MsRunId instance must have the name file name as the "
415 "MsFileAccessor.")));
420 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
422 pwiz_reader->getOboPsiModTermNativeIDFormat();
429 return std::make_shared<XyMsRunReader>(ms_run_id);
435 return std::make_shared<TimsMsRunReader>(ms_run_id);
442 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
448 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
455 return std::make_shared<TimsMsRunReaderDia>(ms_run_id);
461 return std::make_shared<BafAsciiMsRunReader>(ms_run_id);
467 return std::make_shared<XyMsRunReader>(ms_run_id);
471 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
473 pwiz_reader->getOboPsiModTermNativeIDFormat();
489 std::vector<MsRunIdCstSPtr> ms_run_ids =
getMsRunIds();
490 if(ms_run_id_index >= ms_run_ids.size())
491 throw PappsoException(QObject::tr(
"MsRunId request out-of-bound error."));
516 QFile file(ms_run_id.get()->getFileName());
519 QObject::tr(
"unable to build a reader : file %1 not found.")
520 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
522 MsDataFormat file_format = ms_run_id.get()->getMsDataFormat();
528 return std::make_shared<XyMsRunReader>(ms_run_id);
534 return std::make_shared<BafAsciiMsRunReader>(ms_run_id);
539 QObject::tr(
"unable to build a reader for %1 : unknown file format")
540 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
547 return std::make_shared<TimsMsRunReader>(ms_run_id);
551 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
556 <<
"returning std::make_shared<TimsFramesMsRunReader>(ms_run_id).";
557 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
560 return std::make_shared<TimsMsRunReader>(ms_run_id);
565 return std::make_shared<PwizMsRunReader>(ms_run_id);
572 const QString &xml_id)
574 std::vector<MsRunIdCstSPtr> run_list =
getMsRunIds();
578 if(original_run_id.get()->getRunId() == run_id)
580 MsRunId new_run_id(*original_run_id.get());
587 if((run_id.isEmpty()) && (run_list.size() == 1))
589 MsRunId new_run_id(*run_list[0].get());
596 if(reader_sp ==
nullptr)
601 .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.