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

code and decode amino acid string sequence to unique integer More...

`#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
QStringList | decode (const std::vector< uint32_t > &code_list) 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
| tell if a code only contains a list of amino acid
bool | uniqueCodeContainsAminoAcid (uint32_t code, uint8_t aa_ok, int times) const
| tell if a unique code only contains one amino acid 1 or n times
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

code and decode amino acid string sequence to unique integer

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::AaStringCodec::m_units
std::vector< uint32_t > m_units
Definition aastringcodec.h:148
pappso::AaStringCodec::m_base
uint32_t m_base
Definition aastringcodec.h:146
pappso::AaStringCodec::m_aaCode
const AaCode & m_aaCode
Definition aastringcodec.h:147

References m_aaCode, m_base, and m_units.

Referenced by AaStringCodec().

## 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 AaStringCodec(), m_aaCode, m_base, and m_units.

## ~AaStringCodec()

AaStringCodec::~AaStringCodec | ( |  | ) |

Destructor

Definition at line 52 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 58 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::AaStringCodec::code
uint32_t code(const QString &aa_str) const
get integer from amino acide suite string
Definition aastringcodec.cpp:58

References code(), m_aaCode, and m_units.

Referenced by code(), codeLlc(), codeLlc(), codeOnlyContains(), decode(), decode(), getLimitMax(), getMass(), and uniqueCodeContainsAminoAcid().

## 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 72 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;
}

References code(), m_aaCode, and m_units.

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 94 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;
}

References code(), and m_units.

## codeOnlyContains()

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

tell if a code only contains a list of amino acid

Parameters

  code | the code to valid
  aa_ok | list of required amino acids

Definition at line 265 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;
}

References code(), and m_base.

## decode() [1/2]

QStringList pappso::AaStringCodec::decode | ( | const std::vector< uint32_t > & | code_list | ) | const

Definition at line 135 of file aastringcodec.cpp.

{
QStringList aa_string_list;
for(auto code : code_list)
{
aa_string_list << decode(code);
}
return aa_string_list;
}
pappso::AaStringCodec::decode
QString decode(uint32_t code) const
Definition aastringcodec.cpp:119

References code(), and decode().

## decode() [2/2]

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

Definition at line 119 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;
}

References code(), m_aaCode, and m_base.

Referenced by decode().

## generateCodeMassFromModel()

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

private

Definition at line 235 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::CodeToMass::code
uint32_t code
Definition aastringcodec.h:45
pappso::CodeToMass::mass
double mass
Definition aastringcodec.h:46

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

Referenced by generateLlcCodeListUpToMaxPeptideSize(), and recGenerateModel().

## 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 190 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:207

References m_base, and recGenerateModel().

## 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 162 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:235

References generateCodeMassFromModel(), m_base, and recGenerateModel().

## getAaCode()

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

Definition at line 299 of file aastringcodec.cpp.

{
return m_aaCode;
}

References 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 253 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;
}

References code(), m_base, and m_units.

## getMass()

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

Definition at line 147 of file aastringcodec.cpp.

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

References code(), m_aaCode, and m_base.

## 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 207 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::Enums::XicExtractMethod::max
@ max
maximum of intensities
Definition types.h:280

References generateCodeMassFromModel(), and recGenerateModel().

Referenced by generateLlcCodeListByMaxPeptideSize(), generateLlcCodeListUpToMaxPeptideSize(), and recGenerateModel().

## uniqueCodeContainsAminoAcid()

bool pappso::AaStringCodec::uniqueCodeContainsAminoAcid | ( | uint32_t | code,
|  | uint8_t | aa_ok,
|  | int | times ) const

tell if a unique code only contains one amino acid 1 or n times

Parameters

  code | the code to valid
  aa_ok | the amino acid the code must contains
  times | the number of aa_ok presence in code

Definition at line 279 of file aastringcodec.cpp.

{
int number = 0;
while(code > 0)
{
if(aa_ok == (uint8_t)(code % m_base))
{
number++;
if(number == times)
return true;
}
code /= m_base;
}
return false;
}

References code(), and m_base.

## Member Data Documentation

## m_aaCode

const AaCode& pappso::AaStringCodec::m_aaCode

private

Definition at line 147 of file aastringcodec.h.

Referenced by AaStringCodec(), AaStringCodec(), code(), codeLlc(), decode(), generateCodeMassFromModel(), getAaCode(), and getMass().

## m_base

uint32_t pappso::AaStringCodec::m_base = 0

private

Definition at line 146 of file aastringcodec.h.

Referenced by AaStringCodec(), AaStringCodec(), codeOnlyContains(), decode(), generateLlcCodeListByMaxPeptideSize(), generateLlcCodeListUpToMaxPeptideSize(), getLimitMax(), getMass(), and uniqueCodeContainsAminoAcid().

## m_units

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

private

Definition at line 148 of file aastringcodec.h.

Referenced by AaStringCodec(), AaStringCodec(), code(), codeLlc(), codeLlc(), generateCodeMassFromModel(), and getLimitMax().

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

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