libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
mzcbormsfilereader.cpp
Go to the documentation of this file.
2
5
6#include <QFileInfo>
7
8namespace pappso
9{
10
11
17
18
22
23
26{
27 // std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << " () "
28 // << std::setprecision(15) << "m_fileFormat: " << (int)m_fileFormat
29 // << std::endl;
30
31 return m_fileFormat;
32}
33
34std::size_t
36{
37
39 QString str_index_file = m_fileName;
40 QFileInfo mzcbor_index_fileinfo(str_index_file.append(".idx"));
41 if(mzcbor_index_fileinfo.exists())
42 {
43 qDebug() << "mzcbor_index_fileinfo.exists()";
44 QFile mzcbor_index_file(mzcbor_index_fileinfo.absoluteFilePath());
45 mzcbor_index_file.open(QIODevice::ReadOnly);
46
47 m_mzcborIndexReader.readCbor(&mzcbor_index_file);
48 if(m_mzcborIndexReader.isMzcborIndex())
49 {
51 }
52 m_mzcborIndexReader.close();
53 mzcbor_index_file.close();
54
55 qDebug() << m_mzcborIndexReader.getRunIdList().size();
56
57 return m_mzcborIndexReader.getRunIdList().size();
58 }
59 else
60 {
61 qDebug();
62 QFile mzcbor_file(m_fileName);
63 mzcbor_file.open(QIODevice::ReadOnly);
64
65 m_mzcborReaderBase.readCbor(&mzcbor_file, monitor);
66 if(m_mzcborReaderBase.isMzcbor())
67 {
69 }
70 m_mzcborReaderBase.close();
71 mzcbor_file.close();
72
73 qDebug() << m_mzcborReaderBase.getMsrunIdList().join(" ");
74
75 return m_mzcborReaderBase.getMsrunIdList().size();
76 }
77}
78
79
80std::vector<MsRunIdCstSPtr>
81MzcborMsFileReader::getMsRunIds(const QString &run_prefix)
82{
83 std::vector<MsRunIdCstSPtr> ms_run_ids;
84
85
87 {
88
89 if(m_mzcborIndexReader.getRunIdList().size() > 0)
90 {
91 qDebug();
92 std::size_t iter = 0;
93 for(auto &msrun_id_str : m_mzcborIndexReader.getRunIdList())
94 {
95 MsRunId ms_run_id(m_fileName, msrun_id_str);
96
97
98 // Set the MS data format as determined in initialize().
100
101 // We need to set the unambiguous xmlId string.
102 ms_run_id.setXmlId(
103 QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(iter)));
104
105 // Now set the sample name to the run id : we can not do that, this is not the use
106 // sample name ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
107
108 // And if it is possible, the real sample name because this one is for the
109 // end user to recognize his sample:
110 ms_run_id.setSampleName(msrun_id_str);
111
112
113 ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
114 iter++;
115 }
116 }
117 else
118 {
119
120 std::size_t iter = 0;
121 for(auto &msrun_id_str : m_mzcborReaderBase.getMsrunIdList())
122 {
123 MsRunId ms_run_id(m_fileName, msrun_id_str);
124
125
126 // Set the MS data format as determined in initialize().
127 ms_run_id.setMsDataFormat(m_fileFormat);
128
129 // We need to set the unambiguous xmlId string.
130 ms_run_id.setXmlId(
131 QString("%1%2").arg(run_prefix).arg(Utils::getLexicalOrderedString(iter)));
132
133 // Now set the sample name to the run id : we can not do that, this is not the use
134 // sample name ms_run_id.setSampleName(QString::fromStdString(ms_data_ptr->run.id));
135
136 // And if it is possible, the real sample name because this one is for the
137 // end user to recognize his sample:
138 ms_run_id.setSampleName(msrun_id_str);
139
140
141 ms_run_ids.push_back(std::make_shared<MsRunId>(ms_run_id));
142 iter++;
143 }
144 }
145 }
146
147 return ms_run_ids;
148}
149} // namespace pappso
MsFileReader(const QString &file_name)
Enums::MsDataFormat m_fileFormat
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition msrunid.h:54
void setMsDataFormat(Enums::MsDataFormat format)
Definition msrunid.cpp:168
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:147
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition msrunid.cpp:77
pappso::cbor::mzcbor::MzcborIndexReader m_mzcborIndexReader
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
virtual Enums::MsDataFormat getFileFormat() override
pappso::cbor::mzcbor::MzcborReaderBase m_mzcborReaderBase
MzcborMsFileReader(const QString &file_name)
virtual std::size_t initialize()
static const QString getLexicalOrderedString(unsigned int num)
Definition utils.cpp:72
@ unknown
unknown format
Definition types.h:149
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39