61 for(
auto aa_pep : peptide)
92 assign(other.begin(), other.end());
133 peptide_str.append(QString(
"[%1]").arg(QString::number(
m_beginMassDelta,
'f', 2)));
135 for(
auto aa_model : *
this)
137 qDebug() <<
" aa_model.amino_acid.toString()=" << aa_model.amino_acid.toAbsoluteString()
138 <<
" aa_model.alignment_type=" <<
Utils::toString(aa_model.alignment_type)
139 <<
" aa_model.mass_difference=" << aa_model.mass_difference
140 <<
" aa_model.bracket=" << aa_model.bracket;
143 peptide_str.append(
"-(");
146 peptide_str.append(QString(
"[%1]").arg(aa_model.amino_acid.toString()));
150 peptide_str.append(aa_model.amino_acid.toString());
154 if(aa_model.mass_difference != 0.0)
157 QString(
"[%1]").arg(QString::number(aa_model.mass_difference,
'f', 2)));
161 peptide_str.append(
")");
164 peptide_str.replace(
")-(",
"");
165 peptide_str.append(QString(
"_[%1]").arg(QString::number(
getMassDelta(),
'f', 2)));
166 peptide_str.replace(
"_[0.00]",
"");
167 peptide_str.replace(
"_[-0.00]",
"");
175 for(
auto aa_model : *
this)
177 if(std::abs(aa_model.amino_acid.getMass() + aa_model.mass_difference) < 0.001)
188 for(
auto aa_model : *
this)
191 if(std::abs(aa_model.amino_acid.getMass() + aa_model.mass_difference) < 0.001)
193 amino_acid_to_remove = &aa_model;
197 if(amino_acid_to_remove !=
nullptr)
199 if(std::abs(front().amino_acid.getMass() - amino_acid_to_remove->
amino_acid.
getMass()) <
204 at(pos - 1).mass_difference = 0;
215 QString peptide_str(
"[");
226 peptide_str.append(
"+");
228 peptide_str.append(QString(
"%1]?").arg(QString::number(
getMassDelta(),
'f', 4)));
229 peptide_str.replace(
"[+0.0000]?",
"");
230 peptide_str.replace(
"[-0.0000]?",
"");
234 for(
auto aa_model : *
this)
236 qDebug() <<
" aa_model.amino_acid.toString()=" << aa_model.amino_acid.toAbsoluteString()
237 <<
" aa_model.alignment_type=" <<
Utils::toString(aa_model.alignment_type)
238 <<
" aa_model.mass_difference=" << aa_model.mass_difference
239 <<
" aa_model.bracket=" << aa_model.bracket;
247 peptide_str.append(aa_model.amino_acid.getLetter());
257 peptide_str.append(aa_model.amino_acid.toProForma());
259 mass_diff += aa_model.mass_difference;
264 peptide_str.append(QString(
"[+%1]").arg(QString::number(mass_diff,
'f', 4)));
268 peptide_str.append(QString(
"[%1]").arg(QString::number(mass_diff,
'f', 4)));
285 for(
auto aa_model : *
this)
287 mass += aa_model.amino_acid.getMass() + aa_model.mass_difference;
301 std::size_t count = 0;
304 for(
auto aa_model : *
this)
306 if(aa_model.mass_difference != 0.0)
333 (it_expe_peaks->x < it_theo_peaks->mz_range.lower()))
340 if(it_expe_peaks->x < it_theo_peaks->mz_range.upper())
343 auto it_theo_peaks_loop = it_theo_peaks;
345 (it_theo_peaks_loop->mz_range.contains(it_expe_peaks->x)))
347 if((it_theo_peaks_loop->it_experimental_peak_match == it_expe_peaks_end) ||
348 (it_theo_peaks_loop->it_experimental_peak_match->y < it_expe_peaks->y))
350 it_theo_peaks_loop->it_experimental_peak_match = it_expe_peaks;
351 qDebug() <<
"match: mz=" << it_expe_peaks->x <<
" intensity=" << it_expe_peaks->y;
354 it_theo_peaks_loop++;
368 std::vector<std::vector<pappso::DataPoint>::const_iterator> matched_experimental_peaks;
371 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
373 matched_experimental_peaks.push_back(theo_peak.it_experimental_peak_match);
377 auto it_end = std::unique(matched_experimental_peaks.begin(), matched_experimental_peaks.end());
380 matched_experimental_peaks.begin(),
383 [](
double k,
const std::vector<pappso::DataPoint>::const_iterator &l) { return (k + l->y); });
396 for(
auto aa_model : *
this)
399 cumul_mass += aa_model.amino_acid.getMass() + aa_model.mass_difference;
401 qDebug() << cumul_mass;
412 for(std::size_t i = 0; i < bmaxindice; i++)
424 return a.mz_range.getMz() < b.mz_range.getMz();
431 std::vector<double> mass_list;
434 mass_list.push_back(datapoint.mz_range.getMz());
466 double precision_ref = precision->
getNominal();
468 bool modified =
false;
469 std::vector<AminoAcidModel>::iterator it_begin_block = end();
472 it_begin_block = begin();
475 qDebug() <<
" new block offset=" << offset;
478 for(
auto it = begin(); it != end(); it++)
480 qDebug() <<
" it->mass_difference=" << it->mass_difference;
481 if(it_begin_block == end())
484 if(std::abs(it->mass_difference) > precision_ref)
488 offset = it->mass_difference;
490 qDebug() <<
" new block offset=" << offset;
492 if(it_begin_block != end())
495 qDebug() <<
" existing block offset=" << offset;
498 offset += it->mass_difference;
503 qDebug() <<
" where is the end of the block ? offset=" << offset;
505 std::find_if(it, end(), [offset, precision_ref](
const AminoAcidModel &point) {
512 if(it_end_block != end())
516 if(it_begin_block == begin())
518 it_begin_block->mass_difference = 0.0;
519 it_end_block->mass_difference = 0.0;
521 it_begin_block = end();
523 qDebug() <<
" existing block end block found";
527 qDebug() <<
" existing block end block not found offset=" << offset;
529 it_begin_block = end();
543 double precision_ref = precision->
getNominal();
544 auto it_reverse = rbegin();
545 bool modified =
false;
547 while(it_reverse != rend())
549 if(it_reverse->remove)
555 double mass_difference = it_reverse->mass_difference;
556 if(mass_difference < 0)
559 double cumul_mass_aa = 0;
560 auto it_block_end = it_reverse;
561 while(it_block_end != rend())
563 cumul_mass_aa += it_block_end->amino_acid.getMass();
565 if(std::abs(mass_difference + cumul_mass_aa) < precision_ref)
569 for(
auto it_block = it_reverse; it_block != it_block_end; it_block++)
571 it_block->remove =
true;
576 if((it_block_end != rend()) && (it_block_end->mass_difference != 0.0))
598 bool modified =
false;
602 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
604 if(at(theo_peak.aa_indice).bracket ==
true)
607 at(theo_peak.aa_indice).bracket =
false;
614const std::vector<TheoreticalPeakDataPoint> &
628 double intensity = 0;
629 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
631 intensity = theo_peak.it_experimental_peak_match->y;
633 str.append(QString(
"{%1,%2,%3,%4}")
634 .arg(theo_peak.mz_range.getMz())
636 .arg(theo_peak.aa_indice)
637 .arg(at(theo_peak.aa_indice).amino_acid.toString()));
647 double total_mass_to_insert = amino_acid_candidate.
getMass();
648 auto insert_aa_modification =
652 for(
auto &aa_model : *
this)
654 mass_difference += aa_model.mass_difference;
655 auto aa_ref = aa_model.amino_acid;
656 if(mass_difference != 0.0)
658 mass_difference += aa_ref.getTotalModificationMass();
662 double current_diff = (aa_ref_remove->
getMass() - mass_difference) + total_mass_to_insert;
665 qDebug() <<
"current_diff=" << current_diff;
666 if(std::abs(current_diff) < precision->
getNominal())
668 qDebug() <<
"modif = true=";
669 aa_model.mass_difference = 0;
670 aa_model.amino_acid.removeAllButInternalModification();
671 aa_model.amino_acid.addAaModification(aa_ref_remove);
672 aa_model.amino_acid.addAaModification(insert_aa_modification);
675 aa_model.amino_acid.addAaModification(mod);
693 std::vector<AaModificationP> modificationInsertList;
694 for(
const auto aa : aa_list)
696 modificationInsertList.push_back(
700 for(
auto &aa_model : *
this)
702 mass_difference += aa_model.mass_difference;
703 auto aa_ref = aa_model.amino_acid;
704 if(mass_difference != 0.0)
706 mass_difference += aa_ref.getTotalModificationMass();
710 double better_diff = 10;
712 for(
const auto aaInsertion : modificationInsertList)
714 double current_diff =
715 (aa_ref_remove->
getMass() - mass_difference) + aaInsertion->getMass();
716 qDebug() << aa_model.amino_acid.getLetter() <<
" " << aaInsertion->getName() <<
" "
717 << aaInsertion->getMass() <<
" " << current_diff;
718 if(std::abs(current_diff) < std::abs(better_diff))
720 aa_ref_insert = aaInsertion;
721 better_diff = current_diff;
724 qDebug() <<
"better_diff=" << better_diff;
725 if((aa_ref_insert !=
nullptr) && (std::abs(better_diff) < precision->
getNominal()))
728 qDebug() <<
"modif = true=";
729 aa_model.mass_difference = 0;
730 aa_model.amino_acid.removeAllButInternalModification();
731 aa_model.amino_acid.addAaModification(aa_ref_remove);
732 aa_model.amino_acid.addAaModification(aa_ref_insert);
749 for(
auto &aa_model : *
this)
751 mass_difference += aa_model.mass_difference;
752 auto aa_ref = aa_model.amino_acid;
753 if(mass_difference != 0.0)
755 if(std::abs(modification->
getMass() - mass_difference) < precision->
getNominal())
757 aa_model.mass_difference = 0;
758 aa_model.amino_acid.addAaModification(modification);
775 for(
auto &aa_model : *
this)
777 mass_difference += aa_model.mass_difference;
778 auto aa_ref = aa_model.amino_acid;
779 if(aa_ref.getLetter() == aa_modified.
getLetter())
781 if(mass_difference != 0.0)
784 if(std::abs(mass_modification - mass_difference) < precision->
getNominal())
786 aa_model.mass_difference = 0;
789 aa_model.amino_acid.addAaModification(modification);
virtual const char & getLetter() 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(Enums::PeptideIon ion_type)
AaModificationP getCleavageCterModification() const
AaModificationP getCleavageNterModification() 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
PeptideModel(const pappso::QualifiedMassSpectrum &qmass_spectrum, const pappso::Peptide &peptide)
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
bool ltrimOnRemoval()
try to remove left amino acid if there is a removal
double getMassDelta() const
mass delta between experimental and theoretical mass
bool checkForMutations(const std::vector< Enums::AminoAcidChar > &aa_list, pappso::PrecisionPtr precision)
try to replace mass differences with corresponding mutations mass delta
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
pappso_double getMz(unsigned int charge) const
get the m/z peptide model mass
void generateTheoreticalPeaks(pappso::PrecisionPtr precision)
bool eliminateComplementaryDelta(pappso::PrecisionPtr precision)
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 AaModification * AaModificationP
const pappso_double MHPLUS(1.007276466879)
const pappso_double MPROTIUM(1.007825032241)
const PrecisionBase * PrecisionPtr