libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
mzcbormsfilereader.cpp
Go to the documentation of this file.
1
#include "
mzcbormsfilereader.h
"
2
3
#include "
pappsomspp/core/processing/uimonitor/uimonitorvoid.h
"
4
#include "
pappsomspp/core/utils.h
"
5
6
#include <QFileInfo>
7
8
namespace
pappso
9
{
10
11
12
MzcborMsFileReader::MzcborMsFileReader
(
const
QString &file_name) :
MsFileReader
{file_name}
13
{
14
m_fileFormat
=
pappso::Enums::MsDataFormat::unknown
;
15
initialize
();
16
}
17
18
19
MzcborMsFileReader::~MzcborMsFileReader
()
20
{
21
}
22
23
24
Enums::MsDataFormat
25
MzcborMsFileReader::getFileFormat
()
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
34
std::size_t
35
pappso::MzcborMsFileReader::initialize
()
36
{
37
38
pappso::UiMonitorVoid
monitor;
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
{
50
m_fileFormat
=
pappso::Enums::MsDataFormat::mzcbor
;
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
{
68
m_fileFormat
=
pappso::Enums::MsDataFormat::mzcbor
;
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
80
std::vector<MsRunIdCstSPtr>
81
MzcborMsFileReader::getMsRunIds
(
const
QString &run_prefix)
82
{
83
std::vector<MsRunIdCstSPtr> ms_run_ids;
84
85
86
if
(
m_fileFormat
==
pappso::Enums::MsDataFormat::mzcbor
)
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().
99
ms_run_id.
setMsDataFormat
(
m_fileFormat
);
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
pappso::MsFileReader::MsFileReader
MsFileReader(const QString &file_name)
Definition
msfilereader.cpp:19
pappso::MsFileReader::m_fileFormat
Enums::MsDataFormat m_fileFormat
Definition
msfilereader.h:17
pappso::MsFileReader::m_fileName
QString m_fileName
Definition
msfilereader.h:16
pappso::MsRunId
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition
msrunid.h:54
pappso::MsRunId::setMsDataFormat
void setMsDataFormat(Enums::MsDataFormat format)
Definition
msrunid.cpp:168
pappso::MsRunId::setXmlId
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition
msrunid.cpp:147
pappso::MsRunId::setSampleName
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition
msrunid.cpp:77
pappso::MzcborMsFileReader::m_mzcborIndexReader
pappso::cbor::mzcbor::MzcborIndexReader m_mzcborIndexReader
Definition
mzcbormsfilereader.h:39
pappso::MzcborMsFileReader::~MzcborMsFileReader
virtual ~MzcborMsFileReader()
Definition
mzcbormsfilereader.cpp:19
pappso::MzcborMsFileReader::getMsRunIds
virtual std::vector< MsRunIdCstSPtr > getMsRunIds(const QString &run_prefix) override
Definition
mzcbormsfilereader.cpp:81
pappso::MzcborMsFileReader::getFileFormat
virtual Enums::MsDataFormat getFileFormat() override
Definition
mzcbormsfilereader.cpp:25
pappso::MzcborMsFileReader::m_mzcborReaderBase
pappso::cbor::mzcbor::MzcborReaderBase m_mzcborReaderBase
Definition
mzcbormsfilereader.h:38
pappso::MzcborMsFileReader::MzcborMsFileReader
MzcborMsFileReader(const QString &file_name)
Definition
mzcbormsfilereader.cpp:12
pappso::MzcborMsFileReader::initialize
virtual std::size_t initialize()
Definition
mzcbormsfilereader.cpp:35
pappso::UiMonitorVoid
Definition
uimonitorvoid.h:42
pappso::Utils::getLexicalOrderedString
static const QString getLexicalOrderedString(unsigned int num)
Definition
utils.cpp:72
mzcbormsfilereader.h
pappso::Enums::MsDataFormat
MsDataFormat
Definition
types.h:141
pappso::Enums::MsDataFormat::mzcbor
@ mzcbor
Definition
types.h:160
pappso::Enums::MsDataFormat::unknown
@ unknown
unknown format
Definition
types.h:142
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
uimonitorvoid.h
utils.h
pappsomspp
core
msfile
mzcbormsfilereader.cpp
Generated on
for libpappsomspp by
1.17.0