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