| 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 |
|
|
/////////////////////// Local includes |
| 35 |
|
|
#include "MsXpS/libXpertMassCore/CleavageConfig.hpp" |
| 36 |
|
|
|
| 37 |
|
|
namespace MsXpS |
| 38 |
|
|
{ |
| 39 |
|
|
namespace libXpertMassCore |
| 40 |
|
|
{ |
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
/*! |
| 44 |
|
|
\class MsXpS::libXpertMassCore::CleavageConfig |
| 45 |
|
|
\inmodule libXpertMassCore |
| 46 |
|
|
\ingroup PolChemDefAqueousChemicalReactions |
| 47 |
|
|
\inheaderfile CleavageConfig.hpp |
| 48 |
|
|
|
| 49 |
|
|
\brief The CleavageConfig class derives from CleavageAgent to provide a model |
| 50 |
|
|
for specifying aqueous cleavage specifications (patterns) of \l{Polymer} |
| 51 |
|
|
\l{Sequence}s along with instructions on the way the cleavage must occur. |
| 52 |
|
|
|
| 53 |
|
|
Cleavage agent specifications determine the specificity of cleavage in a polymer |
| 54 |
|
|
sequence using a simple syntax. For example, Trypsin is able to cleave after |
| 55 |
|
|
lysyl and arginyl residues. Its cleavage pattern is thus "Lys/;Arg/". However, |
| 56 |
|
|
it is known that Trypsin fails to cleave after Lys if that monomer is followed |
| 57 |
|
|
by a Prolyl residue, thus the complete cleavage agent pattern specification for |
| 58 |
|
|
Trypsin is the following: "Lys/;Arg/;-Lys/Pro". |
| 59 |
|
|
|
| 60 |
|
|
A cleavage agent specification might not be enough information to determine the |
| 61 |
|
|
manner in which a polymer is cleaved. Cleavage rules might be required to refine |
| 62 |
|
|
the specification. A cleavage agent specification might hold as many cleavage |
| 63 |
|
|
rules as required. |
| 64 |
|
|
|
| 65 |
|
|
\sa CleavageMotif, CleavageRule |
| 66 |
|
|
*/ |
| 67 |
|
|
|
| 68 |
|
|
|
| 69 |
|
|
/*! |
| 70 |
|
|
\variable MsXpS::libXpertMassCore::CleavageConfig::m_partials |
| 71 |
|
|
|
| 72 |
|
|
\brief The partial cleavages accepted. |
| 73 |
|
|
*/ |
| 74 |
|
|
|
| 75 |
|
|
/*! |
| 76 |
|
|
\variable MsXpS::libXpertMassCore::CleavageConfig::m_startIonizeLevel |
| 77 |
|
|
|
| 78 |
|
|
\brief The first ionization level of the range. |
| 79 |
|
|
*/ |
| 80 |
|
|
|
| 81 |
|
|
/*! |
| 82 |
|
|
\variable MsXpS::libXpertMassCore::CleavageConfig::m_stopIonizeLevel |
| 83 |
|
|
|
| 84 |
|
|
\brief The last ionization level of the range. |
| 85 |
|
|
*/ |
| 86 |
|
|
|
| 87 |
|
|
|
| 88 |
|
|
/*! |
| 89 |
|
|
\variable MsXpS::libXpertMassCore::CleavageConfig::m_sequenceEmbedded |
| 90 |
|
|
|
| 91 |
|
|
\brief Tells if the sequence of the obtained Oligomer instance need to embed |
| 92 |
|
|
their sequence. |
| 93 |
|
|
*/ |
| 94 |
|
|
|
| 95 |
|
|
|
| 96 |
|
|
/*! |
| 97 |
|
|
\brief Constructs an empty CleavageConfig instance. |
| 98 |
|
|
*/ |
| 99 |
|
2 |
CleavageConfig::CleavageConfig(QObject *parent): CleavageAgent(parent) |
| 100 |
|
|
{ |
| 101 |
|
2 |
} |
| 102 |
|
|
|
| 103 |
|
|
/*! |
| 104 |
|
|
\brief Constructs a CleavageConfig instance using a full set of parameters. |
| 105 |
|
|
|
| 106 |
|
|
\list |
| 107 |
|
|
\a pol_chem_def_csp: the polymer chemistry definition. |
| 108 |
|
|
|
| 109 |
|
|
\a name: the name of CleavageAgent; |
| 110 |
|
|
|
| 111 |
|
|
\a pattern: the cleavage pattern of the CleavageAgent; |
| 112 |
|
|
|
| 113 |
|
|
\a partials: the partial cleavages; |
| 114 |
|
|
|
| 115 |
|
|
\a is_sequence_embedded: indicates if the Oligomer sequence needs to be stored. |
| 116 |
|
|
\endlist |
| 117 |
|
|
*/ |
| 118 |
|
24 |
CleavageConfig::CleavageConfig(PolChemDefCstSPtr pol_chem_def_csp, |
| 119 |
|
|
const QString &name, |
| 120 |
|
|
const QString &pattern, |
| 121 |
|
|
int partials, |
| 122 |
|
|
bool is_sequence_embedded, |
| 123 |
|
24 |
QObject *parent) |
| 124 |
|
|
: CleavageAgent(pol_chem_def_csp, name, pattern, parent), |
| 125 |
|
24 |
m_partials(partials), |
| 126 |
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
24 |
m_sequenceEmbedded(is_sequence_embedded) |
| 127 |
|
|
{ |
| 128 |
|
24 |
} |
| 129 |
|
|
|
| 130 |
|
|
/*! |
| 131 |
|
|
\brief Constructs a CleavageConfig instance starting using a limited set of |
| 132 |
|
|
parameters. |
| 133 |
|
|
|
| 134 |
|
|
\list |
| 135 |
|
|
\a cleavage_agent: CleavageAgent to be used to initialize the base class. |
| 136 |
|
|
|
| 137 |
|
|
\a partials: the partial cleavages; |
| 138 |
|
|
|
| 139 |
|
|
\a is_sequence_embedded: indicates if the Oligomer sequence needs to be stored. |
| 140 |
|
|
\endlist |
| 141 |
|
|
*/ |
| 142 |
|
2 |
CleavageConfig::CleavageConfig(const CleavageAgent &cleavage_agent, |
| 143 |
|
|
int partials, |
| 144 |
|
|
bool is_sequence_embedded, |
| 145 |
|
2 |
QObject *parent) |
| 146 |
|
|
: CleavageAgent(cleavage_agent, parent), |
| 147 |
|
2 |
m_partials(partials), |
| 148 |
|
2 |
m_sequenceEmbedded(is_sequence_embedded) |
| 149 |
|
|
{ |
| 150 |
|
2 |
} |
| 151 |
|
|
|
| 152 |
|
|
/*! |
| 153 |
|
|
\brief Constructs a CleavageConfig instance as a copy of \a other |
| 154 |
|
|
*/ |
| 155 |
|
22 |
CleavageConfig::CleavageConfig(const CleavageConfig &other, QObject *parent) |
| 156 |
|
|
: CleavageAgent(other, parent), |
| 157 |
|
22 |
m_partials(other.m_partials), |
| 158 |
|
22 |
m_startIonizeLevel(other.m_startIonizeLevel), |
| 159 |
|
22 |
m_stopIonizeLevel(other.m_stopIonizeLevel), |
| 160 |
|
22 |
m_sequenceEmbedded(other.m_sequenceEmbedded) |
| 161 |
|
|
{ |
| 162 |
|
22 |
} |
| 163 |
|
|
|
| 164 |
|
|
/*! |
| 165 |
|
|
\brief Destructs this CleavageConfig instance. |
| 166 |
|
|
*/ |
| 167 |
|
100 |
CleavageConfig::~CleavageConfig() |
| 168 |
|
|
{ |
| 169 |
|
100 |
} |
| 170 |
|
|
|
| 171 |
|
|
/*! |
| 172 |
|
|
\brief Initializes this CleavageConfig instance using \a other. |
| 173 |
|
|
|
| 174 |
|
|
If no initialization error occurred, return true, false otherwise. |
| 175 |
|
|
*/ |
| 176 |
|
|
bool |
| 177 |
|
1 |
CleavageConfig::initialize(const CleavageConfig &other) |
| 178 |
|
|
{ |
| 179 |
|
|
// That call fatal-fails, no need to check bool return value. |
| 180 |
|
1 |
bool ok = CleavageAgent::initialize(other); |
| 181 |
|
|
|
| 182 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 |
if(!ok) |
| 183 |
|
✗ |
qCritical() << "Failed to initalize the CleavageConfig instance."; |
| 184 |
|
|
|
| 185 |
|
1 |
m_partials = other.m_partials; |
| 186 |
|
1 |
m_startIonizeLevel = other.m_startIonizeLevel; |
| 187 |
|
1 |
m_stopIonizeLevel = other.m_stopIonizeLevel; |
| 188 |
|
1 |
m_sequenceEmbedded = other.m_sequenceEmbedded; |
| 189 |
|
|
|
| 190 |
|
1 |
return ok; |
| 191 |
|
|
} |
| 192 |
|
|
|
| 193 |
|
|
/*! |
| 194 |
|
|
\brief Sets this instance's CleavageAgent base class to \a cleavage_agent. |
| 195 |
|
|
|
| 196 |
|
|
Returns true the CleavageAgent initialization succeeded, false otherwise. |
| 197 |
|
|
*/ |
| 198 |
|
|
bool |
| 199 |
|
1 |
CleavageConfig::setCleavageAgent(const CleavageAgent &cleavage_agent) |
| 200 |
|
|
{ |
| 201 |
|
1 |
bool ok = CleavageAgent::initialize(cleavage_agent); |
| 202 |
|
|
|
| 203 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 |
if(!ok) |
| 204 |
|
✗ |
qCritical() << "Failed to initalize the CleavageConfig instance."; |
| 205 |
|
|
|
| 206 |
|
1 |
return ok; |
| 207 |
|
|
} |
| 208 |
|
|
|
| 209 |
|
|
/*! |
| 210 |
|
|
\brief Set the partial cleavages to \a value. |
| 211 |
|
|
*/ |
| 212 |
|
|
void |
| 213 |
|
7 |
CleavageConfig::setPartials(int value) |
| 214 |
|
|
{ |
| 215 |
|
7 |
Q_ASSERT(value >= 0); |
| 216 |
|
|
|
| 217 |
|
7 |
m_partials = value; |
| 218 |
|
7 |
} |
| 219 |
|
|
|
| 220 |
|
|
/*! |
| 221 |
|
|
\brief Returns the partial cleavages. |
| 222 |
|
|
*/ |
| 223 |
|
|
int |
| 224 |
|
40 |
CleavageConfig::getPartials() const |
| 225 |
|
|
{ |
| 226 |
|
40 |
return m_partials; |
| 227 |
|
|
} |
| 228 |
|
|
|
| 229 |
|
|
/*! |
| 230 |
|
|
\brief Sets the ionization start level to \a value. |
| 231 |
|
|
*/ |
| 232 |
|
|
void |
| 233 |
|
8 |
CleavageConfig::setStartIonizeLevel(int value) |
| 234 |
|
|
{ |
| 235 |
|
8 |
int local = (value < 0) ? abs(value) : value; |
| 236 |
|
|
|
| 237 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 |
if(local <= m_stopIonizeLevel) |
| 238 |
|
|
{ |
| 239 |
|
8 |
m_startIonizeLevel = local; |
| 240 |
|
|
} |
| 241 |
|
|
else |
| 242 |
|
|
{ |
| 243 |
|
✗ |
m_startIonizeLevel = m_stopIonizeLevel; |
| 244 |
|
✗ |
m_stopIonizeLevel = local; |
| 245 |
|
|
} |
| 246 |
|
8 |
} |
| 247 |
|
|
|
| 248 |
|
|
/*! |
| 249 |
|
|
\brief Returns the ionization start level. |
| 250 |
|
|
*/ |
| 251 |
|
|
int |
| 252 |
|
439 |
CleavageConfig::getStartIonizeLevel() const |
| 253 |
|
|
{ |
| 254 |
|
439 |
return m_startIonizeLevel; |
| 255 |
|
|
} |
| 256 |
|
|
|
| 257 |
|
|
/*! |
| 258 |
|
|
\brief Sets the ionization stop level to \a value. |
| 259 |
|
|
*/ |
| 260 |
|
|
void |
| 261 |
|
8 |
CleavageConfig::setStopIonizeLevel(int value) |
| 262 |
|
|
{ |
| 263 |
|
8 |
int local = (value < 0) ? abs(value) : value; |
| 264 |
|
|
|
| 265 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 |
if(local > m_startIonizeLevel) |
| 266 |
|
|
{ |
| 267 |
|
8 |
m_stopIonizeLevel = local; |
| 268 |
|
|
} |
| 269 |
|
|
else |
| 270 |
|
|
{ |
| 271 |
|
✗ |
m_startIonizeLevel = m_stopIonizeLevel; |
| 272 |
|
✗ |
m_stopIonizeLevel = local; |
| 273 |
|
|
} |
| 274 |
|
8 |
} |
| 275 |
|
|
|
| 276 |
|
|
/*! |
| 277 |
|
|
\brief Returns the ionization stop level. |
| 278 |
|
|
*/ |
| 279 |
|
|
int |
| 280 |
|
439 |
CleavageConfig::getStopIonizeLevel() const |
| 281 |
|
|
{ |
| 282 |
|
439 |
return m_stopIonizeLevel; |
| 283 |
|
|
} |
| 284 |
|
|
|
| 285 |
|
|
/*! |
| 286 |
|
|
\brief Sets both the ionization start and stop levels to \a value1 and \a |
| 287 |
|
|
value2, respectively. |
| 288 |
|
|
*/ |
| 289 |
|
|
void |
| 290 |
|
19 |
CleavageConfig::setIonizeLevels(int value1, int value2) |
| 291 |
|
|
{ |
| 292 |
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
|
19 |
if(abs(value1) <= abs(value2)) |
| 293 |
|
|
{ |
| 294 |
|
19 |
m_startIonizeLevel = abs(value1); |
| 295 |
|
19 |
m_stopIonizeLevel = abs(value2); |
| 296 |
|
|
} |
| 297 |
|
|
else |
| 298 |
|
|
{ |
| 299 |
|
✗ |
m_startIonizeLevel = abs(value2); |
| 300 |
|
✗ |
m_stopIonizeLevel = abs(value1); |
| 301 |
|
|
} |
| 302 |
|
19 |
} |
| 303 |
|
|
|
| 304 |
|
|
/*! |
| 305 |
|
|
\brief Sets the sequence embedded boolean value to \a is_sequence_embedded. |
| 306 |
|
|
*/ |
| 307 |
|
|
void |
| 308 |
|
18 |
CleavageConfig::setSequenceEmbedded(bool is_sequence_embedded) |
| 309 |
|
|
{ |
| 310 |
|
18 |
m_sequenceEmbedded = is_sequence_embedded; |
| 311 |
|
18 |
} |
| 312 |
|
|
|
| 313 |
|
|
/*! |
| 314 |
|
|
\brief Returns the sequence embedded boolean value. |
| 315 |
|
|
*/ |
| 316 |
|
|
bool |
| 317 |
|
8 |
CleavageConfig::isSequenceEmbedded() const |
| 318 |
|
|
{ |
| 319 |
|
8 |
return m_sequenceEmbedded; |
| 320 |
|
|
} |
| 321 |
|
|
|
| 322 |
|
|
//////////////// OPERATORS ///////////////////// |
| 323 |
|
|
|
| 324 |
|
|
/*! |
| 325 |
|
|
\brief Returns true if this CleavageConfig instance and \a other are identical, false otherwise. |
| 326 |
|
|
\sa operator!=() |
| 327 |
|
|
*/ |
| 328 |
|
|
bool |
| 329 |
|
5 |
CleavageConfig::operator==(const CleavageConfig &other) const |
| 330 |
|
|
{ |
| 331 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 |
if(&other == this) |
| 332 |
|
|
return true; |
| 333 |
|
|
|
| 334 |
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
|
10 |
if(CleavageAgent::operator!=(other) || m_partials != other.m_partials || |
| 335 |
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 |
m_startIonizeLevel != other.m_startIonizeLevel || |
| 336 |
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 |
m_stopIonizeLevel != other.m_stopIonizeLevel || |
| 337 |
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 |
m_sequenceEmbedded != other.m_sequenceEmbedded) |
| 338 |
|
|
return false; |
| 339 |
|
|
|
| 340 |
|
|
return true; |
| 341 |
|
|
} |
| 342 |
|
|
|
| 343 |
|
|
/*! |
| 344 |
|
|
\brief Returns true if this instance and \a other differ, false otherwise. |
| 345 |
|
|
Returns the negative value of opearator==(). |
| 346 |
|
|
\sa operator==() |
| 347 |
|
|
*/ |
| 348 |
|
|
bool |
| 349 |
|
3 |
CleavageConfig::operator!=(const CleavageConfig &other) const |
| 350 |
|
|
{ |
| 351 |
|
3 |
return !operator==(other); |
| 352 |
|
|
} |
| 353 |
|
|
|
| 354 |
|
|
void |
| 355 |
|
✗ |
CleavageConfig::registerJsConstructor(QJSEngine *engine) |
| 356 |
|
|
{ |
| 357 |
|
✗ |
if(!engine) |
| 358 |
|
|
{ |
| 359 |
|
✗ |
qWarning() << "Cannot register CleavageConfig class: engine is null"; |
| 360 |
|
✗ |
return; |
| 361 |
|
|
} |
| 362 |
|
|
|
| 363 |
|
|
// Register the meta object as a constructor |
| 364 |
|
|
|
| 365 |
|
✗ |
QJSValue jsMetaObject = |
| 366 |
|
✗ |
engine->newQMetaObject(&CleavageConfig::staticMetaObject); |
| 367 |
|
✗ |
engine->globalObject().setProperty("CleavageConfig", jsMetaObject); |
| 368 |
|
✗ |
} |
| 369 |
|
|
|
| 370 |
|
|
|
| 371 |
|
|
} // namespace libXpertMassCore |
| 372 |
|
|
} // namespace MsXpS |
| 373 |
|
|
|