Loading...
Searching...
No Matches
pappso::cbor::psm::CborScanMapBase Class Reference

`#include <cborscanmapbase.h>`

Inheritance diagram for pappso::cbor::psm::CborScanMapBase:

## Public Member Functions

| CborScanMapBase (const PsmFileScanProcess &psm_file_scan_process)
virtual | ~CborScanMapBase ()
virtual void | process ()
virtual void | filterAndSortPsmList ()
void | filterPsmListUniqueUniqueProforma ()
std::vector< double >::iterator | addPsmEvalVectorDouble (const QString &eval_name, const QString &eval_value_key, std::vector< double >::iterator begin, std::vector< double >::const_iterator end)
| add a new eval key and double values (from a vector) to each PSM
QCborMap | getCborScanId () const
QCborMap | getCborScanPrecursor () const
QCborArray | getCborPsmList () const
void | populateProteinMapUsingOldProteinMap (const PsmProteinMap &old_protein_map, PsmProteinMap &new_protein_map) const

## Protected Member Functions

pappso::QualifiedMassSpectrumSPtr | getCurrentQualifiedMassSpectrumSPtr () const

## Protected Attributes

const PsmFileScanProcess & | m_PsmFileScanProcess

## Detailed Description

Todo
  write docs

Definition at line 47 of file cborscanmapbase.h.

## Constructor & Destructor Documentation

## CborScanMapBase()

pappso::cbor::psm::CborScanMapBase::CborScanMapBase | ( | const PsmFileScanProcess & | psm_file_scan_process | ) |

Default constructor

Definition at line 40 of file cborscanmapbase.cpp.

: m_PsmFileScanProcess(psm_file_scan_process)
{
}
pappso::cbor::psm::CborScanMapBase::m_PsmFileScanProcess
const PsmFileScanProcess & m_PsmFileScanProcess
Definition cborscanmapbase.h:85

References m_PsmFileScanProcess.

Referenced by pappso::cbor::psm::PsmFeaturesScan::PsmFeaturesScan(), pappso::cbor::psm::PsmIonSeriesScan::PsmIonSeriesScan(), pappso::cbor::psm::PsmSpecGlobScan::PsmSpecGlobScan(), and pappso::cbor::psm::PsmSpecPeptidOmsScan::PsmSpecPeptidOmsScan().

## ~CborScanMapBase()

pappso::cbor::psm::CborScanMapBase::~CborScanMapBase | ( |  | ) |

virtual

Destructor

Definition at line 45 of file cborscanmapbase.cpp.

{
}

## Member Function Documentation

## addPsmEvalVectorDouble()

std::vector< double >::iterator pappso::cbor::psm::CborScanMapBase::addPsmEvalVectorDouble | ( | const QString & | eval_name,
|  | const QString & | eval_value_key,
|  | std::vector< double >::iterator | begin,
|  | std::vector< double >::const_iterator | end )

add a new eval key and double values (from a vector) to each PSM

Definition at line 86 of file cborscanmapbase.cpp.

{
std::vector<double>::iterator it = itbegin;
if(keys().contains("psm_list"))
{
QCborArray new_psm_arr;
for(QCborValue cbor_psm : value("psm_list").toArray())
{
QCborMap cbor_psm_map = cbor_psm.toMap();
if(!cbor_psm_map.keys().contains("proforma"))
{
throw pappso::PappsoException(
QObject::tr("missing proforma in psm %1").arg(cbor_psm_map.keys().size()));
}
QCborMap cbor_psm_eval_newvalues;
if(it == itend)
{
throw pappso::PappsoException(
QObject::tr("no more values to add in psm %1").arg(cbor_psm_map.keys().size()));
}
cbor_psm_eval_newvalues.insert(eval_value_key, *it);
it++;
QCborMap psm_eval = cbor_psm_map.value("eval").toMap();
psm_eval.remove(eval_name);
psm_eval.insert(eval_name, cbor_psm_eval_newvalues);
cbor_psm_map.remove(QString("eval"));
cbor_psm_map.insert(QString("eval"), psm_eval);
new_psm_arr.push_back(cbor_psm_map);
}
// insert(QString("psm_list"), new_psm_arr);
remove(QString("psm_list"));
insert(QString("psm_list"), new_psm_arr);
}
return it;
}

Referenced by pappso::cbor::psm::PsmNewEval::newCborScanMap().

## filterAndSortPsmList()

void pappso::cbor::psm::CborScanMapBase::filterAndSortPsmList | ( |  | ) |

virtual

Reimplemented in pappso::cbor::psm::PsmSpecPeptidOmsScan.

Definition at line 261 of file cborscanmapbase.cpp.

{
// cbor_writer.writeCborMap(*this);
}

## filterPsmListUniqueUniqueProforma()

void pappso::cbor::psm::CborScanMapBase::filterPsmListUniqueUniqueProforma | ( |  | ) |

Definition at line 268 of file cborscanmapbase.cpp.

{
struct uniquePsmResult
{
QString proforma;
QCborMap psm;
};
QCborArray old_psm_arr = value("psm_list").toArray();
QCborArray new_psm_arr;
// for(QCborValue cbor_psm : old_psm_arr) {
std::vector<uniquePsmResult> all_psm_list;
for(auto it_psm : old_psm_arr)
{
QCborMap psm_map = it_psm.toMap();
all_psm_list.push_back({psm_map.value("proforma").toString(), psm_map});
}
qDebug();
std::sort(all_psm_list.begin(), all_psm_list.end(), [](uniquePsmResult &a, uniquePsmResult &b) {
return a.proforma > b.proforma;
});
qDebug();
std::vector<uniquePsmResult> unique_psm_list;
for(auto it = all_psm_list.begin(); it != all_psm_list.end(); it++)
{
qDebug() << it->proforma;
if(unique_psm_list.size() > 0)
{
if(unique_psm_list.back().proforma == it->proforma)
{
// merge ?
PsmCborUtils::mergePsmProteinRefList(unique_psm_list.back().psm, it->psm);
}
else
{
unique_psm_list.push_back(*it);
}
}
else
{
unique_psm_list.push_back(*it);
}
qDebug();
}
qDebug() << unique_psm_list.size();
for(auto it = unique_psm_list.begin(); it != unique_psm_list.end(); it++)
{
new_psm_arr.append(it->psm);
qDebug();
}
// qWarning() << new_psm_arr.size();
remove(QString("psm_list"));
insert(QString("psm_list"), new_psm_arr);
}
pappso::cbor::psm::PsmCborUtils::mergePsmProteinRefList
static void mergePsmProteinRefList(QCborMap &cbor_psm_destination, const QCborMap &cbor_psm_source)
Definition psmcborutils.cpp:150
pappso::PeptideIonNter::a
@ a
Definition peptide.h:77
pappso::PeptideIonNter::b
@ b
Definition peptide.h:74

References pappso::a, pappso::b, and pappso::cbor::psm::PsmCborUtils::mergePsmProteinRefList().

Referenced by pappso::cbor::psm::PsmSpecGlobScan::process(), and pappso::cbor::psm::PsmSpecPeptidOmsScan::process().

## getCborPsmList()

QCborArray pappso::cbor::psm::CborScanMapBase::getCborPsmList | ( |  | ) | const

Definition at line 75 of file cborscanmapbase.cpp.

{
if(!keys().contains("psm_list"))
{
throw pappso::PappsoException(QObject::tr("missing psm_list in scan"));
}
return value("psm_list").toArray();
}

## getCborScanId()

QCborMap pappso::cbor::psm::CborScanMapBase::getCborScanId | ( |  | ) | const

Definition at line 55 of file cborscanmapbase.cpp.

{
if(!keys().contains("id"))
{
throw pappso::PappsoException(QObject::tr("missing id in scan"));
}
return value("id").toMap();
}

## getCborScanPrecursor()

QCborMap pappso::cbor::psm::CborScanMapBase::getCborScanPrecursor | ( |  | ) | const

Definition at line 65 of file cborscanmapbase.cpp.

{
if(!keys().contains("precursor"))
{
throw pappso::PappsoException(QObject::tr("missing precursor in scan"));
}
return value("precursor").toMap();
}

## getCurrentQualifiedMassSpectrumSPtr()

pappso::QualifiedMassSpectrumSPtr pappso::cbor::psm::CborScanMapBase::getCurrentQualifiedMassSpectrumSPtr | ( |  | ) | const

protected

Definition at line 136 of file cborscanmapbase.cpp.

{
if(isEmpty())
{
throw pappso::PappsoException(QObject::tr("ERROR: cbor scan map is empty"));
}
if(!contains(QString("precursor")))
{
throw pappso::PappsoException(QObject::tr("ERROR: no precursor in scan"));
}
const QCborMap cbor_precursor(value("precursor").toMap());
if(!contains(QString("ms2")))
{
throw pappso::PappsoException(QObject::tr("ERROR: ms2 is empty in scan"));
}
const QCborMap cbor_ms2(value("ms2").toMap());
if(!contains(QString("id")))
{
throw pappso::PappsoException(QObject::tr("ERROR: id is empty in scan"));
}
const QCborMap cbor_id(value("id").toMap());
if(!cbor_id.keys().contains("index"))
{
throw pappso::PappsoException("There is no scan index");
}
if(!cbor_ms2.keys().contains("spectrum"))
{
throw pappso::PappsoException("There is no spectrum in ms2");
}
const QCborMap cbor_spectrum(cbor_ms2.value("spectrum").toMap());
if(!cbor_spectrum.keys().contains("mz"))
{
throw pappso::PappsoException("There is no cbor_spectrum mz values");
}
if(!cbor_spectrum.keys().contains("intensity"))
{
throw pappso::PappsoException("There is no cbor_spectrum intensity values");
}
pappso::MsRunId msrun_id(m_PsmFileScanProcess.m_currentPeaklistFile.name);
msrun_id.setSampleName(m_PsmFileScanProcess.m_currentSampleName);
pappso::MsRunIdCstSPtr msrun_id_sp = std::make_shared<const pappso::MsRunId>(msrun_id);
pappso::MassSpectrumId ms_id(msrun_id_sp);
ms_id.setSpectrumIndex(cbor_id.value("index").toInteger());
// native_id
if(cbor_id.keys().contains("native_id"))
{
ms_id.setNativeId(cbor_id.value("native_id").toString());
}
std::vector<DataPoint> data_point_vector;
std::size_t i = 0;
for(auto cbor_mz_value : cbor_spectrum.value("mz").toArray())
{
data_point_vector.push_back(
{cbor_mz_value.toDouble(), cbor_spectrum.value("intensity").toArray().at(i).toDouble()});
i++;
}
MassSpectrum mass_spectrum(data_point_vector);
pappso::PrecursorIonData precursor_ion_data;
pappso::QualifiedMassSpectrum qualified_mass_spectrum(ms_id);
qualified_mass_spectrum.setMassSpectrumSPtr(mass_spectrum.makeMassSpectrumSPtr());
qualified_mass_spectrum.setMsLevel(2);
if(cbor_precursor.keys().contains("z"))
{
precursor_ion_data.charge = cbor_precursor.value("z").toInteger();
}
if(cbor_precursor.keys().contains("mz"))
{
precursor_ion_data.mz = cbor_precursor.value("mz").toDouble();
}
if(cbor_precursor.keys().contains("intensity"))
{
precursor_ion_data.intensity = cbor_precursor.value("intensity").toDouble();
}
qualified_mass_spectrum.appendPrecursorIonData(precursor_ion_data);
if(cbor_ms2.keys().contains("rt"))
{
qualified_mass_spectrum.setRtInSeconds(cbor_ms2.value("rt").toDouble());
}
return qualified_mass_spectrum.makeQualifiedMassSpectrumSPtr();
}
pappso::MsRunIdCstSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr
Definition msrunid.h:46
pappso::PrecursorIonData::mz
double mz
Definition qualifiedmassspectrum.h:76
pappso::PrecursorIonData::intensity
double intensity
Definition qualifiedmassspectrum.h:78
pappso::PrecursorIonData::charge
int charge
Definition qualifiedmassspectrum.h:77

References pappso::QualifiedMassSpectrum::appendPrecursorIonData(), pappso::PrecursorIonData::charge, pappso::PrecursorIonData::intensity, m_PsmFileScanProcess, pappso::MassSpectrum::makeMassSpectrumSPtr(), pappso::QualifiedMassSpectrum::makeQualifiedMassSpectrumSPtr(), pappso::PrecursorIonData::mz, pappso::QualifiedMassSpectrum::setMassSpectrumSPtr(), pappso::QualifiedMassSpectrum::setMsLevel(), pappso::MassSpectrumId::setNativeId(), pappso::QualifiedMassSpectrum::setRtInSeconds(), pappso::MsRunId::setSampleName(), and pappso::MassSpectrumId::setSpectrumIndex().

Referenced by pappso::cbor::psm::PsmFeaturesScan::process(), pappso::cbor::psm::PsmIonSeriesScan::process(), pappso::cbor::psm::PsmSpecGlobScan::process(), and pappso::cbor::psm::PsmSpecPeptidOmsScan::process().

## populateProteinMapUsingOldProteinMap()

void pappso::cbor::psm::CborScanMapBase::populateProteinMapUsingOldProteinMap | ( | const PsmProteinMap & | old_protein_map,
|  | PsmProteinMap & | new_protein_map ) const

Definition at line 230 of file cborscanmapbase.cpp.

{
if(isEmpty())
{
throw pappso::PappsoException(QObject::tr("ERROR: cbor scan map is empty"));
}
if(!contains(QString("psm_list")))
{
throw pappso::PappsoException(QObject::tr("ERROR: no psm_list in scan"));
}
for(auto it_psm : value("psm_list").toArray())
{
QCborMap psm = it_psm.toMap();
if(!psm.contains(QString("protein_list")))
{
throw pappso::PappsoException(
QObject::tr("ERROR: no protein_list in psm, psm_list in scan"));
}
for(auto it_protein : psm.value("protein_list").toArray())
{
new_protein_map.insert(
old_protein_map.getByAccession(it_protein.toMap().value("accession").toString()));
}
}
}

References pappso::cbor::psm::PsmProteinMap::getByAccession(), and pappso::cbor::psm::PsmProteinMap::insert().

## process()

void pappso::cbor::psm::CborScanMapBase::process | ( |  | ) |

virtual

Reimplemented in pappso::cbor::psm::PsmFeaturesScan, pappso::cbor::psm::PsmIonSeriesScan, pappso::cbor::psm::PsmSpecGlobScan, and pappso::cbor::psm::PsmSpecPeptidOmsScan.

Definition at line 50 of file cborscanmapbase.cpp.

{
}

## Member Data Documentation

## m_PsmFileScanProcess

const PsmFileScanProcess& pappso::cbor::psm::CborScanMapBase::m_PsmFileScanProcess

protected

Definition at line 85 of file cborscanmapbase.h.

Referenced by CborScanMapBase(), and getCurrentQualifiedMassSpectrumSPtr().

The documentation for this class was generated from the following files:

- pappsomspp/core/processing/cbor/psm/cborscanmapbase.h
- pappsomspp/core/processing/cbor/psm/cborscanmapbase.cpp