GCC Code Coverage Report


./
File: src/XpertMass/includes/libXpertMass/Polymer.hpp
Date: 2024-08-24 11:26:06
Lines:
3/3
100.0%
Functions:
3/3
100.0%
Branches:
10/30
33.3%

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 #include <memory>
37
38
39 /////////////////////// Qt includes
40 #include <QString>
41 #include <QObject>
42 #include <QDateTime>
43 #include <QCryptographicHash>
44
45
46 /////////////////////// Local includes
47 #include "exportimportconfig.h"
48 #include "Sequence.hpp"
49 #include "IonizeRule.hpp"
50 #include "Ionizable.hpp"
51 #include "Modif.hpp"
52 #include "CalcOptions.hpp"
53
54
55 namespace MsXpS
56 {
57
58 namespace libXpertMass
59 {
60
61 const int POL_SEQ_FILE_FORMAT_VERSION = 1;
62
63 class PolChemDef;
64 typedef std::shared_ptr<const PolChemDef> PolChemDefCstSPtr;
65
66 class IonizeRule;
67 class Ionizable;
68 class CrossLink;
69 class CrossLinkList;
70
71
72 //! The Polymer class provides a polymer.
73 /*! A polymer is a sequence(Sequence) to which data are
74 aggregated to make it able to perform a number of tasks.
75
76 The polymer has a name and a code, so that it is possible to
77 refer to it in printed material...
78
79 Because Polymer derives from Ionizable, which itself derives from
80 PolChemDefEntity, it holds a pointer to the polymer chemistry
81 definition of the polymer sequence. Without that datum, using the
82 polymer in a complex context would be impossible, as the polymer
83 chemistry definition will provide a huge amount of data required
84 to operate the polymer efficiently. Because Ionizable inherits
85 Ponderable, the polymer has a mono mass and an average mass.
86
87 The polymer also has modifications(left-end and right-end) to
88 characterize it better.
89 */
90 class DECLSPEC Polymer : public QObject, public Sequence, public Ionizable
91 {
92 Q_OBJECT
93
94 public:
95 Polymer(PolChemDefCstSPtr pol_chem_def_csp,
96 const QString &name = QString("NOT_SET"),
97 const QString &code = QString("NOT_SET"),
98 const QString &author = QString("NOT SET"));
99
100 virtual ~Polymer();
101
102 void setCode(const QString &);
103 QString code() const;
104
105 void setAuthor(const QString &);
106 QString author() const;
107
108 void setFilePath(const QString &);
109 QString filePath() const;
110
111 void setDateTime(const QString &);
112 QString dateTime() const;
113
114 bool hasModifiedMonomer(int left_index = -1, int right_index = -1) const;
115
116 bool setLeftEndModif(const QString & = QString());
117 bool setLeftEndModif(const Modif &);
118 const Modif &leftEndModif() const;
119 bool isLeftEndModified() const;
120
121 bool setRightEndModif(const QString & = QString());
122 bool setRightEndModif(const Modif &);
123 const Modif &rightEndModif() const;
124 bool isRightEndModified() const;
125
126 const CrossLinkList &crossLinkList() const;
127 CrossLinkList *crossLinkListPtr();
128 bool crossLinkedMonomerIndexList(int, int, QList<int> *, int *);
129 bool crossLinkList(int, int, QList<CrossLink *> *, int *);
130
131 virtual bool prepareMonomerRemoval(const Monomer *monomer_p) override;
132
133 using Ionizable::operator=;
134 virtual bool removeMonomerAt(int index) override;
135
136 QByteArray md5Sum(int hash_data_specifs) const;
137
138
139 // MASS CALCULATION FUNCTIONS
140 /////////////////////////////
141
142 using Ponderable::accountMasses;
143 bool accountMasses(const CalcOptions &calc_options);
144 static bool accountMasses(Polymer *polymer_p,
145 const CalcOptions &calc_options,
146 double *mono,
147 double *avg);
148
149 using Ionizable::calculateMasses;
150 bool calculateMasses(const CalcOptions &calc_options, bool reset = true);
151 static bool calculateMasses(Polymer *polymer_p,
152 const CalcOptions &calc_options,
153 double *mono,
154 double *avg,
155 bool reset = true);
156
157 bool accountCappingMasses(int, int = 1);
158 static bool accountCappingMasses(Polymer *, int, double *, double *, int = 1);
159
160 bool accountEndModifMasses(int);
161 static bool accountEndModifMasses(Polymer *, int, double *, double *);
162 static bool accountEndModifMasses(Polymer *, int, Ponderable *);
163
164 bool crossLink(CrossLink *);
165 bool uncrossLink(CrossLink *);
166
167 /////////////////////////////
168 // MASS CALCULATION FUNCTIONS
169
170 // ELEMENTAL CALCULATION FUNCTION
171 /////////////////////////////////
172
173 QString elementalComposition(const IonizeRule &,
174 const CoordinateList &,
175 const CalcOptions &);
176
177 /////////////////////////////////
178 // ELEMENTAL CALCULATION FUNCTION
179
180 bool renderXmlCodesElement(const QDomElement &element);
181
182 static QString xmlPolymerFileGetPolChemDefName(const QString &file_path);
183
184 bool renderXmlPolymerFile(QString = QString(""));
185 bool renderXmlPolymerModifElement(const QDomElement &, int);
186 bool renderXmlCrossLinksElement(const QDomElement &, int);
187
188 QString *formatXmlDtd();
189 QString *formatXmlPolSeqElement(int, const QString & = QString(" "));
190 QString *formatXmlCrossLinksElement(int, const QString & = QString(" "));
191
192 bool writeXmlFile();
193
194 using Ionizable::validate;
195 using Sequence::validate;
196 bool validate() override;
197
198 void debugPutStdErr();
199
200 signals:
201 void polymerDestroyedSignal(Polymer *);
202 void crossLinkChangedSignal(Polymer *);
203 void crossLinksPartiallyEncompassedSignal(int) const;
204
205 protected:
206 //! Code.
207 QString m_code;
208
209 //! Name of the last user having last modified the polymer sequence.
210 QString m_author;
211
212 //! File name.
213 QString m_filePath;
214
215 //! Date and time of the last modification.
216 QDateTime m_dateTime;
217
218 //! Left end modification.
219 Modif m_leftEndModif;
220
221 //! Right end modification.
222 Modif m_rightEndModif;
223
224 //! The list of CrossLink instances.
225 CrossLinkList *mpa_crossLinkList;
226 };
227
228 typedef std::shared_ptr<Polymer> PolymerSPtr;
229 typedef std::shared_ptr<const Polymer> PolymerCstSPtr;
230
231
232 } // namespace libXpertMass
233
234 } // namespace MsXpS
235
236
4/10
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
5 Q_DECLARE_METATYPE(MsXpS::libXpertMass::Polymer);
237 extern int polymerMetaTypeId;
238
239
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::PolymerSPtr);
240 extern int polymerSPtrMetaTypeId;
241
242
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::PolymerCstSPtr);
243 extern int polymerCstSPtrMetaTypeId;
244