libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
msrunid.cpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
3
*
4
* This file is part of the PAPPSOms++ library.
5
*
6
* PAPPSOms++ is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* PAPPSOms++ is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
18
*
19
* Contributors:
20
* Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
21
*implementation
22
******************************************************************************/
23
24
#include "
msrunid.h
"
25
#include <QFileInfo>
26
#include <QDir>
27
28
29
int
msRunIdMetaTypeId
= qRegisterMetaType<pappso::MsRunId>(
"pappso::MsRunId"
);
30
31
32
int
msRunIdCstSPtrMetaTypeId
= qRegisterMetaType<pappso::MsRunIdCstSPtr>(
"pappso::MsRunIdCstSPtr"
);
33
34
35
namespace
pappso
36
{
37
38
MsRunId::MsRunId
()
39
{
40
}
41
42
43
MsRunId::MsRunId
(
const
QString &file_name) :
m_fileName
(file_name)
44
{
45
// by default, the sample name is given by the file name
46
QFileInfo fileinfo(
m_fileName
);
47
if
(fileinfo.fileName() ==
"analysis.tdf"
)
48
{
49
m_fileName
= fileinfo.absoluteDir().absolutePath();
50
}
51
m_sampleName
= QFileInfo(
m_fileName
).baseName();
52
}
53
54
55
MsRunId::MsRunId
(
const
QString &file_name,
const
QString &run_id) :
MsRunId
(file_name)
56
{
57
m_runId
= run_id;
58
}
59
60
61
MsRunId::MsRunId
(
const
MsRunId
&other)
62
:
m_fileName
(other.
m_fileName
),
63
m_runId
(other.
m_runId
),
64
m_xmlId
(other.
m_xmlId
),
65
m_sampleName
(other.
m_sampleName
),
66
m_mzFormat
(other.
m_mzFormat
)
67
{
68
}
69
70
71
MsRunId::~MsRunId
()
72
{
73
}
74
75
76
void
77
MsRunId::setSampleName
(
const
QString &name)
78
{
79
m_sampleName
= name;
80
}
81
82
83
const
QString &
84
MsRunId::getSampleName
()
const
85
{
86
return
m_sampleName
;
87
}
88
89
90
void
91
MsRunId::setFileName
(
const
QString &file_name)
92
{
93
94
QFileInfo fileinfo(file_name);
95
if
(fileinfo.fileName() ==
"analysis.tdf"
)
96
{
97
m_fileName
= fileinfo.absoluteDir().absolutePath();
98
}
99
else
100
{
101
m_fileName
= file_name;
102
}
103
104
QString extension = fileinfo.suffix();
105
106
if
(
m_sampleName
.isEmpty())
107
{
108
// set sample name by default :
109
m_sampleName
= QFileInfo(
m_fileName
).baseName();
110
}
111
112
m_mzFormat
=
Enums::MsDataFormat::unknown
;
113
114
if
(extension.toLower() ==
"mzxml"
)
115
{
116
m_mzFormat
=
Enums::MsDataFormat::mzXML
;
117
}
118
else
if
(extension.toLower() ==
"mgf"
)
119
{
120
m_mzFormat
=
Enums::MsDataFormat::MGF
;
121
}
122
else
if
(extension.toLower() ==
"mzml"
)
123
{
124
m_mzFormat
=
Enums::MsDataFormat::mzML
;
125
}
126
else
if
((extension.toLower() ==
"mzcbor"
) || (extension.toLower() ==
"cbor"
))
127
{
128
m_mzFormat
=
Enums::MsDataFormat::mzcbor
;
129
}
130
}
131
132
void
133
MsRunId::setRunId
(
const
QString &run_id)
134
{
135
m_runId
= run_id;
136
}
137
138
139
const
QString &
140
MsRunId::getRunId
()
const
141
{
142
return
m_runId
;
143
}
144
145
146
void
147
MsRunId::setXmlId
(
const
QString &xml_id)
148
{
149
m_xmlId
= xml_id;
150
}
151
152
153
const
QString &
154
MsRunId::getXmlId
()
const
155
{
156
return
m_xmlId
;
157
}
158
159
160
const
QString &
161
MsRunId::getFileName
()
const
162
{
163
return
m_fileName
;
164
}
165
166
167
void
168
MsRunId::setMsDataFormat
(
Enums::MsDataFormat
format)
169
{
170
m_mzFormat
= format;
171
}
172
173
174
Enums::MsDataFormat
175
MsRunId::getMsDataFormat
()
const
176
{
177
return
m_mzFormat
;
178
}
179
180
181
bool
182
MsRunId::operator==
(
const
MsRunId
&other)
const
183
{
184
if
(
m_xmlId
== other.
m_xmlId
)
185
return
true
;
186
return
false
;
187
}
188
189
190
MsRunId
&
191
MsRunId::operator=
(
const
MsRunId
&other)
192
{
193
m_xmlId
= other.
m_xmlId
;
194
m_fileName
= other.
m_fileName
;
195
m_sampleName
= other.
m_sampleName
;
196
m_mzFormat
= other.
m_mzFormat
;
197
198
return
*
this
;
199
}
200
201
202
QString
203
MsRunId::toString
()
const
204
{
205
QString text = QString(
206
"file name: '%1'\n"
207
"run id: '%2'\n"
208
"xml id: '%3'\n"
209
"sample name: '%4'\n"
)
210
.arg(
m_fileName
)
211
.arg(
m_runId
)
212
.arg(
m_xmlId
)
213
.arg(
m_sampleName
);
214
215
return
text;
216
}
217
218
219
bool
220
MsRunId::isValid
()
const
221
{
222
return
!
m_fileName
.isEmpty() && !
m_runId
.isEmpty() && !
m_xmlId
.isEmpty() &&
223
m_mzFormat
!=
Enums::MsDataFormat::unknown
;
224
}
225
226
227
}
// namespace pappso
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::m_runId
QString m_runId
Definition
msrunid.h:91
pappso::MsRunId::m_xmlId
QString m_xmlId
Definition
msrunid.h:92
pappso::MsRunId::MsRunId
MsRunId()
Definition
msrunid.cpp:38
pappso::MsRunId::getFileName
const QString & getFileName() const
Definition
msrunid.cpp:161
pappso::MsRunId::getMsDataFormat
Enums::MsDataFormat getMsDataFormat() const
Definition
msrunid.cpp:175
pappso::MsRunId::toString
QString toString() const
Definition
msrunid.cpp:203
pappso::MsRunId::setMsDataFormat
void setMsDataFormat(Enums::MsDataFormat format)
Definition
msrunid.cpp:168
pappso::MsRunId::getXmlId
const QString & getXmlId() const
Definition
msrunid.cpp:154
pappso::MsRunId::~MsRunId
virtual ~MsRunId()
Definition
msrunid.cpp:71
pappso::MsRunId::m_sampleName
QString m_sampleName
Definition
msrunid.h:93
pappso::MsRunId::setFileName
void setFileName(const QString &file_name)
Definition
msrunid.cpp:91
pappso::MsRunId::operator=
MsRunId & operator=(const MsRunId &other)
Definition
msrunid.cpp:191
pappso::MsRunId::getRunId
const QString & getRunId() const
Definition
msrunid.cpp:140
pappso::MsRunId::getSampleName
const QString & getSampleName() const
Definition
msrunid.cpp:84
pappso::MsRunId::setRunId
void setRunId(const QString &run_id)
Definition
msrunid.cpp:133
pappso::MsRunId::setXmlId
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition
msrunid.cpp:147
pappso::MsRunId::m_mzFormat
Enums::MsDataFormat m_mzFormat
Definition
msrunid.h:94
pappso::MsRunId::m_fileName
QString m_fileName
Definition
msrunid.h:90
pappso::MsRunId::isValid
bool isValid() const
Definition
msrunid.cpp:220
pappso::MsRunId::setSampleName
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition
msrunid.cpp:77
pappso::MsRunId::operator==
bool operator==(const MsRunId &other) const
Definition
msrunid.cpp:182
msRunIdCstSPtrMetaTypeId
int msRunIdCstSPtrMetaTypeId
Definition
msrunid.cpp:32
msRunIdMetaTypeId
int msRunIdMetaTypeId
Definition
msrunid.cpp:29
msrunid.h
pappso::Enums::MsDataFormat
MsDataFormat
Definition
types.h:141
pappso::Enums::MsDataFormat::mzXML
@ mzXML
mzXML
Definition
types.h:144
pappso::Enums::MsDataFormat::mzcbor
@ mzcbor
Definition
types.h:160
pappso::Enums::MsDataFormat::mzML
@ mzML
mzML
Definition
types.h:143
pappso::Enums::MsDataFormat::unknown
@ unknown
unknown format
Definition
types.h:142
pappso::Enums::MsDataFormat::MGF
@ MGF
Mascot format.
Definition
types.h:145
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappsomspp
core
msrun
msrunid.cpp
Generated on
for libpappsomspp by
1.17.0