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),
65 m_sampleName(other.m_sampleName),
66 m_mzFormat(other.m_mzFormat)
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}
127
128void
129MsRunId::setRunId(const QString &run_id)
130{
131 m_runId = run_id;
132}
133
134
135const QString &
137{
138 return m_runId;
139}
140
141
142void
143MsRunId::setXmlId(const QString &xml_id)
144{
145 m_xmlId = xml_id;
146}
147
148
149const QString &
151{
152 return m_xmlId;
153}
154
155
156const QString &
158{
159 return m_fileName;
160}
161
162
163void
168
169
172{
173 return m_mzFormat;
174}
175
176
177bool
178MsRunId::operator==(const MsRunId &other) const
179{
180 if(m_xmlId == other.m_xmlId)
181 return true;
182 return false;
183}
184
185
186MsRunId &
188{
189 m_xmlId = other.m_xmlId;
190 m_fileName = other.m_fileName;
192 m_mzFormat = other.m_mzFormat;
193
194 return *this;
195}
196
197
198QString
200{
201 QString text = QString(
202 "file name: '%1'\n"
203 "run id: '%2'\n"
204 "xml id: '%3'\n"
205 "sample name: '%4'\n")
206 .arg(m_fileName)
207 .arg(m_runId)
208 .arg(m_xmlId)
209 .arg(m_sampleName);
210
211 return text;
212}
213
214
215bool
217{
218 return !m_fileName.isEmpty() && !m_runId.isEmpty() && !m_xmlId.isEmpty() &&
220}
221
222
223} // 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:157
Enums::MsDataFormat getMsDataFormat() const
Definition msrunid.cpp:171
QString toString() const
Definition msrunid.cpp:199
void setMsDataFormat(Enums::MsDataFormat format)
Definition msrunid.cpp:164
const QString & getXmlId() const
Definition msrunid.cpp:150
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:187
const QString & getRunId() const
Definition msrunid.cpp:136
const QString & getSampleName() const
Definition msrunid.cpp:84
void setRunId(const QString &run_id)
Definition msrunid.cpp:129
void setXmlId(const QString &xml_id)
set an XML unique identifier for this MsRunId
Definition msrunid.cpp:143
Enums::MsDataFormat m_mzFormat
Definition msrunid.h:94
QString m_fileName
Definition msrunid.h:90
bool isValid() const
Definition msrunid.cpp:216
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:178
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