39#include "../../peptide/peptiderawfragmentmasses.h"
40#include "../../pappsoexception.h"
41#include "../../utils.h"
61 for(
auto aa_pep : peptide)
63 aa_pep.removeInternalCterModification();
64 aa_pep.removeInternalNterModification();
95 assign(other.begin(), other.end());
133 for(
auto aa_model : *
this)
135 qDebug() <<
" aa_model.amino_acid.toString()="
136 << aa_model.amino_acid.toAbsoluteString()
137 <<
" aa_model.alignment_type="
139 <<
" aa_model.mass_difference=" << aa_model.mass_difference
140 <<
" aa_model.bracket=" << aa_model.bracket;
143 peptide_str.append(
"-(");
147 QString(
"[%1]").arg(aa_model.amino_acid.toString()));
151 peptide_str.append(aa_model.amino_acid.toString());
155 if(aa_model.mass_difference != 0.0)
157 peptide_str.append(QString(
"[%1]").arg(
158 QString::number(aa_model.mass_difference,
'f', 2)));
162 peptide_str.append(
")");
165 peptide_str.replace(
")-(",
"");
167 QString(
"_[%1]").arg(QString::number(
getMassDelta(),
'f', 2)));
168 peptide_str.replace(
"_[0.00]",
"");
169 peptide_str.replace(
"_[-0.00]",
"");
184 for(
auto aa_model : *
this)
186 qDebug() <<
" aa_model.amino_acid.toString()="
187 << aa_model.amino_acid.toAbsoluteString()
188 <<
" aa_model.alignment_type="
190 <<
" aa_model.mass_difference=" << aa_model.mass_difference
191 <<
" aa_model.bracket=" << aa_model.bracket;
199 peptide_str.append(aa_model.amino_acid.getLetter());
204 aa_model.amino_acid.getLetter())
210 peptide_str.append(aa_model.amino_acid.toProForma());
212 mass_diff += aa_model.mass_difference;
218 QString(
"[+%1]").arg(QString::number(mass_diff,
'f', 4)));
223 QString(
"[%1]").arg(QString::number(mass_diff,
'f', 4)));
240 for(
auto aa_model : *
this)
242 mass += aa_model.amino_acid.getMass() + aa_model.mass_difference;
256 std::size_t count = 0;
259 for(
auto aa_model : *
this)
261 if(aa_model.mass_difference != 0.0)
288 (it_expe_peaks->x < it_theo_peaks->mz_range.lower()))
295 if(it_expe_peaks->x < it_theo_peaks->mz_range.upper())
298 auto it_theo_peaks_loop = it_theo_peaks;
300 (it_theo_peaks_loop->mz_range.contains(it_expe_peaks->x)))
302 if((it_theo_peaks_loop->it_experimental_peak_match ==
303 it_expe_peaks_end) ||
304 (it_theo_peaks_loop->it_experimental_peak_match->y <
307 it_theo_peaks_loop->it_experimental_peak_match =
309 qDebug() <<
"match: mz=" << it_expe_peaks->x
310 <<
" intensity=" << it_expe_peaks->y;
313 it_theo_peaks_loop++;
327 std::vector<std::vector<pappso::DataPoint>::const_iterator>
328 matched_experimental_peaks;
331 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
333 matched_experimental_peaks.push_back(
334 theo_peak.it_experimental_peak_match);
338 auto it_end = std::unique(matched_experimental_peaks.begin(),
339 matched_experimental_peaks.end());
341 std::distance(matched_experimental_peaks.begin(), it_end);
343 matched_experimental_peaks.begin(),
346 [](
double k,
const std::vector<pappso::DataPoint>::const_iterator &l) {
361 for(
auto aa_model : *
this)
364 cumul_mass += aa_model.amino_acid.getMass() + aa_model.mass_difference;
366 qDebug() << cumul_mass;
378 for(std::size_t i = 0; i < bmaxindice; i++)
392 return a.mz_range.getMz() < b.mz_range.getMz();
399 std::vector<double> mass_list;
402 mass_list.push_back(datapoint.mz_range.getMz());
434 double precision_ref = precision->
getNominal();
436 bool modified =
false;
437 std::vector<AminoAcidModel>::iterator it_begin_block = end();
440 it_begin_block = begin();
443 qDebug() <<
" new block offset=" << offset;
446 for(
auto it = begin(); it != end(); it++)
448 qDebug() <<
" it->mass_difference=" << it->mass_difference;
449 if(it_begin_block == end())
452 if(std::abs(it->mass_difference) > precision_ref)
456 offset = it->mass_difference;
458 qDebug() <<
" new block offset=" << offset;
460 if(it_begin_block != end())
463 qDebug() <<
" existing block offset=" << offset;
466 offset += it->mass_difference;
471 qDebug() <<
" where is the end of the block ? offset=" << offset;
472 auto it_end_block = std::find_if(
483 if(it_end_block != end())
487 if(it_begin_block == begin())
489 it_begin_block->mass_difference = 0.0;
490 it_end_block->mass_difference = 0.0;
492 it_begin_block = end();
494 qDebug() <<
" existing block end block found";
498 qDebug() <<
" existing block end block not found offset="
501 it_begin_block = end();
515 double precision_ref = precision->
getNominal();
516 auto it_reverse = rbegin();
517 bool modified =
false;
519 while(it_reverse != rend())
521 if(it_reverse->remove)
527 double mass_difference = it_reverse->mass_difference;
528 if(mass_difference < 0)
531 double cumul_mass_aa = 0;
532 auto it_block_end = it_reverse;
533 while(it_block_end != rend())
535 cumul_mass_aa += it_block_end->amino_acid.getMass();
537 if(std::abs(mass_difference + cumul_mass_aa) < precision_ref)
541 for(
auto it_block = it_reverse; it_block != it_block_end;
544 it_block->remove =
true;
549 if((it_block_end != rend()) &&
550 (it_block_end->mass_difference != 0.0))
572 bool modified =
false;
576 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
578 if(at(theo_peak.aa_indice).bracket ==
true)
581 at(theo_peak.aa_indice).bracket =
false;
588const std::vector<TheoreticalPeakDataPoint> &
602 double intensity = 0;
603 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
605 intensity = theo_peak.it_experimental_peak_match->y;
607 str.append(QString(
"{%1,%2,%3,%4}")
608 .arg(theo_peak.mz_range.getMz())
610 .arg(theo_peak.aa_indice)
611 .arg(at(theo_peak.aa_indice).amino_acid.toString()));
621 double total_mass_to_insert = amino_acid_candidate.
getMass();
622 auto insert_aa_modification =
627 for(
auto &aa_model : *
this)
629 mass_difference += aa_model.mass_difference;
630 auto aa_ref = aa_model.amino_acid;
631 if(mass_difference != 0.0)
633 mass_difference += aa_ref.getTotalModificationMass();
636 aa_model.amino_acid.getLetter());
638 double current_diff =
639 (aa_ref_remove->
getMass() - mass_difference) + total_mass_to_insert;
642 qDebug() <<
"current_diff=" << current_diff;
643 if(std::abs(current_diff) < precision->
getNominal())
645 qDebug() <<
"modif = true=";
646 aa_model.mass_difference = 0;
647 aa_model.amino_acid.removeAllButInternalModification();
648 aa_model.amino_acid.addAaModification(aa_ref_remove);
649 aa_model.amino_acid.addAaModification(insert_aa_modification);
652 aa_model.amino_acid.addAaModification(mod);
670 std::vector<AaModificationP> modificationInsertList;
671 for(
const auto aa : aa_list)
673 modificationInsertList.push_back(
677 for(
auto &aa_model : *
this)
679 mass_difference += aa_model.mass_difference;
680 auto aa_ref = aa_model.amino_acid;
681 if(mass_difference != 0.0)
683 mass_difference += aa_ref.getTotalModificationMass();
686 aa_model.amino_acid.getLetter());
688 double better_diff = 10;
690 for(
const auto aaInsertion : modificationInsertList)
692 double current_diff =
693 (aa_ref_remove->
getMass() - mass_difference) +
695 qDebug() << aa_model.amino_acid.getLetter() <<
" "
696 << aaInsertion->getName() <<
" "
697 << aaInsertion->getMass() <<
" " << current_diff;
698 if(std::abs(current_diff) < std::abs(better_diff))
700 aa_ref_insert = aaInsertion;
701 better_diff = current_diff;
704 qDebug() <<
"better_diff=" << better_diff;
705 if((aa_ref_insert !=
nullptr) &&
706 (std::abs(better_diff) < precision->
getNominal()))
709 qDebug() <<
"modif = true=";
710 aa_model.mass_difference = 0;
711 aa_model.amino_acid.removeAllButInternalModification();
712 aa_model.amino_acid.addAaModification(aa_ref_remove);
713 aa_model.amino_acid.addAaModification(aa_ref_insert);
730 for(
auto &aa_model : *
this)
732 mass_difference += aa_model.mass_difference;
733 auto aa_ref = aa_model.amino_acid;
734 if(mass_difference != 0.0)
736 if(std::abs(modification->
getMass() - mass_difference) <
739 aa_model.mass_difference = 0;
740 aa_model.amino_acid.addAaModification(modification);
758 for(
auto &aa_model : *
this)
760 mass_difference += aa_model.mass_difference;
761 auto aa_ref = aa_model.amino_acid;
762 if(aa_ref.getLetter() == aa_modified.
getLetter())
764 if(mass_difference != 0.0)
767 if(std::abs(mass_modification - mass_difference) <
770 aa_model.mass_difference = 0;
773 aa_model.amino_acid.addAaModification(modification);
virtual const char & getLetter() const
const QString & getAccession() const
pappso_double getMass() const
static AaModificationP getInstanceRemovalAccessionByAaLetter(const QChar &amino_acid)
get a PSI MOD instance corresponding to the removal of the given amino acid find the modifications th...
static AaModificationP getInstanceInsertionAccessionByAaLetter(const QChar &amino_acid)
get a PSI MOD instance corresponding to the insertion of the given amino acid find the modifications.
double getTotalModificationMass() const
get the sum of mass modifications
const std::vector< AaModificationP > & getModificationList() const
pappso_double getMass() const override
static pappso_double getDeltaMass(PeptideIon ion_type)
AaModificationP getInternalNterModification() const
AaModificationP getInternalCterModification() const
virtual pappso_double getNominal() const final
Class representing a fully specified mass spectrum.
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
double getPrecursorMass(bool *ok_p=nullptr) const
get precursor mass given the charge stats and precursor mz
static QString toString(specglob::SpectralAlignmentType type)
Convenience function to return a string describing the specglob alingment type.
pappso::AaModificationP m_nterModification
double getIntensityExperimentalPeaks() const
std::vector< TheoreticalPeakDataPoint > m_theoreticalPeakList
double m_intensitySharedPeaks
double m_experimentalPrecursorMass
std::size_t getCountSharedPeaks() const
double m_intensityExperimentalPeaks
void matchExperimentalPeaks(pappso::PrecisionPtr precision)
void assignResidualMass2Cter()
QString getTheoreticalPeakDataPointListToString() const
bool removeBracketsForAlignedAA()
bool eliminateNegativeOffset(pappso::PrecisionPtr precision)
QString toProForma() const
get the peptide model in ProForma notation https://github.com/HUPO-PSI/ProForma/blob/master/README....
bool checkForAaModificationP(pappso::AaModificationP modification, pappso::PrecisionPtr precision)
try to replace mass differences with the given modification
pappso::AaModificationP m_cterModification
double getMassDelta() const
mass delta between experimental and theoretical mass
std::size_t modifCount() const
PeptideModel & operator=(const PeptideModel &other)
pappso::MassSpectrumCstSPtr mcsp_peakList
const std::vector< TheoreticalPeakDataPoint > & getTheoreticalPeakDataPointList() const
void setBeginMassDelta(double)
double getIntensitySharedPeaks() const
void generateTheoreticalPeaks(pappso::PrecisionPtr precision)
bool eliminateComplementaryDelta(pappso::PrecisionPtr precision)
bool checkForMutations(const std::vector< AminoAcidChar > &aa_list, pappso::PrecisionPtr precision)
try to replace mass differences with corresponding mutations mass delta
bool checkForAaModification(const pappso::Aa &aa_modified, pappso::PrecisionPtr precision)
try to replace mass differences with the given modifications on a specific amino acid
bool checkForMutation(const pappso::Aa &amino_acid_candidate, pappso::PrecisionPtr precision)
try to replace mass differences with corresponding mutation mass delta
std::size_t m_countSharedPeaks
std::vector< double > getTheoreticalIonMassList() const
PeptideModel & copyDeep(const PeptideModel &other)
@ nonAlign
the type of alignment to put in origin matrix NON Alignment (0 - NA)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
const pappso_double MHPLUS(1.007276466879)
const pappso_double MPROTIUM(1.007825032241)
SpecGlobTool peptide model.