GCC Code Coverage Report


./
File: src/XpertMass/includes/libXpertMass/PolChemDef.hpp
Date: 2024-08-24 11:26:06
Lines:
2/2
100.0%
Functions:
2/2
100.0%
Branches:
6/20
30.0%

Line Branch Exec Source
1 /* BEGIN software license
2 *
3 * MsXpertSuite - mass spectrometry software suite
4 * -----------------------------------------------
5 * Copyright(C) 2009,...,2018 Filippo Rusconi
6 *
7 * http://www.msxpertsuite.org
8 *
9 * This file is part of the MsXpertSuite project.
10 *
11 * The MsXpertSuite project is the successor of the massXpert project. This
12 * project now includes various independent modules:
13 *
14 * - massXpert, model polymer chemistries and simulate mass spectrometric data;
15 * - mineXpert, a powerful TIC chromatogram/mass spectrum viewer/miner;
16 *
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 *
30 * END software license
31 */
32
33
34 #pragma once
35
36 /////////////////////// Qt includes
37 #include <QString>
38 #include <QList>
39
40
41 /////////////////////// Local includes
42 #include "exportimportconfig.h"
43 #include "Formula.hpp"
44 #include "IsotopicData.hpp"
45 #include "Modif.hpp"
46 #include "CrossLinker.hpp"
47 #include "CleaveSpec.hpp"
48 #include "FragSpec.hpp"
49 #include "IonizeRule.hpp"
50 #include "Polymer.hpp"
51 #include "MonomerSpec.hpp"
52 #include "ModifSpec.hpp"
53 #include "CrossLinkerSpec.hpp"
54 #include "PolChemDefSpec.hpp"
55
56
57 namespace MsXpS
58 {
59
60 namespace libXpertMass
61 {
62
63 extern const int POL_CHEM_DEF_FILE_FORMAT_VERSION;
64
65 class PolChemDef;
66 typedef std::shared_ptr<PolChemDef> PolChemDefSPtr;
67 typedef std::shared_ptr<const PolChemDef> PolChemDefCstSPtr;
68
69
70 //! The PolChemDef class provides a polymer chemistry definition.
71 /*! A polymer chemistry definition allows one to characterize in a
72 fine manner the chemistry of a polymer. That means that it should
73 contain:
74
75 - a list of atoms;
76
77 - a list of monomers;
78
79 - a list of modifications;
80
81 - a list of cross-linkers;
82
83 - a list of cleavage specifications;
84
85 - a list of fragmentation specifications;
86
87 and a number of chemical data, like the left and right cap formulas,
88 the code length(that is the maximum number of characters that might
89 be used to construct a monomer code).
90
91 Because monomers have to be graphically rendered at some point, in
92 the form of monomer vignettes in the sequence editor, the polymer
93 chemistry definition also contains:
94
95 - a list of monomer specifications, which tell the sequence editor
96 what file is to be used to render any monomer in the polymer
97 chemistry definition;
98
99 - a list of modification specifications, which tell the sequence
100 editor what file is to be used to render any chemical
101 modification;
102 */
103 class DECLSPEC PolChemDef
104 {
105
106 public:
107 PolChemDef();
108 PolChemDef(const PolChemDefSpec &);
109
110 virtual ~PolChemDef();
111
112 void setVersion(const QString &);
113 QString version() const;
114
115 void setName(const QString &);
116 QString name() const;
117
118 void setXmlDataFilePath(const QString &file_path);
119 QString getXmlDataFilePath() const;
120 QString getXmlDataDirPath() const;
121
122 void setIsotopicDataFilePath(const QString &file_path);
123 QString getIsotopicDataFilePath() const;
124 QString deduceIsotopicDataFilePath() const;
125
126 void setLeftCap(const Formula &);
127 const Formula &leftCap() const;
128
129 void setRightCap(const Formula &);
130 const Formula &rightCap() const;
131
132 void setCodeLength(int);
133 int codeLength() const;
134
135 bool calculateDelimitedCodes();
136 const QString &delimitedCodes();
137
138 void setIonizeRule(const IonizeRule &);
139 const IonizeRule &ionizeRule() const;
140 IonizeRule *ionizeRulePtr();
141
142 void setIsotopicDataSPtr(IsotopicDataSPtr isotopic_data_sp);
143 IsotopicDataCstSPtr getIsotopicDataCstSPtr() const;
144 IsotopicDataSPtr getIsotopicDataSPtr();
145
146 const QList<Monomer *> &monomerList() const;
147 QList<Monomer *> *monomerListPtr();
148
149 const QList<Modif *> &modifList() const;
150 QList<Modif *> *modifListPtr();
151
152 const QList<CrossLinker *> &crossLinkerList() const;
153 QList<CrossLinker *> *crossLinkerListPtr();
154
155 const QList<CleaveSpec *> &cleaveSpecList() const;
156 QList<CleaveSpec *> *cleaveSpecListPtr();
157
158 const QList<FragSpec *> &fragSpecList() const;
159 QList<FragSpec *> *fragSpecListPtr();
160
161 QList<MonomerSpec *> &monomerSpecList() const;
162 QList<MonomerSpec *> *monomerSpecListPtr();
163
164 QList<ModifSpec *> &modifSpecList() const;
165 QList<ModifSpec *> *modifSpecListPtr();
166 bool referenceModifByName(const QString &, Modif *modif = nullptr) const;
167 bool referenceModifByName(const QString &, Modif &modif) const;
168
169 QList<CrossLinkerSpec *> &crossLinkerSpecList() const;
170 QList<CrossLinkerSpec *> *crossLinkerSpecListPtr();
171
172 bool operator==(const PolChemDef &other) const;
173 bool operator!=(const PolChemDef &other) const;
174
175 bool referenceCrossLinkerByName(const QString &, CrossLinker * = 0) const;
176
177 static std::size_t loadIsotopicData(PolChemDefSPtr pol_chem_def_sp,
178 const QString &file_path = QString());
179
180 static std::size_t writeIsotopicData(PolChemDefSPtr pol_chem_def_sp,
181 const QString &file_path = QString());
182
183 static bool renderXmlPolChemDefFile(PolChemDefSPtr pol_chem_def_sp);
184
185 QString *formatXmlDtd();
186
187 bool writeXmlFile();
188
189 QStringList *differenceBetweenMonomers(double, MassType);
190
191 protected:
192 //! Name.
193 /*! Identifies the polymer definition, like "protein" or "dna", for
194 example.
195 */
196 QString m_name;
197
198 //! File path.
199 /*! Fully qualifies the file which contains the polymer chemistry definition.
200 */
201 QString m_xmlDataFilePath;
202
203 QString m_isotopicDataFilePath;
204
205 //! Left cap formula.
206 /*! Describes how the polymer should be capped on its left end.
207 */
208 Formula m_leftCap;
209
210 //! Right cap formula.
211 /*! Describes how the polymer should be capped on its right end.
212 */
213 Formula m_rightCap;
214
215 //! Code length.
216 /*! Maximum number of characters allowed to construct a monomer
217 code.
218 */
219 int m_codeLength;
220
221 //! Delimited codes string.
222 /*! String made with each code of each monomer separated using '@',
223 like "@Ala@Tyr@Phe@".
224 */
225 QString m_delimitedCodes;
226
227 //! Ionization rule.
228 /*! The ionization rule indicates how the polymer sequence needs be
229 ionized by default.
230 */
231 IonizeRule m_ionizeRule;
232
233 //! Shared pointer to IsotopicData
234 // We will access all the chemical elements data in this class instance.
235 IsotopicDataSPtr msp_isotopicData = nullptr;
236
237 //! List of monomers.
238 QList<Monomer *> m_monomerList;
239
240 //! List of modifications.
241 QList<Modif *> m_modifList;
242
243 //! List of cross-linkers.
244 QList<CrossLinker *> m_crossLinkerList;
245
246 //! List of cleavage specifications.
247 QList<CleaveSpec *> m_cleaveSpecList;
248
249 //! List of fragmentation specifications.
250 QList<FragSpec *> m_fragSpecList;
251
252 //! List of monomer specifications.
253 /*! Each monomer in the polymer chemistry definition has an item in
254 this list indicating where the graphics file is to be found for
255 graphical rendering.
256 */
257 mutable QList<MonomerSpec *> m_monomerSpecList;
258
259 //! List of modification specifications.
260 /*! Each modification in the polymer chemistry definition has an
261 item in this list indicating where the graphics file is to be
262 found for graphical rendering and the graphical mechanism to be
263 used for rendering the modification graphically.
264 */
265 mutable QList<ModifSpec *> m_modifSpecList;
266
267 //! List of cross-link specifications.
268 /*! Each cross-link in the polymer chemistry definition has an item
269 in this list indicating where the graphics file is to be found for
270 graphical rendering.
271 */
272 mutable QList<CrossLinkerSpec *> m_crossLinkerSpecList;
273
274 QList<PolChemDef *> *mp_repositoryList;
275 };
276
277 } // namespace libXpertMass
278
279 } // namespace MsXpS
280
281
282
3/10
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
5 Q_DECLARE_METATYPE(MsXpS::libXpertMass::PolChemDefSPtr);
283 extern int polChemDefSPtrMetaTypeId;
284
285
3/10
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 18 taken 5 times.
✗ Branch 19 not taken.
5 Q_DECLARE_METATYPE(MsXpS::libXpertMass::PolChemDefCstSPtr);
286 extern int polChemDefCstSPtrMetaTypeId;
287