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

store PsmProtein in a map with accession as key More...

`#include <psmproteinmap.h>`

## Public Member Functions

| PsmProteinMap ()
virtual | ~PsmProteinMap ()
std::pair< std::map< QString, PsmProtein >::iterator, bool > | insert (const PsmProtein &psm_protein)
| standard map insert of a PsmProtein (accession is the key)
void | writeMap (CborStreamWriter &writer) const
| writes the protein map in a cbor output stream this output a CborMap structure directly in the output stream
void | readMap (CborStreamReader &reader)
| reads the protein map from a cbor input stream
std::size_t | size () const
| get protein map size
const pappso::cbor::psm::PsmProtein & | getByAccession (const QString &accession) const
| retrieve a PsmProtein with its accession
void | merge (const PsmProteinMap &other_protein_map)
| merge with other protein map
void | reduce (const QStringList &accession_list)
| reduce to protein accessions listed in input
std::map< QString, PsmProtein > & | getProteinMap ()

## Private Attributes

std::map< QString, PsmProtein > | m_proteinMap

## Detailed Description

store PsmProtein in a map with accession as key

Definition at line 55 of file psmproteinmap.h.

## Constructor & Destructor Documentation

## PsmProteinMap()

pappso::cbor::psm::PsmProteinMap::PsmProteinMap | ( |  | ) |

Default constructor

Definition at line 33 of file psmproteinmap.cpp.

{
}

Referenced by merge().

## ~PsmProteinMap()

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

virtual

Destructor

Definition at line 37 of file psmproteinmap.cpp.

{
}

## Member Function Documentation

## getByAccession()

const pappso::cbor::psm::PsmProtein & pappso::cbor::psm::PsmProteinMap::getByAccession | ( | const QString & | accession | ) | const

retrieve a PsmProtein with its accession

Returns
  PsmProtein const reference

Definition at line 164 of file psmproteinmap.cpp.

{
auto it = m_proteinMap.find(accession);
if(it == m_proteinMap.end())
{
throw pappso::ExceptionNotFound(QObject::tr("%1 accession not found").arg(accession));
}
return it->second;
}
pappso::cbor::psm::PsmProteinMap::m_proteinMap
std::map< QString, PsmProtein > m_proteinMap
Definition psmproteinmap.h:111

References m_proteinMap.

Referenced by pappso::cbor::psm::CborScanMapBase::populateProteinMapUsingOldProteinMap(), and reduce().

## getProteinMap()

std::map< QString, pappso::cbor::psm::PsmProtein > & pappso::cbor::psm::PsmProteinMap::getProteinMap | ( |  | ) |

Definition at line 43 of file psmproteinmap.cpp.

{
return m_proteinMap;
}

References m_proteinMap.

## insert()

std::pair< std::map< QString, pappso::cbor::psm::PsmProtein >::iterator, bool > pappso::cbor::psm::PsmProteinMap::insert | ( | const PsmProtein & | psm_protein | ) |

standard map insert of a PsmProtein (accession is the key)

Returns
  standard C++ insert iterator on a map

Definition at line 50 of file psmproteinmap.cpp.

{
return m_proteinMap.insert(
std::pair<QString, PsmProtein>(psm_protein.protein_sp.get()->getAccession(), psm_protein));
}

References m_proteinMap, and pappso::cbor::psm::PsmProtein::protein_sp.

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

## merge()

void pappso::cbor::psm::PsmProteinMap::merge | ( | const PsmProteinMap & | other_protein_map | ) |

merge with other protein map

Definition at line 176 of file psmproteinmap.cpp.

{
for(auto &it_prot : other_protein_map.m_proteinMap)
{
m_proteinMap.insert(std::pair<QString, PsmProtein>(it_prot.first, it_prot.second));
}
}

References PsmProteinMap(), and m_proteinMap.

## readMap()

void pappso::cbor::psm::PsmProteinMap::readMap | ( | CborStreamReader & | reader | ) |

reads the protein map from a cbor input stream

Parameters

  reader | the cbor intput stream

Definition at line 88 of file psmproteinmap.cpp.

{
PsmProtein psm_protein;
reader.enterContainer();
while(!reader.lastError() && reader.hasNext())
{
bool is_ok;
QString accession;
is_ok = reader.decodeString(accession);
qDebug() << accession;
if(is_ok)
{
reader.enterContainer();
pappso::Protein protein;
protein.setAccession(accession);
psm_protein.protein_sp = std::make_shared<pappso::Protein>(protein);
psm_protein.isContaminant = false;
psm_protein.isTarget = true;
auto it = m_proteinMap.insert(std::pair<QString, PsmProtein>(accession, psm_protein));
QString tag;
while(!reader.lastError() && reader.hasNext())
{
is_ok = reader.decodeString(tag);
qDebug() << tag;
if(is_ok)
{
if(tag == "description")
{
QString description;
is_ok = reader.decodeString(description);
qDebug() << description;
it.first->second.protein_sp.get()->setDescription(description);
}
else if(tag == "sequence")
{
QString sequence;
reader.decodeString(sequence);
it.first->second.protein_sp.get()->setSequence(sequence);
}
else if(tag == "target")
{
it.first->second.isTarget = reader.toBool();
reader.next();
}
else if(tag == "contaminant")
{
it.first->second.isContaminant = reader.toBool();
reader.next();
}
else if(tag == "eval")
{
reader.readCborMap(it.first->second.cborEval);
}
}
}
reader.leaveContainer();
}
else
{
// no accession
}
// reader.next();
// }
}
reader.leaveContainer();
}
pappso::Protein::setAccession
virtual void setAccession(const QString &accession)
Definition protein.cpp:132

References pappso::cbor::CborStreamReader::decodeString(), pappso::cbor::psm::PsmProtein::isContaminant, pappso::cbor::psm::PsmProtein::isTarget, m_proteinMap, pappso::cbor::psm::PsmProtein::protein_sp, pappso::cbor::CborStreamReader::readCborMap(), and pappso::Protein::setAccession().

## reduce()

void pappso::cbor::psm::PsmProteinMap::reduce | ( | const QStringList & | accession_list | ) |

reduce to protein accessions listed in input

Definition at line 185 of file psmproteinmap.cpp.

{
std::map<QString, PsmProtein> new_protein_map;
for(const QString &accession : accession_list)
{
new_protein_map.insert(std::pair<QString, PsmProtein>(accession, getByAccession(accession)));
}
m_proteinMap = new_protein_map;
}
pappso::cbor::psm::PsmProteinMap::getByAccession
const pappso::cbor::psm::PsmProtein & getByAccession(const QString &accession) const
retrieve a PsmProtein with its accession
Definition psmproteinmap.cpp:164

References getByAccession(), and m_proteinMap.

## size()

std::size_t pappso::cbor::psm::PsmProteinMap::size | ( |  | ) | const

get protein map size

Definition at line 158 of file psmproteinmap.cpp.

{
return m_proteinMap.size();
}

References m_proteinMap.

## writeMap()

void pappso::cbor::psm::PsmProteinMap::writeMap | ( | CborStreamWriter & | writer | ) | const

writes the protein map in a cbor output stream this output a CborMap structure directly in the output stream

Parameters

  writer | the cbor output stream

Definition at line 57 of file psmproteinmap.cpp.

{
// writer.append("protein_map");
writer.startMap(m_proteinMap.size()); // protein map
for(auto &protein_pair : m_proteinMap)
{
writer.append(protein_pair.first);
qDebug() << protein_pair.first;
writer.startMap(); // protein
writer.append("description");
writer.append(protein_pair.second.protein_sp.get()->getDescription());
writer.append("sequence");
writer.append(protein_pair.second.protein_sp.get()->getSequence());
writer.append("target");
writer.append(protein_pair.second.isTarget);
writer.append("contaminant");
writer.append(protein_pair.second.isContaminant);
if(!protein_pair.second.cborEval.isEmpty())
{
writer.append("eval");
writer.writeCborMap(protein_pair.second.cborEval);
}
writer.endMap(); // protein
}
writer.endMap(); // protein map
}

References m_proteinMap, and pappso::cbor::CborStreamWriter::writeCborMap().

## Member Data Documentation

## m_proteinMap

std::map<QString, PsmProtein> pappso::cbor::psm::PsmProteinMap::m_proteinMap

private

Definition at line 111 of file psmproteinmap.h.

Referenced by getByAccession(), getProteinMap(), insert(), merge(), readMap(), reduce(), size(), and writeMap().

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

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