61 for(
auto aa_pep : peptide)
63 aa_pep.removeInternalCterModification();
64 aa_pep.removeInternalNterModification();
95 assign(other.begin(), other.end());
139 for(
auto aa_model : *
this)
141 qDebug() <<
" aa_model.amino_acid.toString()="
142 << aa_model.amino_acid.toAbsoluteString()
143 <<
" aa_model.alignment_type="
145 <<
" aa_model.mass_difference=" << aa_model.mass_difference
146 <<
" aa_model.bracket=" << aa_model.bracket;
149 peptide_str.append(
"-(");
153 QString(
"[%1]").arg(aa_model.amino_acid.toString()));
157 peptide_str.append(aa_model.amino_acid.toString());
161 if(aa_model.mass_difference != 0.0)
163 peptide_str.append(QString(
"[%1]").arg(
164 QString::number(aa_model.mass_difference,
'f', 2)));
168 peptide_str.append(
")");
171 peptide_str.replace(
")-(",
"");
173 QString(
"_[%1]").arg(QString::number(
getMassDelta(),
'f', 2)));
174 peptide_str.replace(
"_[0.00]",
"");
175 peptide_str.replace(
"_[-0.00]",
"");
183 for(
auto aa_model : *
this)
185 if(std::abs(aa_model.amino_acid.getMass() + aa_model.mass_difference) <
197 for(
auto aa_model : *
this)
200 if(std::abs(aa_model.amino_acid.getMass() + aa_model.mass_difference) <
203 amino_acid_to_remove = &aa_model;
207 if(amino_acid_to_remove !=
nullptr)
209 if(std::abs(front().amino_acid.getMass() -
214 at(pos - 1).mass_difference = 0;
231 for(
auto aa_model : *
this)
233 qDebug() <<
" aa_model.amino_acid.toString()="
234 << aa_model.amino_acid.toAbsoluteString()
235 <<
" aa_model.alignment_type="
237 <<
" aa_model.mass_difference=" << aa_model.mass_difference
238 <<
" aa_model.bracket=" << aa_model.bracket;
246 peptide_str.append(aa_model.amino_acid.getLetter());
251 aa_model.amino_acid.getLetter())
257 peptide_str.append(aa_model.amino_acid.toProForma());
259 mass_diff += aa_model.mass_difference;
265 QString(
"[+%1]").arg(QString::number(mass_diff,
'f', 4)));
270 QString(
"[%1]").arg(QString::number(mass_diff,
'f', 4)));
287 for(
auto aa_model : *
this)
289 mass += aa_model.amino_acid.getMass() + aa_model.mass_difference;
303 std::size_t count = 0;
306 for(
auto aa_model : *
this)
308 if(aa_model.mass_difference != 0.0)
335 (it_expe_peaks->x < it_theo_peaks->mz_range.lower()))
342 if(it_expe_peaks->x < it_theo_peaks->mz_range.upper())
345 auto it_theo_peaks_loop = it_theo_peaks;
347 (it_theo_peaks_loop->mz_range.contains(it_expe_peaks->x)))
349 if((it_theo_peaks_loop->it_experimental_peak_match ==
350 it_expe_peaks_end) ||
351 (it_theo_peaks_loop->it_experimental_peak_match->y <
354 it_theo_peaks_loop->it_experimental_peak_match =
356 qDebug() <<
"match: mz=" << it_expe_peaks->x
357 <<
" intensity=" << it_expe_peaks->y;
360 it_theo_peaks_loop++;
374 std::vector<std::vector<pappso::DataPoint>::const_iterator>
375 matched_experimental_peaks;
378 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
380 matched_experimental_peaks.push_back(
381 theo_peak.it_experimental_peak_match);
385 auto it_end = std::unique(matched_experimental_peaks.begin(),
386 matched_experimental_peaks.end());
388 std::distance(matched_experimental_peaks.begin(), it_end);
390 matched_experimental_peaks.begin(),
393 [](
double k,
const std::vector<pappso::DataPoint>::const_iterator &l) {
408 for(
auto aa_model : *
this)
411 cumul_mass += aa_model.amino_acid.getMass() + aa_model.mass_difference;
413 qDebug() << cumul_mass;
425 for(std::size_t i = 0; i < bmaxindice; i++)
439 return a.mz_range.getMz() < b.mz_range.getMz();
446 std::vector<double> mass_list;
449 mass_list.push_back(datapoint.mz_range.getMz());
481 double precision_ref = precision->
getNominal();
483 bool modified =
false;
484 std::vector<AminoAcidModel>::iterator it_begin_block = end();
487 it_begin_block = begin();
490 qDebug() <<
" new block offset=" << offset;
493 for(
auto it = begin(); it != end(); it++)
495 qDebug() <<
" it->mass_difference=" << it->mass_difference;
496 if(it_begin_block == end())
499 if(std::abs(it->mass_difference) > precision_ref)
503 offset = it->mass_difference;
505 qDebug() <<
" new block offset=" << offset;
507 if(it_begin_block != end())
510 qDebug() <<
" existing block offset=" << offset;
513 offset += it->mass_difference;
518 qDebug() <<
" where is the end of the block ? offset=" << offset;
519 auto it_end_block = std::find_if(
530 if(it_end_block != end())
534 if(it_begin_block == begin())
536 it_begin_block->mass_difference = 0.0;
537 it_end_block->mass_difference = 0.0;
539 it_begin_block = end();
541 qDebug() <<
" existing block end block found";
545 qDebug() <<
" existing block end block not found offset="
548 it_begin_block = end();
562 double precision_ref = precision->
getNominal();
563 auto it_reverse = rbegin();
564 bool modified =
false;
566 while(it_reverse != rend())
568 if(it_reverse->remove)
574 double mass_difference = it_reverse->mass_difference;
575 if(mass_difference < 0)
578 double cumul_mass_aa = 0;
579 auto it_block_end = it_reverse;
580 while(it_block_end != rend())
582 cumul_mass_aa += it_block_end->amino_acid.getMass();
584 if(std::abs(mass_difference + cumul_mass_aa) < precision_ref)
588 for(
auto it_block = it_reverse; it_block != it_block_end;
591 it_block->remove =
true;
596 if((it_block_end != rend()) &&
597 (it_block_end->mass_difference != 0.0))
619 bool modified =
false;
623 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
625 if(at(theo_peak.aa_indice).bracket ==
true)
628 at(theo_peak.aa_indice).bracket =
false;
635const std::vector<TheoreticalPeakDataPoint> &
649 double intensity = 0;
650 if(theo_peak.it_experimental_peak_match != it_expe_peaks_end)
652 intensity = theo_peak.it_experimental_peak_match->y;
654 str.append(QString(
"{%1,%2,%3,%4}")
655 .arg(theo_peak.mz_range.getMz())
657 .arg(theo_peak.aa_indice)
658 .arg(at(theo_peak.aa_indice).amino_acid.toString()));
668 double total_mass_to_insert = amino_acid_candidate.
getMass();
669 auto insert_aa_modification =
674 for(
auto &aa_model : *
this)
676 mass_difference += aa_model.mass_difference;
677 auto aa_ref = aa_model.amino_acid;
678 if(mass_difference != 0.0)
680 mass_difference += aa_ref.getTotalModificationMass();
683 aa_model.amino_acid.getLetter());
685 double current_diff =
686 (aa_ref_remove->
getMass() - mass_difference) + total_mass_to_insert;
689 qDebug() <<
"current_diff=" << current_diff;
690 if(std::abs(current_diff) < precision->
getNominal())
692 qDebug() <<
"modif = true=";
693 aa_model.mass_difference = 0;
694 aa_model.amino_acid.removeAllButInternalModification();
695 aa_model.amino_acid.addAaModification(aa_ref_remove);
696 aa_model.amino_acid.addAaModification(insert_aa_modification);
699 aa_model.amino_acid.addAaModification(mod);
717 std::vector<AaModificationP> modificationInsertList;
718 for(
const auto aa : aa_list)
720 modificationInsertList.push_back(
724 for(
auto &aa_model : *
this)
726 mass_difference += aa_model.mass_difference;
727 auto aa_ref = aa_model.amino_acid;
728 if(mass_difference != 0.0)
730 mass_difference += aa_ref.getTotalModificationMass();
733 aa_model.amino_acid.getLetter());
735 double better_diff = 10;
737 for(
const auto aaInsertion : modificationInsertList)
739 double current_diff =
740 (aa_ref_remove->
getMass() - mass_difference) +
741 aaInsertion->getMass();
742 qDebug() << aa_model.amino_acid.getLetter() <<
" "
743 << aaInsertion->getName() <<
" "
744 << aaInsertion->getMass() <<
" " << current_diff;
745 if(std::abs(current_diff) < std::abs(better_diff))
747 aa_ref_insert = aaInsertion;
748 better_diff = current_diff;
751 qDebug() <<
"better_diff=" << better_diff;
752 if((aa_ref_insert !=
nullptr) &&
753 (std::abs(better_diff) < precision->
getNominal()))
756 qDebug() <<
"modif = true=";
757 aa_model.mass_difference = 0;
758 aa_model.amino_acid.removeAllButInternalModification();
759 aa_model.amino_acid.addAaModification(aa_ref_remove);
760 aa_model.amino_acid.addAaModification(aa_ref_insert);
777 for(
auto &aa_model : *
this)
779 mass_difference += aa_model.mass_difference;
780 auto aa_ref = aa_model.amino_acid;
781 if(mass_difference != 0.0)
783 if(std::abs(modification->
getMass() - mass_difference) <
786 aa_model.mass_difference = 0;
787 aa_model.amino_acid.addAaModification(modification);
805 for(
auto &aa_model : *
this)
807 mass_difference += aa_model.mass_difference;
808 auto aa_ref = aa_model.amino_acid;
809 if(aa_ref.getLetter() == aa_modified.
getLetter())
811 if(mass_difference != 0.0)
814 if(std::abs(mass_modification - mass_difference) <
817 aa_model.mass_difference = 0;
820 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
bool ltrimOnRemoval()
try to remove left amino acid if there is a removal
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
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 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.
class dedicated to raw mass computations of peptide products (fragments)