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