14#include "../exception/exceptionnotfound.h"
15#include "../exception/exceptionnotpossible.h"
16#include "../msrun/msrunid.h"
17#include "../msrun/private/timsframesmsrunreader.h"
19#include "../msrun/private/pwizmsrunreader.h"
20#include "../msrun/private/timsmsrunreader.h"
21#include "../msrun/private/timsmsrunreaderms2.h"
22#include "../msrun/xymsrunreader.h"
32 const QString &xml_prefix)
33 : m_fileName(file_name), m_xmlPrefix(xml_prefix)
35 QFile file(file_name);
38 .arg(QFileInfo(file_name).absoluteFilePath())));
44 "No nativeID format indicates that the file tagged with this term does not "
45 "contain spectra that can have a nativeID format.";
50 : m_fileName(other.m_fileName),
51 m_xmlPrefix(other.m_xmlPrefix),
52 m_fileFormat(other.m_fileFormat),
53 m_fileReaderType(other.m_fileReaderType)
86 term.
m_name =
"SCIEX TOF/TOF T2D format";
88 "Applied Biosystems/MDS Analytical Technologies TOF/TOF instrument "
93 term.
m_name =
"ABI WIFF format";
94 term.
m_definition =
"Applied Biosystems WIFF file format.";
98 term.
m_name =
"Agilent MassHunter format";
100 "A data file format found in an Agilent MassHunter directory which "
101 "contains raw data acquired by an Agilent mass spectrometer.";
107 term.
m_name =
"Bruker FID format";
112 term.
m_name =
"Bruker TDF format";
117 term.
m_name =
"Bruker/Agilent YEP format";
122 term.
m_name =
"Mascot MGF format";
129 term.
m_name =
"mz5 format";
130 term.
m_definition =
"mz5 file format, modelled after mzML.";
134 term.
m_name =
"mzML format";
136 "Proteomics Standards Inititative mzML file format.";
140 term.
m_name =
"ISB mzXML format";
141 term.
m_definition =
"Institute of Systems Biology mzXML file format.";
148 term.
m_name =
"Thermo RAW format";
149 term.
m_definition =
"Thermo Scientific RAW file format.";
155 term.
m_name =
"Waters raw format";
157 "Waters data file format found in a Waters RAW directory, generated "
158 "from an MS acquisition.";
162 term.
m_name =
"text format";
164 "Simple text file format of \"m/z [intensity]\" values for a PMF (or "
165 "single MS2) search.";
184std::vector<MsRunIdCstSPtr>
193 std::vector<MsRunIdCstSPtr> ms_run_ids =
195 if(ms_run_ids.size())
217 if(!QFileInfo(tims_dir).isDir())
219 tims_dir = QFileInfo(
m_fileName).absolutePath();
226 if(ms_run_ids.size())
255 if(ms_run_ids.size())
278 std::pair<MsDataFormat, FileReaderType>(format, reader_type));
283 ret.first->second = reader_type;
329 throw PappsoException(QObject::tr(
"MsRunId request out-of-bound error."));
339 if(!QFileInfo(tims_dir).isDir())
341 tims_dir = QFileInfo(
m_fileName).absolutePath();
345 std::vector<MsRunIdCstSPtr> ms_run_ids =
348 if(ms_run_ids.size())
355 return std::make_shared<TimsMsRunReaderMs2>(ms_run_ids.front());
360 QObject::tr(
"Unable to read mz data directory %1 with TimsTOF reader.")
376 QObject::tr(
"The MsRunId instance must have the name file name as the "
377 "MsFileAccessor.")));
382 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
384 pwiz_reader->getOboPsiModTermNativeIDFormat();
391 return std::make_shared<XyMsRunReader>(ms_run_id);
397 return std::make_shared<TimsMsRunReader>(ms_run_id);
404 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
410 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
416 return std::make_shared<XyMsRunReader>(ms_run_id);
421 auto pwiz_reader = std::make_shared<PwizMsRunReader>(ms_run_id);
423 pwiz_reader->getOboPsiModTermNativeIDFormat();
439 std::vector<MsRunIdCstSPtr> ms_run_ids =
getMsRunIds();
440 if(ms_run_id_index >= ms_run_ids.size())
441 throw PappsoException(QObject::tr(
"MsRunId request out-of-bound error."));
452 std::vector<MsRunIdCstSPtr> ms_run_ids =
getMsRunIds();
455 throw PappsoException(QObject::tr(
"MsRunId request out-of-bound error."));
471 QFile file(ms_run_id.get()->getFileName());
474 QObject::tr(
"unable to build a reader : file %1 not found.")
475 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
477 MsDataFormat file_format = ms_run_id.get()->getMsDataFormat();
483 return std::make_shared<XyMsRunReader>(ms_run_id);
488 QObject::tr(
"unable to build a reader for %1 : unknown file format")
489 .arg(QFileInfo(ms_run_id.get()->getFileName()).absoluteFilePath())));
496 return std::make_shared<TimsMsRunReader>(ms_run_id);
500 return std::make_shared<TimsMsRunReaderMs2>(ms_run_id);
505 <<
"returning std::make_shared<TimsFramesMsRunReader>(ms_run_id).";
506 return std::make_shared<TimsFramesMsRunReader>(ms_run_id);
509 return std::make_shared<TimsMsRunReader>(ms_run_id);
514 auto sp_pwiz = std::make_shared<PwizMsRunReader>(ms_run_id);
522 const QString &xml_id)
524 std::vector<MsRunIdCstSPtr> run_list =
getMsRunIds();
528 if(original_run_id.get()->getRunId() == run_id)
530 MsRunId new_run_id(*original_run_id.get());
537 if((run_id.isEmpty()) && (run_list.size() == 1))
539 MsRunId new_run_id(*run_list[0].get());
546 if(reader_sp ==
nullptr)
551 .arg(QFileInfo(
m_fileName).absoluteFilePath())));
MsRunReaderSPtr msRunReaderSPtrForSelectedMsRunIdIndex()
void setSelectedMsRunIdIndex(std::size_t index)
const OboPsiModTerm & getOboPsiModTermNativeIDFormat() const
get OboPsiModTerm corresponding to the nativeID format format of mz data
std::map< MsDataFormat, FileReaderType > m_preferredFileReaderTypeMap
MsRunReaderSPtr msRunReaderSPtr(MsRunIdCstSPtr ms_run_id)
std::size_t m_selectedMsRunIdIndex
const QString m_xmlPrefix
std::size_t getSelectedMsRunIdIndex() const
void setPreferredFileReaderType(MsDataFormat format, FileReaderType reader_type)
given an mz format, explicitly set the preferred reader
virtual ~MsFileAccessor()
FileReaderType getpreferredFileReaderType(MsDataFormat format)
MsRunIdCstSPtr getSelectedMsRunId()
FileReaderType getFileReaderType() const
get the file reader type
MsDataFormat getFileFormat() const
get the raw format of mz data
std::vector< MsRunIdCstSPtr > getMsRunIds()
OboPsiModTerm m_oboPsiModTermNativeIDFormat
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 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
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
MSrun file reader for native Bruker TimsTOF raw data.