| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/* BEGIN software license |
| 2 |
|
|
* |
| 3 |
|
|
* MsXpertSuite - mass spectrometry software suite |
| 4 |
|
|
* ----------------------------------------------- |
| 5 |
|
|
* Copyright (C) 2009--2020 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 |
|
|
/////////////////////// Qt includes |
| 35 |
|
|
#include <QDebug> |
| 36 |
|
|
|
| 37 |
|
|
|
| 38 |
|
|
/////////////////////// IsoSpec |
| 39 |
|
|
#include <IsoSpec++/isoSpec++.h> |
| 40 |
|
|
#include <IsoSpec++/element_tables.h> |
| 41 |
|
|
|
| 42 |
|
|
|
| 43 |
|
|
/////////////////////// Local includes |
| 44 |
|
|
#include "globals.hpp" |
| 45 |
|
|
#include "PeakCentroid.hpp" |
| 46 |
|
|
#include "IsotopicDataBaseHandler.hpp" |
| 47 |
|
|
|
| 48 |
|
|
|
| 49 |
|
|
namespace MsXpS |
| 50 |
|
|
{ |
| 51 |
|
|
|
| 52 |
|
|
namespace libXpertMass |
| 53 |
|
|
{ |
| 54 |
|
|
|
| 55 |
|
|
/*! |
| 56 |
|
|
\class MsXpS::libXpertMass::IsotopicDataBaseHandler |
| 57 |
|
|
\inmodule libXpertMass |
| 58 |
|
|
\ingroup PolChemDefBuildingdBlocks |
| 59 |
|
|
\inheaderfile IsotopicDataBaseHandler.hpp |
| 60 |
|
|
|
| 61 |
|
|
\brief The IsotopicDataBaseHandler class features basic handling of |
| 62 |
|
|
\l{IsotopicData}. |
| 63 |
|
|
|
| 64 |
|
|
The IsotopicDataBaseHandler class provides the skeleton for derived classes |
| 65 |
|
|
to handle \l{IsotopicData}. |
| 66 |
|
|
|
| 67 |
|
|
There are different isotopic data handlers: |
| 68 |
|
|
|
| 69 |
|
|
\list |
| 70 |
|
|
\li The \l{IsotopicDataLibraryHandler} that handles isotopic data from the |
| 71 |
|
|
IsoSpec element data tables directly from the library's data. These are the |
| 72 |
|
|
reference, pristine \e{unmodified} isotopic data. |
| 73 |
|
|
\li The \l{IsotopicDataUserConfigHandler} that handles isotopic data with the |
| 74 |
|
|
exact same format of those from the IsoSpec element data tables. However, these |
| 75 |
|
|
data correspond to user-modified isotopic data, \e{not} the reference, pristine |
| 76 |
|
|
\e{unmodified} isotopic data. |
| 77 |
|
|
\li The \l{IsotopicDataManualConfigHandler} that handles user-defined data |
| 78 |
|
|
according to an entirely different format. These data are typically used when |
| 79 |
|
|
the user defines new chemical elements that cannot fit in the IsoSpec element |
| 80 |
|
|
data tables format. |
| 81 |
|
|
\endlist |
| 82 |
|
|
|
| 83 |
|
|
\sa IsotopicDataLibraryHandler, IsotopicDataUserConfigHandler, |
| 84 |
|
|
IsotopicDataManualConfigHandler |
| 85 |
|
|
*/ |
| 86 |
|
|
|
| 87 |
|
|
/*! |
| 88 |
|
|
\variable int MsXpS::libXpertMass::IsotopicDataBaseHandler::msp_isotopicData |
| 89 |
|
|
|
| 90 |
|
|
\brief The msp_isotopicData is a pointer to \l{IsotopicData}. |
| 91 |
|
|
*/ |
| 92 |
|
|
|
| 93 |
|
|
/*! |
| 94 |
|
|
\variable int MsXpS::libXpertMass::IsotopicDataBaseHandler::m_fileName |
| 95 |
|
|
|
| 96 |
|
|
\brief The m_fileName is the filename in which to store the \l{IsotopicData} |
| 97 |
|
|
for from with to load the \l{IsotopicData}. |
| 98 |
|
|
*/ |
| 99 |
|
|
|
| 100 |
|
|
/*! |
| 101 |
|
|
\brief Constructs the \l{IsotopicDataBaseHandler} with \a file_name. |
| 102 |
|
|
|
| 103 |
|
|
The msp_isotopicData is initialized by creating an empty IsotopicData |
| 104 |
|
|
instance. |
| 105 |
|
|
*/ |
| 106 |
|
74 |
IsotopicDataBaseHandler::IsotopicDataBaseHandler(const QString &file_name) |
| 107 |
|
74 |
: m_fileName(file_name) |
| 108 |
|
|
{ |
| 109 |
|
|
// We cannot allow to have a nullptr msp_isotopicData member. |
| 110 |
1/2
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
|
74 |
msp_isotopicData = std::make_shared<IsotopicData>(); |
| 111 |
|
74 |
} |
| 112 |
|
|
|
| 113 |
|
|
/*! |
| 114 |
|
|
\brief Constructs the \l{IsotopicDataBaseHandler}. |
| 115 |
|
|
|
| 116 |
|
|
\a isotopic_data_sp Isotopic data |
| 117 |
|
|
|
| 118 |
|
|
\a file_name File name |
| 119 |
|
|
*/ |
| 120 |
|
396 |
IsotopicDataBaseHandler::IsotopicDataBaseHandler( |
| 121 |
|
396 |
IsotopicDataSPtr isotopic_data_sp, const QString &file_name) |
| 122 |
|
396 |
: msp_isotopicData(isotopic_data_sp), m_fileName(file_name) |
| 123 |
|
|
{ |
| 124 |
|
|
// We cannot allow to have a nullptr msp_isotopicData member. |
| 125 |
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 396 times.
|
396 |
if(msp_isotopicData == nullptr) |
| 126 |
|
✗ |
msp_isotopicData = std::make_shared<IsotopicData>(); |
| 127 |
|
396 |
} |
| 128 |
|
|
|
| 129 |
|
|
/*! |
| 130 |
|
|
\brief Destructs the \l{IsotopicDataBaseHandler}. |
| 131 |
|
|
*/ |
| 132 |
|
964 |
IsotopicDataBaseHandler::~IsotopicDataBaseHandler() |
| 133 |
|
|
{ |
| 134 |
|
|
// qDebug(); |
| 135 |
|
964 |
} |
| 136 |
|
|
|
| 137 |
|
|
|
| 138 |
|
|
std::size_t |
| 139 |
|
✗ |
IsotopicDataBaseHandler::loadData([[maybe_unused]] const QString &file_name) |
| 140 |
|
|
{ |
| 141 |
|
✗ |
qDebug() << "The base class does not load data."; |
| 142 |
|
✗ |
return 0; |
| 143 |
|
|
} |
| 144 |
|
|
|
| 145 |
|
|
std::size_t |
| 146 |
|
✗ |
IsotopicDataBaseHandler::writeData([[maybe_unused]] const QString &file_name) |
| 147 |
|
|
{ |
| 148 |
|
✗ |
qDebug() << "The base class does not write data."; |
| 149 |
|
✗ |
return 0; |
| 150 |
|
|
} |
| 151 |
|
|
|
| 152 |
|
|
/*! |
| 153 |
|
|
\brief Sets the IsotopicData to \a isotopic_data_sp. |
| 154 |
|
|
*/ |
| 155 |
|
|
void |
| 156 |
|
✗ |
IsotopicDataBaseHandler::setIsotopicData(IsotopicDataSPtr isotopic_data_sp) |
| 157 |
|
|
{ |
| 158 |
|
✗ |
msp_isotopicData = isotopic_data_sp; |
| 159 |
|
✗ |
} |
| 160 |
|
|
|
| 161 |
|
|
/*! |
| 162 |
|
|
\brief Returns the IsotopicData |
| 163 |
|
|
*/ |
| 164 |
|
|
IsotopicDataSPtr |
| 165 |
|
136 |
IsotopicDataBaseHandler::getIsotopicData() |
| 166 |
|
|
{ |
| 167 |
|
136 |
return msp_isotopicData; |
| 168 |
|
|
} |
| 169 |
|
|
|
| 170 |
|
|
/*! |
| 171 |
|
|
\brief Sets the file name to \a file_name |
| 172 |
|
|
*/ |
| 173 |
|
|
void |
| 174 |
|
✗ |
IsotopicDataBaseHandler::setFileName(const QString &file_name) |
| 175 |
|
|
{ |
| 176 |
|
✗ |
m_fileName = file_name; |
| 177 |
|
✗ |
} |
| 178 |
|
|
|
| 179 |
|
|
/*! |
| 180 |
|
|
\brief Returns the file name |
| 181 |
|
|
*/ |
| 182 |
|
|
QString |
| 183 |
|
✗ |
IsotopicDataBaseHandler::getFileName() |
| 184 |
|
|
{ |
| 185 |
|
✗ |
return m_fileName; |
| 186 |
|
|
} |
| 187 |
|
|
|
| 188 |
|
|
|
| 189 |
|
|
std::size_t |
| 190 |
|
✗ |
IsotopicDataBaseHandler::checkConsistency() |
| 191 |
|
|
{ |
| 192 |
|
✗ |
qDebug() << "The base class does not check consistenty."; |
| 193 |
|
✗ |
return 0; |
| 194 |
|
|
} |
| 195 |
|
|
|
| 196 |
|
|
} // namespace libXpertMass |
| 197 |
|
|
|
| 198 |
|
|
} // namespace MsXpS |
| 199 |
|
|
|
| 200 |
|
|
|
| 201 |
|
|
#if 0 |
| 202 |
|
|
|
| 203 |
|
|
Example from IsoSpec. |
| 204 |
|
|
|
| 205 |
|
|
For water H2O |
| 206 |
|
|
|
| 207 |
|
|
const int elementNumber = 2; |
| 208 |
|
|
const int isotopeNumbers[2] = {2,3}; |
| 209 |
|
|
|
| 210 |
|
|
const int atomCounts[2] = {2,1}; |
| 211 |
|
|
|
| 212 |
|
|
|
| 213 |
|
|
const double hydrogen_masses[2] = {1.00782503207, 2.0141017778}; |
| 214 |
|
|
const double oxygen_masses[3] = {15.99491461956, 16.99913170, 17.9991610}; |
| 215 |
|
|
|
| 216 |
|
|
const double* isotope_masses[2] = {hydrogen_masses, oxygen_masses}; |
| 217 |
|
|
|
| 218 |
|
|
const double hydrogen_probs[2] = {0.5, 0.5}; |
| 219 |
|
|
const double oxygen_probs[3] = {0.5, 0.3, 0.2}; |
| 220 |
|
|
|
| 221 |
|
|
const double* probs[2] = {hydrogen_probs, oxygen_probs}; |
| 222 |
|
|
|
| 223 |
|
|
IsoLayeredGenerator iso(Iso(elementNumber, isotopeNumbers, atomCounts, |
| 224 |
|
|
isotope_masses, probs), 0.99); |
| 225 |
|
|
|
| 226 |
|
|
#endif |
| 227 |
|
|
|