libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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#include "../obo/obopsimodterm.h"
13
14
15namespace pappso
16{
17
18class TimsMsRunReaderMs2;
19typedef std::shared_ptr<TimsMsRunReaderMs2> TimsMsRunReaderMs2SPtr;
20
21// This class is used to access mass spectrometry data files. The file being
22// opened and read might contain more than one MS run. The user of this class
23// might request a vector of all these MS runs (in the form of a vector of
24// MsRunIdCstSPtr. Once the MsRunIdCstSPtr of interest has been located by the
25// caller, the caller might then request the MsRunReaderSPtr to use to read that
26// MS run's data.
28{
29 public:
30 MsFileAccessor(const QString &file_name, const QString &xml_prefix);
31 MsFileAccessor(const MsFileAccessor &other);
32 virtual ~MsFileAccessor();
33
34 const QString &getFileName() const;
35
36 /** @brief get the raw format of mz data
37 */
38 MsDataFormat getFileFormat() const;
39
40
41 /** @brief get OboPsiModTerm corresponding to the raw format of mz data
42 */
43 const OboPsiModTerm getOboPsiModTermFileFormat() const;
44
45
46 /** @brief get OboPsiModTerm corresponding to the nativeID format format of mz
47 * data
48 */
49 const OboPsiModTerm &getOboPsiModTermNativeIDFormat() const;
50
51
52 /** @brief get the file reader type
53 */
54 FileReaderType getFileReaderType() const;
55
56 /** @brief given an mz format, explicitly set the preferred reader
57 */
58 void setPreferredFileReaderType(MsDataFormat format,
59 FileReaderType reader_type);
60 FileReaderType getpreferredFileReaderType(MsDataFormat format);
61
62 std::vector<MsRunIdCstSPtr> getMsRunIds();
63
64 void setSelectedMsRunIdIndex(std::size_t index);
65 std::size_t getSelectedMsRunIdIndex() const;
66 MsRunIdCstSPtr getSelectedMsRunId();
67
68 MsRunReaderSPtr msRunReaderSPtr(MsRunIdCstSPtr ms_run_id);
69 MsRunReaderSPtr msRunReaderSPtr(std::size_t ms_run_id_index);
70 MsRunReaderSPtr msRunReaderSPtrForSelectedMsRunIdIndex();
71
72 /** @brief get an msrun reader by finding the run_id in file
73 *
74 * @param run_id identifier within file of the MSrun
75 * @param xml_id XML identifier given by the user to identify this MSrun in
76 * our experiment (not in the file)
77 */
78 MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id,
79 const QString &xml_id);
80
81 /** @brief get an MsRunReader directly from a valid MsRun ID
82 *
83 * no need to check the file format or filename : all is already part of the
84 * msrunid
85 *
86 * @param ms_run_id msrun identifier
87 * @return msrun reader shared pointer
88 */
89 static MsRunReaderSPtr buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id);
90
91 /** @brief get an MsRunReader directly from a valid MsRun ID
92 *
93 * no need to check the file format or filename : all is already part of the
94 * msrunid
95 *
96 * @param ms_run_id msrun identifier
97 * @param preferred_file_reader_type the preferred file reader type to use
98 * (depending on the mz format)
99 * @return msrun reader shared pointer
100 */
101 static MsRunReaderSPtr
102 buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id,
103 pappso::FileReaderType preferred_file_reader_type);
104
105 /** @brief if possible, builds directly a dedicated Tims TOF tdf file reader
106 */
107 TimsMsRunReaderMs2SPtr buildTimsMsRunReaderMs2SPtr();
108
109 private:
110 QString m_fileName;
111
112 // When opening more than one file concurrently in a determinate session, we
113 // need this prefix to craft unabiguous ms run ids.
114 const QString m_xmlPrefix;
115
116 MsDataFormat m_fileFormat = MsDataFormat::unknown;
117
118 // Type of the file reader that could load the file.
120
121 std::map<MsDataFormat, FileReaderType> m_preferredFileReaderTypeMap;
122
124
126};
127
128typedef std::shared_ptr<MsFileAccessor> MsFileAccessorSPtr;
129typedef std::shared_ptr<const MsFileAccessor> MsFileAccessorCstSPtr;
130
131} // namespace pappso
std::map< MsDataFormat, FileReaderType > m_preferredFileReaderTypeMap
std::size_t m_selectedMsRunIdIndex
OboPsiModTerm m_oboPsiModTermNativeIDFormat
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:56
MsDataFormat
Definition types.h:120
std::shared_ptr< TimsMsRunReaderMs2 > TimsMsRunReaderMs2SPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
std::shared_ptr< const MsFileAccessor > MsFileAccessorCstSPtr
FileReaderType
Definition types.h:146
std::shared_ptr< MsFileAccessor > MsFileAccessorSPtr