Loading...
Searching...
No Matches
pappso::AaStringCodec Class Reference

`#include <aastringcodec.h>`

## Public Member Functions

| AaStringCodec (const AaCode &aaCode)
| AaStringCodec (const AaStringCodec &other)
| ~AaStringCodec ()
std::size_t | getLimitMax (std::size_t size) const
| get the maximum code number for a given peptide size
uint32_t | code (const QString &aa_str) const
| get integer from amino acide suite string
uint32_t | codeLlc (const QString &aa_str) const
| get the lowest common denominator integer from amino acide suite string
uint32_t | codeLlc (std::vector< uint8_t >::const_iterator it_begin, std::size_t size) const
| get the lowest common denominator integer from amino acide code vector
QString | decode (uint32_t code) const
double | getMass (uint32_t code) const
std::vector< CodeToMass > | generateLlcCodeListUpToMaxPeptideSize (std::size_t size) const
| generates all possible combination of llc code mass llc : the lowest common code denominator for a given aa formula
std::vector< CodeToMass > | generateLlcCodeListByMaxPeptideSize (std::size_t size) const
| generates all possible combination of llc code mass llc : the lowest common code denominator for a given aa formula
bool | codeOnlyContains (uint32_t code, const std::vector< uint8_t > &aa_ok) const
const AaCode & | getAaCode () const

## Private Member Functions

void | recGenerateModel (std::vector< CodeToMass > &glist, std::vector< uint8_t > &model, std::size_t position) const
| recursive method to generate models
CodeToMass | generateCodeMassFromModel (const std::vector< uint8_t > &model) const

## Private Attributes

uint32_t | m_base = 0
const AaCode & | m_aaCode
std::vector< uint32_t > | m_units

## Detailed Description

Definition at line 51 of file aastringcodec.h.

## Constructor & Destructor Documentation

## AaStringCodec() [1/2]

AaStringCodec::AaStringCodec | ( | const AaCode & | aaCode | ) |

Default constructor

Definition at line 33 of file aastringcodec.cpp.

: m_aaCode(aaCode)
{
m_base = m_aaCode.getSize() + 1;
m_units.resize(10);
uint32_t unit = 1;
for(auto &this_unit : m_units)
{
this_unit = unit;
unit *= m_base;
}
}
pappso::AaCode::getSize
std::size_t getSize() const
Definition aacode.cpp:74
pappso::AaStringCodec::m_units
std::vector< uint32_t > m_units
Definition aastringcodec.h:131
pappso::AaStringCodec::m_base
uint32_t m_base
Definition aastringcodec.h:129
pappso::AaStringCodec::m_aaCode
const AaCode & m_aaCode
Definition aastringcodec.h:130

References pappso::AaCode::getSize(), m_aaCode, m_base, and m_units.

## AaStringCodec() [2/2]

AaStringCodec::AaStringCodec | ( | const AaStringCodec & | other | ) |

Copy constructor

Parameters

  other | TODO

Definition at line 46 of file aastringcodec.cpp.

: m_aaCode(other.m_aaCode)
{
m_base = other.m_base;
m_units = other.m_units;
}

References m_base, and m_units.

## ~AaStringCodec()

AaStringCodec::~AaStringCodec | ( |  | ) |

Destructor

Definition at line 53 of file aastringcodec.cpp.

{
}

## Member Function Documentation

## code()

uint32_t pappso::AaStringCodec::code | ( | const QString & | aa_str | ) | const

get integer from amino acide suite string

Definition at line 59 of file aastringcodec.cpp.

{
std::size_t pos = 0;
uint32_t code = 0;
for(auto &aa_char : aa_str)
{
code += m_aaCode.getAaCode(aa_char.toLatin1()) * m_units[pos];
pos++;
}
return code;
}
pappso::AaCode::getAaCode
uint8_t getAaCode(char aa_letter) const
Definition aacode.cpp:81
pappso::AaStringCodec::code
uint32_t code(const QString &aa_str) const
get integer from amino acide suite string
Definition aastringcodec.cpp:59

## codeLlc() [1/2]

uint32_t pappso::AaStringCodec::codeLlc | ( | const QString & | aa_str | ) | const

get the lowest common denominator integer from amino acide suite string

Definition at line 73 of file aastringcodec.cpp.

{
std::vector<uint8_t> llc_vec;
for(auto &aa_char : aa_str)
{
llc_vec.push_back(m_aaCode.getAaCode(aa_char.toLatin1()));
}
std::sort(llc_vec.begin(), llc_vec.end(), std::greater<uint8_t>());
std::size_t pos = 0;
uint32_t code = 0;
for(auto &aa_code : llc_vec)
{
code += (uint32_t)aa_code * m_units[pos];
pos++;
}
return code;
}

Referenced by pappso::ProteinIntegerCode::computePeptideCodeFragments().

## codeLlc() [2/2]

uint32_t pappso::AaStringCodec::codeLlc | ( | std::vector< uint8_t >::const_iterator | it_begin,
|  | std::size_t | size
| ) |  | const

get the lowest common denominator integer from amino acide code vector

Definition at line 95 of file aastringcodec.cpp.

{
std::vector<uint8_t> llc_vec;
for(std::size_t i = 0; i < size; i++)
{
llc_vec.push_back(*it_begin);
it_begin++;
}
std::sort(llc_vec.begin(), llc_vec.end(), std::greater<uint8_t>());
std::size_t pos = 0;
uint32_t code = 0;
for(auto &aa_code : llc_vec)
{
code += (uint32_t)aa_code * m_units[pos];
pos++;
}
return code;
}

## codeOnlyContains()

bool pappso::AaStringCodec::codeOnlyContains | ( | uint32_t | code,
|  | const std::vector< uint8_t > & | aa_ok
| ) |  | const

Definition at line 257 of file aastringcodec.cpp.

{
while(code > 0)
{
if(std::find(aa_ok.begin(), aa_ok.end(), (uint8_t)(code % m_base)) ==
aa_ok.end())
return false;
code /= m_base;
}
return true;
}

## decode()

QString pappso::AaStringCodec::decode | ( | uint32_t | code | ) | const

Definition at line 120 of file aastringcodec.cpp.

{
QString aa_suite;
while(code > 0)
{
aa_suite.append(m_aaCode.getAa((uint8_t)(code % m_base)).getLetter());
code /= m_base;
}
// qDebug() << aa_suite;
return aa_suite;
}
pappso::AaBase::getLetter
virtual const char & getLetter() const
Definition aabase.cpp:433
pappso::AaCode::getAa
const Aa & getAa(char aa_letter) const
Definition aacode.cpp:89

## generateCodeMassFromModel()

pappso::CodeToMass pappso::AaStringCodec::generateCodeMassFromModel | ( | const std::vector< uint8_t > & | model | ) | const

private

Definition at line 226 of file aastringcodec.cpp.

{
CodeToMass code_mass;
std::size_t pos = 0;
for(auto aacode : model)
{
code_mass.mass += m_aaCode.getMass(aacode);
code_mass.code += (uint32_t)aacode * m_units[pos];
pos++;
}
// qDebug() << code_mass.code << " " << code_mass.mass;
return code_mass;
}
pappso::AaCode::getMass
double getMass(uint8_t aa_code) const
Definition aacode.cpp:186
pappso::CodeToMass
Definition aastringcodec.h:44
pappso::CodeToMass::code
uint32_t code
Definition aastringcodec.h:45
pappso::CodeToMass::mass
double mass
Definition aastringcodec.h:46

References pappso::CodeToMass::code, and pappso::CodeToMass::mass.

## generateLlcCodeListByMaxPeptideSize()

std::vector< CodeToMass > pappso::AaStringCodec::generateLlcCodeListByMaxPeptideSize | ( | std::size_t | size | ) | const

generates all possible combination of llc code mass llc : the lowest common code denominator for a given aa formula

generate only for this peptide size

Definition at line 180 of file aastringcodec.cpp.

{
std::vector<CodeToMass> llc_list;
if(size == 0)
return llc_list;
std::vector<uint8_t> model;
model.resize(size, 0);
for(uint8_t i = 1; i < m_base; i++)
{
model[0] = i;
recGenerateModel(llc_list, model, 1);
}
return llc_list;
}
pappso::AaStringCodec::recGenerateModel
void recGenerateModel(std::vector< CodeToMass > &glist, std::vector< uint8_t > &model, std::size_t position) const
recursive method to generate models
Definition aastringcodec.cpp:198

## generateLlcCodeListUpToMaxPeptideSize()

std::vector< CodeToMass > pappso::AaStringCodec::generateLlcCodeListUpToMaxPeptideSize | ( | std::size_t | size | ) | const

generates all possible combination of llc code mass llc : the lowest common code denominator for a given aa formula

generate from peptide size =1 to peptide size

Definition at line 151 of file aastringcodec.cpp.

{
std::vector<CodeToMass> llc_list;
if(size == 0)
return llc_list;
std::vector<uint8_t> model;
for(uint8_t p = 1; p <= size; p++)
{
model.resize(p, 0);
for(uint8_t i = 1; i < m_base; i++)
{
model[0] = i;
if(p == 1)
{
llc_list.push_back(generateCodeMassFromModel(model));
}
else
{
recGenerateModel(llc_list, model, 1);
}
}
}
return llc_list;
}
pappso::AaStringCodec::generateCodeMassFromModel
CodeToMass generateCodeMassFromModel(const std::vector< uint8_t > &model) const
Definition aastringcodec.cpp:226

Referenced by pappso::AaStringCodeMassMatching::AaStringCodeMassMatching().

## getAaCode()

const pappso::AaCode & pappso::AaStringCodec::getAaCode | ( |  | ) | const

Definition at line 273 of file aastringcodec.cpp.

{
return m_aaCode;
}

Referenced by pappso::ProteinIntegerCode::ProteinIntegerCode().

## getLimitMax()

std::size_t pappso::AaStringCodec::getLimitMax | ( | std::size_t | size | ) | const

get the maximum code number for a given peptide size

Definition at line 245 of file aastringcodec.cpp.

{
std::size_t code = 0;
for(std::size_t pos = 0; pos < size; pos++)
{
code += (std::size_t)(m_base - 1) * (std::size_t)m_units[pos];
}
return code;
}

## getMass()

double pappso::AaStringCodec::getMass | ( | uint32_t | code | ) | const

Definition at line 136 of file aastringcodec.cpp.

{
double mass = 0;
while(code > 0)
{
mass += m_aaCode.getMass((uint8_t)(code % m_base));
code /= m_base;
}
return mass;
}

## recGenerateModel()

void pappso::AaStringCodec::recGenerateModel | ( | std::vector< CodeToMass > & | glist,
|  | std::vector< uint8_t > & | model,
|  | std::size_t | position
| ) |  | const

private

recursive method to generate models

Definition at line 198 of file aastringcodec.cpp.

{
if(position == model.size())
return;
if(position == model.size() - 1)
{
uint8_t max = model[position - 1];
for(uint8_t i = 1; i <= max; i++)
{
model[position] = i;
glist.push_back(generateCodeMassFromModel(model));
}
}
else
{
uint8_t max = model[position - 1];
for(uint8_t i = 1; i <= max; i++)
{
model[position] = i;
recGenerateModel(glist, model, position + 1);
}
}
}
pappso::XicExtractMethod::max
@ max
maximum of intensities

References pappso::max.

## Member Data Documentation

## m_aaCode

const AaCode& pappso::AaStringCodec::m_aaCode

private

Definition at line 130 of file aastringcodec.h.

Referenced by AaStringCodec().

## m_base

uint32_t pappso::AaStringCodec::m_base = 0

private

Definition at line 129 of file aastringcodec.h.

Referenced by AaStringCodec(), and AaStringCodec().

## m_units

std::vector<uint32_t> pappso::AaStringCodec::m_units

private

Definition at line 131 of file aastringcodec.h.

Referenced by AaStringCodec(), and AaStringCodec().

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

- pappsomspp/amino_acid/aastringcodec.h
- pappsomspp/amino_acid/aastringcodec.cpp