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

utilities to help managing data in PSM CBOR data file More...

`#include <psmcborutils.h>`

## Classes

struct | PsmProteinRef

## Static Public Member Functions

static void | prepareCborScanWithSpectrum (QCborMap &cbor_scan, const pappso::QualifiedMassSpectrum &ms2_qualified_mass_spectrum)
static void | prepareCborScanWithSpectrumAndPeakList (QCborMap &cbor_scan, const pappso::QualifiedMassSpectrum &ms2_qualified_mass_spectrum)
static std::vector< PsmProteinRef > | getPsmProteinRefList (const QCborMap &cbor_psm)
static void | setPsmProteinRefList (QCborMap &cbor_psm, const std::vector< PsmProteinRef > &protein_ref_list)
static void | mergePsmProteinRefList (QCborMap &cbor_psm_destination, const QCborMap &cbor_psm_source)

## Detailed Description

utilities to help managing data in PSM CBOR data file

Definition at line 44 of file psmcborutils.h.

## Member Function Documentation

## getPsmProteinRefList()

std::vector< PsmCborUtils::PsmProteinRef > pappso::cbor::psm::PsmCborUtils::getPsmProteinRefList | ( | const QCborMap & | cbor_psm | ) |

static

Definition at line 101 of file psmcborutils.cpp.

{
std::vector<PsmCborUtils::PsmProteinRef> protein_ref_list;
if(cbor_psm.contains(QString("protein_list")))
{
for(auto it : cbor_psm.value("protein_list").toArray())
{
QCborMap cbor_protein_ref = it.toMap();
PsmCborUtils::PsmProteinRef protein_ref;
protein_ref.accession = cbor_protein_ref.value("accession").toString();
for(auto ref_position : cbor_protein_ref.value("positions").toArray())
{
protein_ref.positions.push_back(ref_position.toInteger());
}
protein_ref_list.push_back(protein_ref);
}
}
return protein_ref_list;
}

References pappso::cbor::psm::PsmCborUtils::PsmProteinRef::accession, and pappso::cbor::psm::PsmCborUtils::PsmProteinRef::positions.

Referenced by mergePsmProteinRefList().

## mergePsmProteinRefList()

void pappso::cbor::psm::PsmCborUtils::mergePsmProteinRefList | ( | QCborMap & | cbor_psm_destination,
|  | const QCborMap & | cbor_psm_source )

static

Definition at line 150 of file psmcborutils.cpp.

{
std::vector<PsmCborUtils::PsmProteinRef> protein_ref_list =
getPsmProteinRefList(cbor_psm_destination);
std::vector<PsmCborUtils::PsmProteinRef> protein_ref_list_source =
getPsmProteinRefList(cbor_psm_source);
protein_ref_list.insert(
protein_ref_list.end(), protein_ref_list_source.begin(), protein_ref_list_source.end());
std::sort(protein_ref_list.begin(),
protein_ref_list.end(),
[](PsmCborUtils::PsmProteinRef &a, PsmCborUtils::PsmProteinRef &b) {
return a.accession > b.accession;
});
std::vector<PsmCborUtils::PsmProteinRef> unique_protein_ref_list;
for(auto it = protein_ref_list.begin(); it != protein_ref_list.end(); it++)
{
// qDebug() << it->proforma;
if(unique_protein_ref_list.size() > 0)
{
if(unique_protein_ref_list.back().accession == it->accession)
{
// merge positions
unique_protein_ref_list.back().positions.insert(
unique_protein_ref_list.back().positions.end(),
it->positions.begin(),
it->positions.end());
std::sort(unique_protein_ref_list.back().positions.begin(),
unique_protein_ref_list.back().positions.end());
auto last = std::unique(unique_protein_ref_list.back().positions.begin(),
unique_protein_ref_list.back().positions.end());
// v now holds {1 2 3 4 5 x x}, where 'x' is indeterminate
unique_protein_ref_list.back().positions.erase(
last, unique_protein_ref_list.back().positions.end());
}
else
{
unique_protein_ref_list.push_back(*it);
}
}
else
{
unique_protein_ref_list.push_back(*it);
}
qDebug();
}
setPsmProteinRefList(cbor_psm_destination, unique_protein_ref_list);
}
pappso::cbor::psm::PsmCborUtils::setPsmProteinRefList
static void setPsmProteinRefList(QCborMap &cbor_psm, const std::vector< PsmProteinRef > &protein_ref_list)
Definition psmcborutils.cpp:126
pappso::cbor::psm::PsmCborUtils::getPsmProteinRefList
static std::vector< PsmProteinRef > getPsmProteinRefList(const QCborMap &cbor_psm)
Definition psmcborutils.cpp:101
pappso::PeptideIonNter::a
@ a
Definition peptide.h:77
pappso::PeptideIonNter::b
@ b
Definition peptide.h:74
pappso::QualifiedMassSpectrumParameter::last
@ last
Definition qualifiedmassspectrum.h:71

References pappso::a, pappso::b, getPsmProteinRefList(), pappso::last, and setPsmProteinRefList().

Referenced by pappso::cbor::psm::CborScanMapBase::filterPsmListUniqueUniqueProforma().

## prepareCborScanWithSpectrum()

void pappso::cbor::psm::PsmCborUtils::prepareCborScanWithSpectrum | ( | QCborMap & | cbor_scan,
|  | const pappso::QualifiedMassSpectrum & | ms2_qualified_mass_spectrum )

static

Definition at line 40 of file psmcborutils.cpp.

{
// id
QCborMap cbor_scan_id;
cbor_scan_id.insert(QString("index"),
(qint64)ms2_qualified_mass_spectrum.getMassSpectrumId().getSpectrumIndex());
cbor_scan_id.insert(QString("native_id"),
ms2_qualified_mass_spectrum.getMassSpectrumId().getNativeId());
bool is_ok;
std::size_t scan =
ms2_qualified_mass_spectrum.getMassSpectrumId().extractScanNumberFromNativeId(&is_ok);
if(is_ok)
{
cbor_scan_id.insert(QString("scan"), (qint64)scan);
}
cbor_scan.insert(QString("id"), cbor_scan_id.toCborValue());
// precursor
QCborMap cbor_scan_precursor;
cbor_scan_precursor.insert(QString("z"), ms2_qualified_mass_spectrum.getPrecursorCharge());
cbor_scan_precursor.insert(QString("mz"), ms2_qualified_mass_spectrum.getPrecursorMz());
cbor_scan_precursor.insert(QString("mh"), ms2_qualified_mass_spectrum.getPrecursorMass());
cbor_scan_precursor.insert(QString("intensity"),
ms2_qualified_mass_spectrum.getPrecursorIntensity());
cbor_scan.insert(QString("precursor"), cbor_scan_precursor.toCborValue());
// ms2
QCborMap cbor_scan_ms2;
cbor_scan_ms2.insert(QString("rt"), ms2_qualified_mass_spectrum.getRtInSeconds());
cbor_scan.insert(QString("ms2"), cbor_scan_ms2.toCborValue());
}
pappso::MassSpectrumId::getSpectrumIndex
std::size_t getSpectrumIndex() const
Definition massspectrumid.cpp:113
pappso::MassSpectrumId::getNativeId
const QString & getNativeId() const
Definition massspectrumid.cpp:99
pappso::MassSpectrumId::extractScanNumberFromNativeId
std::size_t extractScanNumberFromNativeId(bool *is_ok) const
try to find scan id in the native id string
Definition massspectrumid.cpp:145
pappso::QualifiedMassSpectrum::getPrecursorCharge
uint getPrecursorCharge(bool *ok=nullptr) const
get precursor charge
Definition qualifiedmassspectrum.cpp:336
pappso::QualifiedMassSpectrum::getPrecursorIntensity
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
get precursor intensity
Definition qualifiedmassspectrum.cpp:396
pappso::QualifiedMassSpectrum::getPrecursorMass
double getPrecursorMass(bool *ok_p=nullptr) const
get precursor mass given the charge stats and precursor mz
Definition qualifiedmassspectrum.cpp:260
pappso::QualifiedMassSpectrum::getMassSpectrumId
const MassSpectrumId & getMassSpectrumId() const
Get the MassSpectrumId.
Definition qualifiedmassspectrum.cpp:154
pappso::QualifiedMassSpectrum::getPrecursorMz
pappso_double getPrecursorMz(bool *ok=nullptr) const
get precursor mz
Definition qualifiedmassspectrum.cpp:240
pappso::QualifiedMassSpectrum::getRtInSeconds
pappso_double getRtInSeconds() const
Get the retention time in seconds.
Definition qualifiedmassspectrum.cpp:205

References pappso::MassSpectrumId::extractScanNumberFromNativeId(), pappso::QualifiedMassSpectrum::getMassSpectrumId(), pappso::MassSpectrumId::getNativeId(), pappso::QualifiedMassSpectrum::getPrecursorCharge(), pappso::QualifiedMassSpectrum::getPrecursorIntensity(), pappso::QualifiedMassSpectrum::getPrecursorMass(), pappso::QualifiedMassSpectrum::getPrecursorMz(), pappso::QualifiedMassSpectrum::getRtInSeconds(), and pappso::MassSpectrumId::getSpectrumIndex().

Referenced by prepareCborScanWithSpectrumAndPeakList().

## prepareCborScanWithSpectrumAndPeakList()

void pappso::cbor::psm::PsmCborUtils::prepareCborScanWithSpectrumAndPeakList | ( | QCborMap & | cbor_scan,
|  | const pappso::QualifiedMassSpectrum & | ms2_qualified_mass_spectrum )

static

Definition at line 76 of file psmcborutils.cpp.

{
prepareCborScanWithSpectrum(cbor_scan, ms2_qualified_mass_spectrum);
QCborMap spectrum_cbor;
QCborArray mz_cbor;
QCborArray intensity_cbor;
for(const pappso::DataPoint &data_point :
*(ms2_qualified_mass_spectrum.getMassSpectrumCstSPtr().get()))
{
mz_cbor.append(data_point.x);
intensity_cbor.append(data_point.y);
}
spectrum_cbor.insert(QString("mz"), mz_cbor);
spectrum_cbor.insert(QString("intensity"), intensity_cbor);
QCborMap new_ms2_map = cbor_scan.value("ms2").toMap();
new_ms2_map.insert(QString("spectrum"), spectrum_cbor.toCborValue());
cbor_scan.insert(QString("ms2"), new_ms2_map);
}
pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr
MassSpectrumCstSPtr getMassSpectrumCstSPtr() const
Get the MassSpectrumCstSPtr.
Definition qualifiedmassspectrum.cpp:138
pappso::cbor::psm::PsmCborUtils::prepareCborScanWithSpectrum
static void prepareCborScanWithSpectrum(QCborMap &cbor_scan, const pappso::QualifiedMassSpectrum &ms2_qualified_mass_spectrum)
Definition psmcborutils.cpp:40

References pappso::QualifiedMassSpectrum::getMassSpectrumCstSPtr(), and prepareCborScanWithSpectrum().

## setPsmProteinRefList()

void pappso::cbor::psm::PsmCborUtils::setPsmProteinRefList | ( | QCborMap & | cbor_psm,
|  | const std::vector< PsmProteinRef > & | protein_ref_list )

static

Definition at line 126 of file psmcborutils.cpp.

{
QCborArray protein_list;
for(auto it : protein_ref_list)
{
QCborMap protein_ref;
protein_ref.insert(QString("accession"), it.accession);
QCborArray positions_arr;
for(auto position : it.positions)
{
positions_arr.append((qint64)position);
}
protein_ref.insert(QString("positions"), positions_arr);
protein_list.append(protein_ref);
}
cbor_psm.remove(QString("protein_list"));
cbor_psm.insert(QString("protein_list"), protein_list);
}

Referenced by mergePsmProteinRefList().

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

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