32#include "../peptide/peptideproformaparser.h"
38 const std::vector<ProteinSp> &protein_list)
39 :
PeptideBase(peptide_sp), m_id(id), m_proteinSpList(protein_list)
44 :
PeptideBase(other.msp_peptide), m_id(other.m_id), m_proteinSpList(other.m_proteinSpList)
51 if(mpa_peptideNaturalIsotopeList !=
nullptr)
52 delete mpa_peptideNaturalIsotopeList;
59 if(ni_min_abundance > 0)
61 if(m_peptideLabelMap.size() > 0)
64 for(
auto &pair_label : m_peptideLabelMap)
66 qDebug() << pair_label.second.get();
67 pair_label.second->computeIsotopologues(ni_min_abundance);
99const std::map<QString, pappso::masschroq::PeptideLabelSp> &
102 return m_peptideLabelMap;
108 if(m_allObservedChargeStateList.end() ==
109 std::find(m_allObservedChargeStateList.begin(), m_allObservedChargeStateList.end(), charge))
111 m_allObservedChargeStateList.push_back(charge);
115const std::vector<std::uint8_t> &
118 return m_allObservedChargeStateList;
125 auto it = std::find(m_observedInMsRunSpList.begin(), m_observedInMsRunSpList.end(), msrun_sp);
126 if(it == m_observedInMsRunSpList.end())
128 m_observedInMsRunSpList.push_back(msrun_sp);
133const std::vector<pappso::masschroq::ProteinSp> &
136 return m_proteinSpList;
175 m_alignedPeakPositionElementList.push_back(position);
184 double best_rt = peptide_observation.
getBestXicCoord().get()->rtTarget;
190 m_referenceMs2ObservationList.push_back(best_rt);
196 m_consensusAlignedPeakRetentionTime = 0;
198 if(m_alignedPeakPositionElementList.size() > 0)
200 std::sort(m_alignedPeakPositionElementList.begin(),
201 m_alignedPeakPositionElementList.end(),
203 return a.wide > b.wide;
207 std::size_t limit = m_alignedPeakPositionElementList.size() * 0.9;
210 limit = m_alignedPeakPositionElementList.size();
213 double total_intensity = std::accumulate(m_alignedPeakPositionElementList.begin(),
214 m_alignedPeakPositionElementList.begin() + limit,
217 sum += element.intensity;
220 double sum_rt = std::accumulate(m_alignedPeakPositionElementList.begin(),
221 m_alignedPeakPositionElementList.begin() + limit,
224 sum += element.intensity * element.alignedRetentionTime;
228 m_consensusAlignedPeakRetentionTime = sum_rt / total_intensity;
230 m_alignedPeakPositionElementList.clear();
232 double sum_rt = std::accumulate(
233 m_referenceMs2ObservationList.begin(), m_referenceMs2ObservationList.end(), (
double)0.0);
234 m_consensusAlignedMs2RetentionTime = sum_rt / (double)m_referenceMs2ObservationList.size();
236 m_referenceMs2ObservationList.clear();
242 auto it = std::find_if(m_observedInMsRunSpList.begin(),
243 m_observedInMsRunSpList.end(),
245 if(it == m_observedInMsRunSpList.end())
254 mp_referenceMsRunRetentionTime = msrun_retention_time_reference_p;
260 return m_consensusAlignedPeakRetentionTime;
266 return m_consensusAlignedMs2RetentionTime;
273 m_msRunXicCoordChargeList.push_back(msrun_xic_coord);
279 std::uint8_t charge)
const
285 for(
auto &xic_coord_charge : m_msRunXicCoordChargeList)
287 if(msrun_group_p->
contains(xic_coord_charge.msrun_p))
289 if(xic_coord_charge.charge == charge)
291 if(xic_coord_charge.intensity > intensity)
293 intensity = xic_coord_charge.intensity;
294 best_xic_coord = xic_coord_charge.xic_coord_sp;
301 return best_xic_coord;
309 for(
auto &xic_coord_charge_a : m_msRunXicCoordChargeList)
313 *(xic_coord_charge_a.msrun_p->getMsRunReaderSPtr().get()->getMsRunId().get());
316 for(
auto &xic_coord_charge_b : m_msRunXicCoordChargeList)
318 if(&xic_coord_charge_a == &xic_coord_charge_b)
327 *(xic_coord_charge_b.msrun_p->getMsRunReaderSPtr().get()->getMsRunId().get());
328 if(msrun_id_b == msrun_id_a)
335 if(xic_coord_charge_a.charge == xic_coord_charge_b.charge)
338 msrun_id_a, xic_coord_a.get(), msrun_id_b, xic_coord_b.get());
351 std::uint8_t charge)
const
354 std::size_t count = 0;
357 for(
auto &msrun_xic_coord_charge : m_msRunXicCoordChargeList)
359 if(msrun_group.
contains(msrun_xic_coord_charge.msrun_p))
362 if(msrun_xic_coord_charge.charge == charge)
367 if(ion_mobility_grid_p !=
nullptr)
371 *xic_coord_to_add.get(),
372 *(msrun_xic_coord_charge.msrun_p->getMsRunReaderSPtr()
379 if(xic_coord_mean.get() ==
nullptr)
381 xic_coord_mean = xic_coord_to_add.get()->initializeAndClone();
385 xic_coord_mean = xic_coord_mean.get()->addition(xic_coord_to_add);
388 qDebug() <<
" xic_coord_mean.get()->toString=" << xic_coord_mean.get()->toString();
392 if(xic_coord_mean.get() !=
nullptr)
394 xic_coord_mean = xic_coord_mean.get()->divideBy(count);
398 return xic_coord_mean;
404 auto it = json_label_list.begin();
406 while(it != json_label_list.end())
408 QString label = it.key();
410 QString proforma = it.value().toObject().value(
"proforma").toString();
414 if(proforma.isEmpty())
417 QObject::tr(
"ERROR: label %1 %2 must contain proforma sequence").arg(label).arg(m_id));
421 peptide_label_sp = std::make_shared<pappso::masschroq::PeptideLabel>(
424 m_peptideLabelMap.insert({label, peptide_label_sp});
432 auto it = m_peptideLabelMap.find(label);
433 if(it == m_peptideLabelMap.end())
436 QObject::tr(
"ERROR: label %1 not found in peptide %2").arg(label).arg(m_id));
438 return it->second.get();
pappso::XicCoordSPtr translateXicCoordFromTo(const pappso::XicCoord &source_xic_coord, const MsRunId &source_msrunid, const MsRunId &target_msrunid) const
void storeObservedIdentityBetween(const MsRunId &msrun_ida, const XicCoord *xic_coorda, const MsRunId &msrun_idb, const XicCoord *xic_coordb)
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
double translateOriginal2AlignedRetentionTime(double original_retention_time) const
bool contains(const MsRun *msrun_p) const
const std::shared_ptr< pappso::IonMobilityGrid > & getIonMobilityGridSp() const
virtual void computeIsotopologues(double ni_min_abundance)
compute possible isotopes for this molecule
pappso::XicCoordSPtr getBestXicCoord() const
void computeConsensusRetentionTime()
compute consensus retention time (on MS2 observations and MS1 peak measurements) the computation is b...
const QString & getMods() const
get optional information as text
void addObservedChargeState(std::uint8_t charge)
void populateIonMobilityGrid(pappso::IonMobilityGrid *ion_mobility_grid_p) const
Populate ion mobility grid with observed XIC coordinates for this peptide on all MSruns The ion mobil...
Peptide(const QString &id, const pappso::PeptideSp &peptide_sp, const std::vector< ProteinSp > &protein_list)
constructor
virtual void computeIsotopologues(double ni_min_abundance) override
compute possible isotopes for this molecule
void addMsRunXicCoordCharge(const MsRunXicCoordCharge &msrun_xic_coord)
bool isObservedInMsRunSp(const MsRun *msrun_p)
tell if this peptide is observed (MS2 fragmentation and identification) in this msrun
void setJsonLabelList(const QJsonObject &json_label_list)
build peptide label map from JSON label_list object
void setMods(const QString &mods)
set optional information as text to this peptide
const std::vector< std::uint8_t > & getAllObservedChargeStateList() const
PeptideLabel * getPeptideLabelPtr(const QString &label) const
get a peptide label pointer with the corresponding label identifier
const std::vector< ProteinSp > & getProteinSpList() const
const QString & getId() const
get peptide unique identifier
double getConsensusMs2RetentionTime() const
get consensus retention time based on MS2 fragmenation and identification events
pappso::XicCoordSPtr getBestXicCoordSPtrForChargeInMsRunGroup(const MsRunGroup *msrun_group_p, std::uint8_t charge) const
get the XIC coordinates of the higher observed intensity for this peptide and charge in other MS run ...
void setReferenceMsRunRetentionTimePtr(const pappso::MsRunRetentionTime< QString > *msrun_retention_time_reference_p)
sets the current msrun retention time reference
const std::map< QString, PeptideLabelSp > & getPeptideLabelMap() const
get the peptide label label_list
double getConsensusPeakRetentionTime() const
get consensus retention time based on XIC peak measurements
void addAlignedPeptideObservation(const PeptideObservation &peptide_observation, const pappso::MsRunRetentionTime< QString > &msrun_retention_time)
accumulate retention time information for MS2 observation convenient function used while collecting d...
void addAlignedPeakMeasurement(const PeptideMeasurements::Measurement &one_xic_measure, const pappso::MsRunRetentionTime< QString > &msrun_retention_time)
accumulate retention time information for MS1 peak measurement
pappso::XicCoordSPtr getBestIonMobilityXicCoordToExtractOverallMsRunGroup(const MsRunGroup &msrun_group, const pappso::MsRunId &targeted_msrun, std::uint8_t charge) const
get ion mobility coordinates corrected against other MSruns in the group
void addObservedInMsRunSp(const MsRunSp &msrun_sp)
std::shared_ptr< PeptideLabel > PeptideLabelSp
@ a
peak detected using a single direct MS2 observation
std::shared_ptr< MsRun > MsRunSp
std::shared_ptr< const Peptide > PeptideSp
double pappso_double
A type definition for doubles.
std::shared_ptr< XicCoord > XicCoordSPtr
pappso::TracePeakCstSPtr m_tracePeakSp
internal structure to compute consensus retention times
double alignedRetentionTime
double alignedRetentionTimeCenter
internal structure to store msrun + charge + intensity + xic coordinate