31 const MassSpectrum &spectrum,
33 unsigned int parent_charge,
35 const std::list<PeptideIon> &ion_type_list,
36 unsigned int max_isotope_number,
37 [[maybe_unused]]
unsigned int max_isotope_rank)
38 : _precision(precision)
43 _peak_ion_match_list.clear();
44 qDebug() <<
"PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
45 "begin max_isotope_number="
46 << max_isotope_number;
47 PeptideFragmentIonListBase fragmentIonList(peptideSp, ion_type_list);
48 qDebug() <<
"PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
49 "peak_list spectrum.size="
51 std::vector<DataPoint> peak_list(spectrum.begin(), spectrum.end());
52 for(
auto ion_type : ion_type_list)
54 auto ion_list = fragmentIonList.getPeptideFragmentIonSp(ion_type);
56 for(
unsigned int charge = 1; charge <= parent_charge; charge++)
58 for(
auto &&ion : ion_list)
60 for(
unsigned int isotope_number = 0;
61 isotope_number <= max_isotope_number;
64 PeptideNaturalIsotopeAverage isotopeIon(
65 ion, isotope_number, charge, precision);
68 << isotope_number <<
" " << isotopeIon.toString();
70 std::vector<DataPoint>::iterator it_peak =
71 getBestPeakIterator(peak_list, isotopeIon);
72 if(it_peak != peak_list.end())
74 _peak_ion_match_list.push_back(PeakIonIsotopeMatch(
76 isotopeIon.makePeptideNaturalIsotopeAverageSp(),
78 peak_list.erase(it_peak);
80 qDebug() << isotope_number <<
" "
81 << _peak_ion_match_list.back().toString();
88 catch(PappsoException &exception_pappso)
92 "ERROR building PeptideIsotopeSpectrumMatch, PAPPSO exception:\n%1")
93 .arg(exception_pappso.qwhat());
94 qDebug() <<
"PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
97 throw PappsoException(errorStr);
99 catch(std::exception &exception_std)
103 "ERROR building PeptideIsotopeSpectrumMatch, std exception:\n%1")
104 .arg(exception_std.what());
105 qDebug() <<
"PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch "
108 throw PappsoException(errorStr);
112 PeptideIsotopeSpectrumMatch::PeptideIsotopeSpectrumMatch(
114 std::vector<PeptideNaturalIsotopeAverageSp> v_peptideIsotopeList,
115 std::vector<PeptideFragmentIonSp> v_peptideIonList,
117 : _precision(precision)
119 qDebug() <<
" begin";
120 if(v_peptideIsotopeList.size() != v_peptideIonList.size())
124 "v_peptideIsotopeList.size() %1 != v_peptideIonList.size() %2")
125 .arg(v_peptideIsotopeList.size())
126 .arg(v_peptideIonList.size()));
129 auto isotopeIt = v_peptideIsotopeList.begin();
130 auto ionIt = v_peptideIonList.begin();
131 std::vector<DataPoint> peak_list(spectrum.begin(), spectrum.end());
133 while(isotopeIt != v_peptideIsotopeList.end())
135 std::vector<DataPoint>::iterator it_peak =
137 if(it_peak != peak_list.end())
141 peak_list.erase(it_peak);
152 : _precision(other._precision),
153 _peak_ion_match_list(other._peak_ion_match_list)
163 std::vector<DataPoint>::iterator
165 std::vector<DataPoint> &peak_list,
169 std::vector<DataPoint>::iterator itpeak = peak_list.begin();
170 std::vector<DataPoint>::iterator itend = peak_list.end();
171 std::vector<DataPoint>::iterator itselect = peak_list.end();
175 while(itpeak != itend)
179 if(itpeak->y > best_intensity)
181 best_intensity = itpeak->y;
191 const std::list<PeakIonIsotopeMatch> &
219 if(
a.getPeptideIonType() <
b.getPeptideIonType())
221 if(
a.getPeptideFragmentIonSp().get()->size() <
222 b.getPeptideFragmentIonSp().get()->size())
224 if(
a.getCharge() <
b.getCharge())
226 if(
a.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber() <
227 b.getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber())
232 std::size_t nserie = 0;
233 std::size_t isotopeserie = 0;
234 unsigned int charge = 0;
235 for(std::list<PeakIonIsotopeMatch>::iterator it =
240 if((nserie != it->getPeptideFragmentIonSp().get()->size()) ||
241 (ion_type != it->getPeptideIonType()) || (charge != it->getCharge()))
243 ion_type = it->getPeptideIonType();
245 nserie = it->getPeptideFragmentIonSp().get()->size();
246 charge = it->getCharge();
249 it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber())
252 it->getPeptideNaturalIsotopeAverageSp().get()->getIsotopeNumber();
Class to represent a mass spectrum.
virtual ~PeptideIsotopeSpectrumMatch()
std::list< PeakIonIsotopeMatch >::const_iterator const_iterator
std::list< PeakIonIsotopeMatch > _peak_ion_match_list
PeptideIsotopeSpectrumMatch(const MassSpectrum &spectrum, const PeptideSp &peptide_sp, unsigned int parent_charge, PrecisionPtr precision, const std::list< PeptideIon > &ion_type_list, unsigned int max_isotope_number, unsigned int max_isotope_rank)
annotate spectrum with peptide ions and isotopes
const std::list< PeakIonIsotopeMatch > & getPeakIonIsotopeMatchList() const
const_iterator begin() const
void dropPeaksLackingMonoisotope()
const_iterator end() const
virtual std::vector< DataPoint >::iterator getBestPeakIterator(std::vector< DataPoint > &peak_list, const PeptideNaturalIsotopeAverage &ion) const
virtual bool matchPeak(pappso_double peak_mz) const final
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
PeptideIon
PeptideIon enum defines all types of ions (Nter or Cter)
std::shared_ptr< const Peptide > PeptideSp
double pappso_double
A type definition for doubles.
const PrecisionBase * PrecisionPtr