33 #include "../pappsoexception.h"
40 : msp_peptide(peptide)
44 int number_of_fixed_oxygen =
47 int number_of_fixed_sulfur =
51 int number_of_fixed_nitrogen =
53 int number_of_fixed_hydrogen =
61 std::map<Isotope, int> map_isotope;
62 map_isotope.insert(std::pair<Isotope, int>(
Isotope::C13, 0));
63 map_isotope.insert(std::pair<Isotope, int>(
Isotope::H2, 0));
64 map_isotope.insert(std::pair<Isotope, int>(
Isotope::N15, 0));
65 map_isotope.insert(std::pair<Isotope, int>(
Isotope::O17, 0));
66 map_isotope.insert(std::pair<Isotope, int>(
Isotope::O18, 0));
67 map_isotope.insert(std::pair<Isotope, int>(
Isotope::S33, 0));
68 map_isotope.insert(std::pair<Isotope, int>(
Isotope::S34, 0));
69 map_isotope.insert(std::pair<Isotope, int>(
Isotope::S36, 0));
71 for(
int nbc13 = 0; nbc13 <= total_carbon; nbc13++)
75 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
77 if(pepIsotope.get()->getIntensityRatio(1) < minimum_ratio_to_compute)
82 std::list<PeptideNaturalIsotopeSp> temp_list;
87 number_of_fixed_sulfur);
88 std::list<PeptideNaturalIsotopeSp>::iterator it =
92 map_isotope = it->get()->getIsotopeMap();
93 for(
int nbS34 = 1; nbS34 <= total_sulfur; nbS34++)
97 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
98 temp_list.push_back(pepIsotope);
99 if(pepIsotope.get()->getIntensityRatio(1) < minimum_ratio_to_compute)
109 it, temp_list.begin(), temp_list.end());
118 map_isotope = it->get()->getIsotopeMap();
119 for(
int nbS33 = 1; nbS33 <= (total_sulfur - map_isotope[
Isotope::S34]);
124 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
125 temp_list.push_back(pepIsotopeS33);
126 if(pepIsotopeS33.get()->getIntensityRatio(1) <
127 minimum_ratio_to_compute)
136 it, temp_list.begin(), temp_list.end());
143 map_isotope = it->get()->getIsotopeMap();
144 for(
int nbS36 = 1; nbS36 <= (total_sulfur - map_isotope[
Isotope::S34] -
150 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
151 temp_list.push_back(pepIsotopeS36);
152 if(pepIsotopeS36.get()->getIntensityRatio(1) <
153 minimum_ratio_to_compute)
162 it, temp_list.begin(), temp_list.end());
173 number_of_fixed_hydrogen);
180 map_isotope = it->get()->getIsotopeMap();
181 for(
int nbH2 = 1; nbH2 <= total_hydrogen; nbH2++)
185 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
186 temp_list.push_back(pepIsotope);
187 if(pepIsotope.get()->getIntensityRatio(1) < minimum_ratio_to_compute)
196 it, temp_list.begin(), temp_list.end());
205 unsigned int total_oxygen(
207 number_of_fixed_oxygen);
214 map_isotope = it->get()->getIsotopeMap();
215 for(
unsigned int nbO18 = 1; nbO18 <= total_oxygen; nbO18++)
221 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
222 temp_list.push_back(pepIsotope);
223 if(pepIsotope.get()->getIntensityRatio(1) < minimum_ratio_to_compute)
232 it, temp_list.begin(), temp_list.end());
241 unsigned int total_nitrogen(
243 number_of_fixed_nitrogen);
250 map_isotope = it->get()->getIsotopeMap();
251 for(
unsigned int nbN15 = 1; nbN15 <= total_nitrogen; nbN15++)
257 std::make_shared<PeptideNaturalIsotope>(
msp_peptide, map_isotope);
258 temp_list.push_back(pepIsotope);
259 if(pepIsotope.get()->getIntensityRatio(1) < minimum_ratio_to_compute)
268 it, temp_list.begin(), temp_list.end());
278 return std::make_shared<PeptideNaturalIsotopeList>(*
this);
283 : msp_peptide(other.msp_peptide),
284 msp_peptide_natural_isotope_list(other.msp_peptide_natural_isotope_list)
292 const std::map<unsigned int, pappso_double>
295 std::list<PeptideNaturalIsotopeSp>::const_iterator it =
297 std::map<unsigned int, pappso_double> map_isotope_number;
301 unsigned int number = it->get()->getIsotopeNumber();
302 std::pair<std::map<unsigned int, pappso_double>::iterator,
bool> mapnew =
303 map_isotope_number.insert(
304 std::pair<unsigned int, pappso_double>(number, 0));
305 if(mapnew.second ==
false)
310 mapnew.first->second += it->get()->getIntensityRatio(1);
313 return map_isotope_number;
322 std::vector<PeptideNaturalIsotopeSp>
324 unsigned int charge)
const
326 std::vector<PeptideNaturalIsotopeSp> v_isotope_list;
330 if(isotopeSp.get()->getIsotopeNumber() == isotope_number)
332 v_isotope_list.push_back(isotopeSp);
335 std::sort(v_isotope_list.begin(),
336 v_isotope_list.end(),
339 return (m.get()->getIntensityRatio(charge) >
340 n.get()->getIntensityRatio(charge));
342 return v_isotope_list;
350 std::vector<PeptideNaturalIsotopeAverageSp>
354 unsigned int isotopeNumber,
359 unsigned int askedIsotopeRank;
360 unsigned int maxAskedIsotopeRank = 10;
362 std::vector<PeptideNaturalIsotopeAverageSp> v_isotopeAverageList;
363 std::vector<PeptideNaturalIsotopeAverageSp> v_isotopeAverageListResult;
365 std::vector<unsigned int> previousIsotopeRank;
366 bool isEmpty =
false;
367 for(askedIsotopeRank = 1;
368 (askedIsotopeRank < maxAskedIsotopeRank) && (!isEmpty);
372 peptide, askedIsotopeRank, isotopeNumber, charge, precision);
373 isEmpty = isotopeAverage.
isEmpty();
379 if(std::find(previousIsotopeRank.begin(),
380 previousIsotopeRank.end(),
382 previousIsotopeRank.end())
385 v_isotopeAverageList.push_back(
390 if(v_isotopeAverageList.size() == 0)
391 return v_isotopeAverageListResult;
394 std::sort(v_isotopeAverageList.begin(),
395 v_isotopeAverageList.end(),
398 return (m.get()->getIntensityRatio() >
399 n.get()->getIntensityRatio());
403 auto it = v_isotopeAverageList.begin();
404 v_isotopeAverageListResult.clear();
406 while((it != v_isotopeAverageList.end()) &&
407 (cumulativeRatio < minimumIntensity))
409 cumulativeRatio += it->get()->getIntensityRatio();
410 v_isotopeAverageListResult.push_back(*it);
416 return v_isotopeAverageListResult;
424 std::vector<PeptideNaturalIsotopeAverageSp>
432 std::vector<PeptideNaturalIsotopeAverageSp>
433 peptide_natural_isotope_average_list;
435 std::map<unsigned int, pappso::pappso_double> map_isotope_number =
437 std::vector<std::pair<unsigned int, pappso::pappso_double>>
440 for(
unsigned int i = 0; i < map_isotope_number.size(); i++)
442 sorted_number_ratio.push_back(
443 std::pair<unsigned int, pappso::pappso_double>(i,
444 map_isotope_number[i]));
445 unsigned int asked_rank = 0;
446 unsigned int given_rank = 0;
447 bool more_rank =
true;
452 *
this, asked_rank, i, charge, precision);
454 if(given_rank < asked_rank)
465 peptide_natural_isotope_average_list.push_back(
473 std::sort(sorted_number_ratio.begin(),
474 sorted_number_ratio.end(),
475 [](
const std::pair<unsigned int, pappso::pappso_double> &m,
476 const std::pair<unsigned int, pappso::pappso_double> &n) {
477 return (m.second > n.second);
481 double cumulativeRatio = 0;
482 std::vector<unsigned int> selected_isotope_number_list;
483 for(
auto &pair_isotope_number : sorted_number_ratio)
485 if(cumulativeRatio <= minimumIntensityRatio)
487 selected_isotope_number_list.push_back(pair_isotope_number.first);
493 cumulativeRatio += pair_isotope_number.second;
497 std::remove_if(peptide_natural_isotope_average_list.begin(),
498 peptide_natural_isotope_average_list.end(),
499 [selected_isotope_number_list](
501 auto it = std::find(selected_isotope_number_list.begin(),
502 selected_isotope_number_list.end(),
503 average.get()->getIsotopeNumber());
504 return (it == selected_isotope_number_list.end());
506 peptide_natural_isotope_average_list.erase(
507 it_remove, peptide_natural_isotope_average_list.end());
508 return peptide_natural_isotope_average_list;
unsigned int getIsotopeRank() const
pappso_double getIntensityRatio() const
PeptideNaturalIsotopeAverageSp makePeptideNaturalIsotopeAverageSp() const
~PeptideNaturalIsotopeList()
const PeptideInterfaceSp & getPeptideInterfaceSp() const
const PeptideInterfaceSp msp_peptide
PeptideNaturalIsotopeList(const PeptideInterfaceSp &peptide, pappso_double minimum_ratio_to_compute=0.001)
compute the list of possible isotopes for a peptide
std::list< PeptideNaturalIsotopeSp >::const_iterator const_iterator
const_iterator end() const
PeptideNaturalIsotopeListSp makePeptideNaturalIsotopeListSp() const
std::vector< PeptideNaturalIsotopeAverageSp > getByIntensityRatio(unsigned int charge, PrecisionPtr precision, pappso_double minimum_isotope_pattern_ratio) const
get the list of natural isotopes representing at least a minimum ratio of the whole isotope pattern
std::list< PeptideNaturalIsotopeSp > msp_peptide_natural_isotope_list
const std::map< unsigned int, pappso_double > getIntensityRatioPerIsotopeNumber() const
const_iterator begin() const
std::vector< PeptideNaturalIsotopeSp > getByIsotopeNumber(unsigned int isotopeLevel, unsigned int charge) const
unsigned int size() const
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< const PeptideNaturalIsotope > PeptideNaturalIsotopeSp
std::shared_ptr< const PeptideInterface > PeptideInterfaceSp
double pappso_double
A type definition for doubles.
std::shared_ptr< const PeptideNaturalIsotopeAverage > PeptideNaturalIsotopeAverageSp
std::vector< PeptideNaturalIsotopeAverageSp > getByIntensityRatioByIsotopeNumber(const PeptideInterfaceSp &peptide, unsigned int charge, PrecisionPtr precision, unsigned int isotopeNumber, pappso_double minimumIntensity)
std::shared_ptr< const PeptideNaturalIsotopeList > PeptideNaturalIsotopeListSp
peptide natural isotope model