msfileaccessor.h
Go to the documentation of this file.
#pragma once
#include <QString>
#include <QMetaType>
#include "../types.h"
#include "../msrun/msrunreader.h"
#include "../msrun/msrunid.h"
#include "../exportinmportconfig.h"
namespace pappso
{
class TimsMsRunReaderMs2;
typedef std::shared_ptr<TimsMsRunReaderMs2> TimsMsRunReaderMs2SPtr;
enum class FileReaderType
{
pwiz,
xy,
tims,
tims_ms2,
};
// This class is used to access mass spectrometry data files. The file being
// opened and read might contain more than one MS run. The user of this class
// might request a vector of all these MS runs (in the form of a vector of
// MsRunIdCstSPtr. Once the MsRunIdCstSPtr of interest has been located by the
// caller, the caller might then request the MsRunReaderSPtr to use to read that
// MS run's data.
class PMSPP_LIB_DECL MsFileAccessor
{
public:
MsFileAccessor(const QString &file_name, const QString &xml_prefix);
MsFileAccessor(const MsFileAccessor &other);
virtual ~MsFileAccessor();
const QString &getFileName() const;
/** @brief get the raw format of mz data
*/
MzFormat getFileFormat() const;
/** @brief get the file reader type
*/
FileReaderType getFileReaderType() const;
/** @brief given an mz format, explicitly set the prefered reader
*/
void setPreferedFileReaderType(MzFormat format, FileReaderType reader_type);
std::vector<MsRunIdCstSPtr> getMsRunIds();
MsRunReaderSPtr msRunReaderSp(MsRunIdCstSPtr ms_run_id);
/** @brief get an msrun reader by finding the run_id in file
*
* @param run_id identifier within file of the MSrun
* @param xml_id XML identifier given by the user to identify this MSrun in
* our experiment (not in the file)
*/
MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id,
const QString &xml_id);
/** @brief get an MsRunReader directly from a valid MsRun ID
*
* no need to check the file format or filename : all is already part of the
* msrunid
*
* @param ms_run_id msrun identifier
* @return msrun reader shared pointer
*/
static MsRunReaderSPtr buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id);
/** @brief get an MsRunReader directly from a valid MsRun ID
*
* no need to check the file format or filename : all is already part of the
* msrunid
*
* @param ms_run_id msrun identifier
* @param prefered_file_reader_type the prefered file reader type to use
* (depending on the mz format)
* @return msrun reader shared pointer
*/
static MsRunReaderSPtr
buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id,
pappso::FileReaderType prefered_file_reader_type);
/** @brief if possible, builds directly a dedicated Tims TOF tdf file reader
*/
TimsMsRunReaderMs2SPtr buildTimsMsRunReaderMs2SPtr();
private:
QString m_fileName;
// When opening more than one file concurrently in a determinate session, we
// need this prefix to craft unabiguous ms run ids.
const QString m_xmlPrefix;
MzFormat m_fileFormat = MzFormat::unknown;
// Type of the file reader that could load the file.
FileReaderType m_fileReaderType;
std::map<MzFormat, FileReaderType> m_preferedFileReaderTypeMap;
};
} // namespace pappso
pappso::MsFileAccessor
Definition: msfileaccessor.h:35
pappso::MsFileAccessor::m_xmlPrefix
const QString m_xmlPrefix
Definition: msfileaccessor.h:101
pappso::MsFileAccessor::m_fileName
QString m_fileName
Definition: msfileaccessor.h:97
pappso::MsFileAccessor::m_preferedFileReaderTypeMap
std::map< MzFormat, FileReaderType > m_preferedFileReaderTypeMap
Definition: msfileaccessor.h:108
pappso::MsFileAccessor::m_fileReaderType
FileReaderType m_fileReaderType
Definition: msfileaccessor.h:106
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition: exportinmportconfig.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
pappso::MsRunReaderSPtr
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:184
pappso::TimsMsRunReaderMs2SPtr
std::shared_ptr< TimsMsRunReaderMs2 > TimsMsRunReaderMs2SPtr
Definition: msfileaccessor.h:17
pappso::MzFormat
MzFormat
Definition: types.h:107
pappso::MzFormat::unknown
@ unknown
unknown format
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:44
pappso::FileReaderType
FileReaderType
Definition: msfileaccessor.h:21
pappso::FileReaderType::pwiz
@ pwiz
pappso::FileReaderType::xy
@ xy
pappso::FileReaderType::tims_ms2
@ tims_ms2
pappso::FileReaderType::tims
@ tims