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
14namespace pappso
15{
16
17class TimsMsRunReaderMs2;
18typedef std::shared_ptr<TimsMsRunReaderMs2> TimsMsRunReaderMs2SPtr;
19
21{
22 pwiz,
23 xy,
24 tims,
27};
28
29// This class is used to access mass spectrometry data files. The file being
30// opened and read might contain more than one MS run. The user of this class
31// might request a vector of all these MS runs (in the form of a vector of
32// MsRunIdCstSPtr. Once the MsRunIdCstSPtr of interest has been located by the
33// caller, the caller might then request the MsRunReaderSPtr to use to read that
34// MS run's data.
36{
37 public:
38 MsFileAccessor(const QString &file_name, const QString &xml_prefix);
39 MsFileAccessor(const MsFileAccessor &other);
40 virtual ~MsFileAccessor();
41
42 const QString &getFileName() const;
43
44 /** @brief get the raw format of mz data
45 */
46 MzFormat getFileFormat() const;
47
48 /** @brief get the file reader type
49 */
50 FileReaderType getFileReaderType() const;
51
52 /** @brief given an mz format, explicitly set the prefered reader
53 */
54 void setPreferedFileReaderType(MzFormat format, FileReaderType reader_type);
55
56 std::vector<MsRunIdCstSPtr> getMsRunIds();
57
58 MsRunReaderSPtr msRunReaderSp(MsRunIdCstSPtr ms_run_id);
59
60 /** @brief get an msrun reader by finding the run_id in file
61 *
62 * @param run_id identifier within file of the MSrun
63 * @param xml_id XML identifier given by the user to identify this MSrun in
64 * our experiment (not in the file)
65 */
66 MsRunReaderSPtr getMsRunReaderSPtrByRunId(const QString &run_id,
67 const QString &xml_id);
68
69 /** @brief get an MsRunReader directly from a valid MsRun ID
70 *
71 * no need to check the file format or filename : all is already part of the
72 * msrunid
73 *
74 * @param ms_run_id msrun identifier
75 * @return msrun reader shared pointer
76 */
77 static MsRunReaderSPtr buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id);
78
79 /** @brief get an MsRunReader directly from a valid MsRun ID
80 *
81 * no need to check the file format or filename : all is already part of the
82 * msrunid
83 *
84 * @param ms_run_id msrun identifier
85 * @param prefered_file_reader_type the prefered file reader type to use
86 * (depending on the mz format)
87 * @return msrun reader shared pointer
88 */
89 static MsRunReaderSPtr
90 buildMsRunReaderSPtr(MsRunIdCstSPtr ms_run_id,
91 pappso::FileReaderType prefered_file_reader_type);
92
93 /** @brief if possible, builds directly a dedicated Tims TOF tdf file reader
94 */
95 TimsMsRunReaderMs2SPtr buildTimsMsRunReaderMs2SPtr();
96
97 private:
98 QString m_fileName;
99
100 // When opening more than one file concurrently in a determinate session, we
101 // need this prefix to craft unabiguous ms run ids.
102 const QString m_xmlPrefix;
103
105
106 // Type of the file reader that could load the file.
108
109 std::map<MzFormat, FileReaderType> m_preferedFileReaderTypeMap;
110};
111
112} // 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:185
std::shared_ptr< TimsMsRunReaderMs2 > TimsMsRunReaderMs2SPtr
MzFormat
Definition: types.h:108
@ unknown
unknown format
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition: msrunid.h:45