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 get the file reader type
48  */
49  FileReaderType getFileReaderType() const;
50 
51  /** @brief given an mz format, explicitly set the prefered reader
52  */
53  void setPreferedFileReaderType(MzFormat format, FileReaderType reader_type);
54 
55  std::vector<MsRunIdCstSPtr> getMsRunIds();
56 
57  MsRunReaderSPtr msRunReaderSp(MsRunIdCstSPtr ms_run_id);
58 
59  /** @brief get an msrun reader by finding the run_id in file
60  *
61  * @param run_id identifier within file of the MSrun
62  * @param xml_id XML identifier given by the user to identify this MSrun in
63  * our experiment (not in the file)
64  */
65  MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id,
66  const QString &xml_id);
67 
68  /** @brief get an MsRunReader directly from a valid MsRun ID
69  *
70  * no need to check the file format or filename : all is already part of the
71  * msrunid
72  *
73  * @param ms_run_id msrun identifier
74  * @return msrun reader shared pointer
75  */
76  static MsRunReaderSPtr buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id);
77 
78  /** @brief get an MsRunReader directly from a valid MsRun ID
79  *
80  * no need to check the file format or filename : all is already part of the
81  * msrunid
82  *
83  * @param ms_run_id msrun identifier
84  * @param prefered_file_reader_type the prefered file reader type to use
85  * (depending on the mz format)
86  * @return msrun reader shared pointer
87  */
88  static MsRunReaderSPtr
89  buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id,
90  pappso::FileReaderType prefered_file_reader_type);
91 
92  /** @brief if possible, builds directly a dedicated Tims TOF tdf file reader
93  */
94  TimsMsRunReaderMs2SPtr buildTimsMsRunReaderMs2SPtr();
95 
96  private:
97  QString m_fileName;
98 
99  // When opening more than one file concurrently in a determinate session, we
100  // need this prefix to craft unabiguous ms run ids.
101  const QString m_xmlPrefix;
102 
103  MzFormat m_fileFormat = MzFormat::unknown;
104 
105  // Type of the file reader that could load the file.
107 
108  std::map<MzFormat, FileReaderType> m_preferedFileReaderTypeMap;
109 };
110 
111 } // namespace pappso
const QString m_xmlPrefix
std::map< MzFormat, FileReaderType > m_preferedFileReaderTypeMap
FileReaderType m_fileReaderType
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< MsRunReader > MsRunReaderSPtr
Definition: msrunreader.h:166
std::shared_ptr< TimsMsRunReaderMs2 > TimsMsRunReaderMs2SPtr
MzFormat
Definition: types.h:107
@ unknown
unknown format
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:44