libpappsomspp
Library for mass spectrometry
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
29int msRunIdMetaTypeId = qRegisterMetaType<pappso::MsRunId>("pappso::MsRunId");
30
31
32int msRunIdCstSPtrMetaTypeId = qRegisterMetaType<pappso::MsRunIdCstSPtr>("pappso::MsRunIdCstSPtr");
33
34
35namespace pappso
36{
37
41
42
43MsRunId::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
55MsRunId::MsRunId(const QString &file_name, const QString &run_id) : MsRunId(file_name)
56{
57 m_runId = run_id;
58}
59
60
62 : m_fileName(other.m_fileName),
63 m_runId(other.m_runId),
64 m_xmlId(other.m_xmlId),
67{
68}
69
70
74
75
76void
77MsRunId::setSampleName(const QString &name)
78{
79 m_sampleName = name;
80}
81
82
83const QString &
85{
86 return m_sampleName;
87}
88
89
90void
91MsRunId::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
113
114 if(extension.toLower() == "mzxml")
115 {
117 }
118 else if(extension.toLower() == "mgf")
119 {
121 }
122 else if(extension.toLower() == "mzml")
123 {
125 }
126 else if((extension.toLower() == "mzcbor") || (extension.toLower() == "cbor"))
127 {
129 }
130}
131
132void
133MsRunId::setRunId(const QString &run_id)
134{
135 m_runId = run_id;
136}
137
138
139const QString &
141{
142 return m_runId;
143}
144
145
146void
147MsRunId::setXmlId(const QString &xml_id)
148{
149 m_xmlId = xml_id;
150}
151
152
153const QString &
155{
156 return m_xmlId;
157}
158
159
160const QString &
162{
163 return m_fileName;
164}
165
166
167void
172
173
176{
177 return m_mzFormat;
178}
179
180
181bool
182MsRunId::operator==(const MsRunId &other) const
183{
184 if(m_xmlId == other.m_xmlId)
185 return true;
186 return false;
187}
188
189
190MsRunId &
192{
193 m_xmlId = other.m_xmlId;
194 m_fileName = other.m_fileName;
196 m_mzFormat = other.m_mzFormat;
197
198 return *this;
199}
200
201
202QString
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
219bool
221{
222 return !m_fileName.isEmpty() && !m_runId.isEmpty() && !m_xmlId.isEmpty() &&
224}
225
226
227} // namespace pappso
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
Definition msrunid.h:54
QString m_runId
Definition msrunid.h:91
QString m_xmlId
Definition msrunid.h:92
const QString & getFileName() const
Definition msrunid.cpp:161
Enums::MsDataFormat getMsDataFormat() const
Definition msrunid.cpp:175
QString toString() const
Definition msrunid.cpp:203
void setMsDataFormat(Enums::MsDataFormat format)
Definition msrunid.cpp:168
const QString & getXmlId() const
Definition msrunid.cpp:154
virtual ~MsRunId()
Definition msrunid.cpp:71
QString m_sampleName
Definition msrunid.h:93
void setFileName(const QString &file_name)
Definition msrunid.cpp:91
MsRunId & operator=(const MsRunId &other)
Definition msrunid.cpp:191
const QString & getRunId() const
Definition msrunid.cpp:140
const QString & getSampleName() const
Definition msrunid.cpp:84
void setRunId(const QString &run_id)
Definition msrunid.cpp:133
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:147
Enums::MsDataFormat m_mzFormat
Definition msrunid.h:94
QString m_fileName
Definition msrunid.h:90
bool isValid() const
Definition msrunid.cpp:220
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition msrunid.cpp:77
bool operator==(const MsRunId &other) const
Definition msrunid.cpp:182
int msRunIdCstSPtrMetaTypeId
Definition msrunid.cpp:32
int msRunIdMetaTypeId
Definition msrunid.cpp:29
@ unknown
unknown format
Definition types.h:149
@ MGF
Mascot format.
Definition types.h:152
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39