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
33 qRegisterMetaType<pappso::MsRunIdCstSPtr>("pappso::MsRunIdCstSPtr");
34
35
36namespace pappso
37{
38
42
43
44MsRunId::MsRunId(const QString &file_name) : m_fileName(file_name)
45{
46 // by default, the sample name is given by the file name
47 QFileInfo fileinfo(m_fileName);
48 if(fileinfo.fileName() == "analysis.tdf")
49 {
50 m_fileName = fileinfo.absoluteDir().absolutePath();
51 }
52 m_sampleName = QFileInfo(m_fileName).baseName();
53}
54
55
56MsRunId::MsRunId(const QString &file_name, const QString &run_id)
57 : MsRunId(file_name)
58{
59 m_runId = run_id;
60}
61
62
64 : m_fileName(other.m_fileName),
65 m_runId(other.m_runId),
66 m_xmlId(other.m_xmlId),
67 m_sampleName(other.m_sampleName),
68 m_mzFormat(other.m_mzFormat)
69{
70}
71
72
76
77
78void
79MsRunId::setSampleName(const QString &name)
80{
81 m_sampleName = name;
82}
83
84
85const QString &
87{
88 return m_sampleName;
89}
90
91
92void
93MsRunId::setFileName(const QString &file_name)
94{
95 m_fileName = file_name;
96
97 QFileInfo file_info(file_name);
98 QString extension = file_info.suffix();
99
100 if(m_sampleName.isEmpty())
101 {
102 // set sample name by default :
103 m_sampleName = file_info.baseName();
104 }
105
107
108 if(extension.toLower() == "mzxml")
109 {
111 }
112 else if(extension.toLower() == "mgf")
113 {
115 }
116 else if(extension.toLower() == "mzml")
117 {
119 }
120}
121
122void
123MsRunId::setRunId(const QString &run_id)
124{
125 m_runId = run_id;
126}
127
128
129const QString &
131{
132 return m_runId;
133}
134
135
136void
137MsRunId::setXmlId(const QString &xml_id)
138{
139 m_xmlId = xml_id;
140}
141
142
143const QString &
145{
146 return m_xmlId;
147}
148
149
150const QString &
152{
153 return m_fileName;
154}
155
156
157void
159{
160 m_mzFormat = format;
161}
162
163
166{
167 return m_mzFormat;
168}
169
170
171bool
172MsRunId::operator==(const MsRunId &other) const
173{
174 if(m_xmlId == other.m_xmlId)
175 return true;
176 return false;
177}
178
179
180MsRunId &
182{
183 m_xmlId = other.m_xmlId;
184 m_fileName = other.m_fileName;
186 m_mzFormat = other.m_mzFormat;
187
188 return *this;
189}
190
191
192QString
194{
195 QString text = QString(
196 "file name: '%1'\n"
197 "run id: '%2'\n"
198 "xml id: '%3'\n"
199 "sample name: '%4'\n")
200 .arg(m_fileName)
201 .arg(m_runId)
202 .arg(m_xmlId)
203 .arg(m_sampleName);
204
205 return text;
206}
207
208
209bool
211{
212 return !m_fileName.isEmpty() && !m_runId.isEmpty() && !m_xmlId.isEmpty() &&
214}
215
216
217} // 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:151
QString toString() const
Definition msrunid.cpp:193
const QString & getXmlId() const
Definition msrunid.cpp:144
MsDataFormat getMsDataFormat() const
Definition msrunid.cpp:165
virtual ~MsRunId()
Definition msrunid.cpp:73
QString m_sampleName
Definition msrunid.h:93
void setFileName(const QString &file_name)
Definition msrunid.cpp:93
MsRunId & operator=(const MsRunId &other)
Definition msrunid.cpp:181
const QString & getRunId() const
Definition msrunid.cpp:130
const QString & getSampleName() const
Definition msrunid.cpp:86
void setRunId(const QString &run_id)
Definition msrunid.cpp:123
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:137
MsDataFormat m_mzFormat
Definition msrunid.h:94
QString m_fileName
Definition msrunid.h:90
void setMsDataFormat(MsDataFormat format)
Definition msrunid.cpp:158
bool isValid() const
Definition msrunid.cpp:210
void setSampleName(const QString &name)
set a sample name for this MsRunId
Definition msrunid.cpp:79
bool operator==(const MsRunId &other) const
Definition msrunid.cpp:172
int msRunIdCstSPtrMetaTypeId
Definition msrunid.cpp:32
int msRunIdMetaTypeId
Definition msrunid.cpp:29
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
MsDataFormat
Definition types.h:120
@ unknown
unknown format
@ MGF
Mascot format.