libpappsomspp
Library for mass spectrometry
msfileaccessor.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <QString>
5 #include <QMetaType>
6 
7 
8 #include "../types.h"
9 #include "../msrun/msrunreader.h"
10 #include "../msrun/msrunid.h"
11 #include "../exportinmportconfig.h"
12 
13 
14 namespace pappso
15 {
16 
17 class TimsMsRunReaderMs2;
18 typedef std::shared_ptr<TimsMsRunReaderMs2> TimsMsRunReaderMs2SPtr;
19 
20 enum class FileReaderType
21 {
22  pwiz,
23  xy,
24  tims,
25  tims_ms2,
26 };
27 
28 // This class is used to access mass spectrometry data files. The file being
29 // opened and read might contain more than one MS run. The user of this class
30 // might request a vector of all these MS runs (in the form of a vector of
31 // MsRunIdCstSPtr. Once the MsRunIdCstSPtr of interest has been located by the
32 // caller, the caller might then request the MsRunReaderSPtr to use to read that
33 // MS run's data.
35 {
36  public:
37  MsFileAccessor(const QString &file_name, const QString &xml_prefix);
38  MsFileAccessor(const MsFileAccessor &other);
39  virtual ~MsFileAccessor();
40 
41  const QString &getFileName() const;
42 
43  /** @brief get the raw format of mz data
44  */
45  MzFormat getFileFormat() const;
46 
47  /** @brief given an mz format, explicitly set the prefered reader
48  */
49  void setPreferedFileReaderType(MzFormat format, FileReaderType reader_type);
50 
51  std::vector<MsRunIdCstSPtr> getMsRunIds();
52 
53  MsRunReaderSPtr msRunReaderSp(MsRunIdCstSPtr ms_run_id);
54 
55  /** @brief get an msrun reader by finding the run_id in file
56  *
57  * @param run_id identifier within file of the MSrun
58  * @param xml_id XML identifier given by the user to identify this MSrun in
59  * our experiment (not in the file)
60  */
61  MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id,
62  const QString &xml_id);
63 
64  /** @brief get an MsRunReader directly from a valid MsRun ID
65  *
66  * no need to check the file format or filename : all is already part of the
67  * msrunid
68  */
69  static MsRunReaderSPtr buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id);
70 
71  /** @brief if possible, builds directly a dedicated Tims TOF tdf file reader
72  */
73  TimsMsRunReaderMs2SPtr buildTimsMsRunReaderMs2SPtr();
74 
75  private:
76  QString m_fileName;
77 
78  // When opening more than one file concurrently in a determinate session, we
79  // need this prefix to craft unabiguous ms run ids.
80  const QString m_xmlPrefix;
81 
82  MzFormat m_fileFormat = MzFormat::unknown;
83 
84  // Type of the file reader that could load the file.
86 
87  std::map<MzFormat, FileReaderType> m_preferedFileReaderTypeMap;
88 };
89 
90 } // namespace pappso
pappso::MsFileAccessor::m_preferedFileReaderTypeMap
std::map< MzFormat, FileReaderType > m_preferedFileReaderTypeMap
Definition: msfileaccessor.h:87
pappso::FileReaderType::xy
@ xy
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
Definition: aa.cpp:39
pappso::FileReaderType::tims
@ tims
pappso::MsFileAccessor::m_fileReaderType
FileReaderType m_fileReaderType
Definition: msfileaccessor.h:85
pappso::MsRunReaderSPtr
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:172
pappso::FileReaderType::pwiz
@ pwiz
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:65
pappso::MzFormat::unknown
@ unknown
unknown format
pappso::MsFileAccessor
Definition: msfileaccessor.h:35
pappso::MsFileAccessor::m_xmlPrefix
const QString m_xmlPrefix
Definition: msfileaccessor.h:80
pappso::FileReaderType
FileReaderType
Definition: msfileaccessor.h:21
pappso::FileReaderType::tims_ms2
@ tims_ms2
pappso::TimsMsRunReaderMs2SPtr
std::shared_ptr< TimsMsRunReaderMs2 > TimsMsRunReaderMs2SPtr
Definition: msfileaccessor.h:17
pappso::MsFileAccessor::m_fileName
QString m_fileName
Definition: msfileaccessor.h:76
pappso::MzFormat
MzFormat
Definition: types.h:128