libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
peptidenaturalisotope.cpp
Go to the documentation of this file.
1/**
2 * \file pappsomspp/peptide/peptidenaturalisotope.cpp
3 * \date 8/3/2015
4 * \author Olivier Langella
5 * \brief peptide natural isotope model
6 */
7
8/*******************************************************************************
9 * Copyright (c) 2015 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
10 *
11 * This file is part of the PAPPSOms++ library.
12 *
13 * PAPPSOms++ is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * PAPPSOms++ is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with PAPPSOms++. If not, see <http://www.gnu.org/licenses/>.
25 *
26 * Contributors:
27 * Olivier Langella <Olivier.Langella@moulon.inra.fr> - initial API and
28 *implementation
29 ******************************************************************************/
30
33
34#include <cmath>
35#include <QDebug>
36
37using namespace std;
38
39namespace pappso
40{
41
42#define CACHE_ARRAY_SIZE 500
43
45
46uint64_t
47Combinations(unsigned int n, unsigned int k)
48{
49 if(k > n)
50 return 0;
51
52 uint64_t r = 1;
53 if((n < CACHE_ARRAY_SIZE) && (combinations_cache[n][k] != 0))
54 {
55 return combinations_cache[n][k];
56 }
57 for(unsigned int d = 1; d <= k; ++d)
58 {
59 r *= n--;
60 r /= d;
61 }
62 if(n < CACHE_ARRAY_SIZE)
63 {
64 combinations_cache[n][k] = r;
65 }
66 return r;
67}
68
69enum class AtomIsotope
70{
76};
77
79isotopem_ratio(pappso_double abundance, unsigned int total, unsigned int heavy)
80{
81 return (pow(abundance, heavy) * pow((double)1 - abundance, (total - heavy)) *
82 (double)Combinations(total, heavy));
83}
84
93
95isotopem_ratio_cache(Enums::Isotope isotope, unsigned int total, unsigned int heavy)
96{
97 pappso_double abundance = 1;
98 switch(isotope)
99 {
101 abundance = ABUNDANCEH2;
102 if(total < CACHE_ARRAY_SIZE)
103 {
104 if(ratioH2_cache[total][heavy] == 0)
105 {
106 ratioH2_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
107 }
108 return ratioH2_cache[total][heavy];
109 }
110 break;
112 abundance = ABUNDANCEC13;
113 if(total < CACHE_ARRAY_SIZE)
114 {
115 if(ratioC13_cache[total][heavy] == 0)
116 {
117 ratioC13_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
118 }
119 return ratioC13_cache[total][heavy];
120 }
121 break;
123 abundance = ABUNDANCEN15;
124 if(total < CACHE_ARRAY_SIZE)
125 {
126 if(ratioN15_cache[total][heavy] == 0)
127 {
128 ratioN15_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
129 }
130 return ratioN15_cache[total][heavy];
131 }
132 break;
134 abundance = ABUNDANCEO18;
135 if(total < CACHE_ARRAY_SIZE)
136 {
137 if(ratioO18_cache[total][heavy] == 0)
138 {
139 ratioO18_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
140 }
141 return ratioO18_cache[total][heavy];
142 }
143 break;
145 abundance = ABUNDANCEO17;
146 if(total < CACHE_ARRAY_SIZE)
147 {
148 if(ratioO17_cache[total][heavy] == 0)
149 {
150 ratioO17_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
151 }
152 return ratioO17_cache[total][heavy];
153 }
154 break;
156 abundance = ABUNDANCES33;
157 if(total < CACHE_ARRAY_SIZE)
158 {
159 if(ratioS33_cache[total][heavy] == 0)
160 {
161 ratioS33_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
162 }
163 return ratioS33_cache[total][heavy];
164 }
165 break;
167 abundance = ABUNDANCES34;
168 if(total < CACHE_ARRAY_SIZE)
169 {
170 if(ratioS34_cache[total][heavy] == 0)
171 {
172 ratioS34_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
173 }
174 return ratioS34_cache[total][heavy];
175 }
176 break;
178 abundance = ABUNDANCES36;
179 if(total < CACHE_ARRAY_SIZE)
180 {
181 if(ratioS36_cache[total][heavy] == 0)
182 {
183 ratioS36_cache[total][heavy] = isotopem_ratio(abundance, total, heavy);
184 }
185 return ratioS36_cache[total][heavy];
186 }
187 break;
188 default:
189 break;
190 }
191 return isotopem_ratio(abundance, total, heavy);
192}
193
194
196 const std::map<Enums::Isotope, int> &map_isotope)
197 : m_peptide(peptide), m_mapIsotope(map_isotope)
198{
199 //_abundance = ((_number_of_carbon - number_of_C13) * ABUNDANCEC12) +
200 //(number_of_C13 * ABUNDANCEC13); p = pow(0.01, i)*pow(0.99, (c-i))*comb(c,i)
201 // qDebug()<< "pow" << pow(ABUNDANCEC13, number_of_C13)*pow(1-ABUNDANCEC13,
202 // (_number_of_carbon-number_of_C13));
203 // qDebug() <<"conb" << Combinations(_number_of_carbon,number_of_C13);
204
205 // CHNO
206 //_probC13 = pow(ABUNDANCEC13, number_of_C13)*pow((double)1-ABUNDANCEC13,
207 //(_number_of_carbon-number_of_C13))* (double)
208 // Combinations(_number_of_carbon,number_of_C13);
209 // qDebug() <<"_probC13" <<_probC13;
210
211 // number of fixed Oxygen atoms (already labelled, not natural) :
212 int number_of_fixed_oxygen = m_peptide.get()->getNumberOfIsotope(Enums::Isotope::O18) +
213 m_peptide.get()->getNumberOfIsotope(Enums::Isotope::O17);
214 int number_of_fixed_sulfur = m_peptide.get()->getNumberOfIsotope(Enums::Isotope::S33) +
215 m_peptide.get()->getNumberOfIsotope(Enums::Isotope::S34) +
216 m_peptide.get()->getNumberOfIsotope(Enums::Isotope::S36);
217
219 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::C) -
220 m_peptide.get()->getNumberOfIsotope(Enums::Isotope::C13),
223 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::N) -
224 m_peptide.get()->getNumberOfIsotope(Enums::Isotope::N15),
227 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::O) -
228 number_of_fixed_oxygen,
231 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::O) -
232 number_of_fixed_oxygen,
235 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::S) -
236 number_of_fixed_sulfur,
239 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::S) -
240 number_of_fixed_sulfur,
243 m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::S) -
244 number_of_fixed_sulfur,
246
247
248 // qDebug() << "Aa::getMass() begin";
249 m_mass = m_peptide.get()->getMass();
258
259
260 // qDebug() << "Aa::getMass() end " << mass;
261}
262
268
272
273
276{
277
278 return m_mass;
279}
280
281
284{
285
286 return m_ratio *
288 (m_peptide.get()->getNumberOfAtom(Enums::AtomIsotopeSurvey::H) + charge) -
289 m_peptide.get()->getNumberOfIsotope(Enums::Isotope::H2),
291}
292
293
294int
296{
297 return m_peptide.get()->getNumberOfAtom(atom);
298}
299
300int
302{
303 return m_mapIsotope.at(isotope) + m_peptide.get()->getNumberOfIsotope(isotope);
304}
305
306const std::map<Enums::Isotope, int> &
311
312
313bool
315{
316 return m_peptide.get()->isPalindrome();
317}
318
319
320unsigned int
322{
323 return m_peptide.get()->size();
324}
325
326const QString
328{
329 return m_peptide.get()->getSequence();
330}
331
332unsigned int
341} // namespace pappso
virtual const QString getSequence() const override
amino acid sequence without modification
const std::map< Enums::Isotope, int > & getIsotopeMap() const
virtual int getNumberOfIsotope(Enums::Isotope isotope) const override
get the number of isotopes C13, H2, O17, O18, N15, S33, S34, S36 in the molecule
const PeptideInterfaceSp m_peptide
PeptideNaturalIsotope(const PeptideInterfaceSp &peptide, const std::map< Enums::Isotope, int > &map_isotope)
virtual bool isPalindrome() const override
tells if the peptide sequence is a palindrome
virtual unsigned int size() const override
virtual unsigned int getIsotopeNumber() const
pappso_double getIntensityRatio(unsigned int charge) const
virtual int getNumberOfAtom(Enums::AtomIsotopeSurvey atom) const override
get the number of atom C, O, N, H in the molecule
const std::map< Enums::Isotope, int > m_mapIsotope
pappso_double getMass() const override
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso_double isotopem_ratio_cache(Enums::Isotope isotope, unsigned int total, unsigned int heavy)
const pappso_double DIFFS32S33(32.9714589101 - MASSSULFUR)
uint64_t Combinations(unsigned int n, unsigned int k)
const pappso_double DIFFS32S34(33.9678670300 - MASSSULFUR)
pappso_double ratioO17_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double DIFFO16O17(16.99913150 - MASSOXYGEN)
const pappso_double ABUNDANCES36(0.00010999120070394368536836893213148869108408689498901367187500)
std::shared_ptr< const PeptideInterface > PeptideInterfaceSp
pappso_double ratioS34_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double ABUNDANCEN15(0.00364198543205827118818262988497735932469367980957031250000000)
const pappso_double DIFFS32S36(35.9670812000 - MASSSULFUR)
pappso_double ratioC13_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
double pappso_double
A type definition for doubles.
Definition types.h:61
pappso_double isotopem_ratio(pappso_double abundance, unsigned int total, unsigned int heavy)
pappso_double ratioH2_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double ABUNDANCEC13(0.01078805814953308406245469086570665240287780761718750000000000)
const pappso_double ABUNDANCEO17(0.00038099847600609595965615028489992255344986915588378906250000)
const pappso_double ABUNDANCEH2(0.00011570983569203332000374651045149221317842602729797363281250)
pappso_double ratioO18_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double ABUNDANCES34(0.04252059835213182203972337447339668869972229003906250000000000)
pappso_double ratioS36_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double ABUNDANCEO18(0.00205139179443282221315669744399201590567827224731445312500000)
uint64_t combinations_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double DIFFO16O18(17.9991610 - MASSOXYGEN)
const pappso_double ABUNDANCES33(0.00751939844812414937003097747947322204709053039550781250000000)
const pappso_double DIFFN14N15(15.0001088982 - MASSNITROGEN)
pappso_double ratioN15_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
pappso_double ratioS33_cache[CACHE_ARRAY_SIZE][CACHE_ARRAY_SIZE]
const pappso_double DIFFC12C13(1.0033548378)
const pappso_double DIFFH1H2(2.0141017778 - MPROTIUM)
#define CACHE_ARRAY_SIZE