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

collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (lower to higher). Leucine is replaced by Isoleucine More...

`#include <aacode.h>`

## Public Member Functions

| AaCode ()
| AaCode (const AaCode &other)
| ~AaCode ()
uint8_t | getAaCode (char aa_letter) const
| get the integer code of an amino acid with the one letter code
uint8_t | getAaCode (pappso::Enums::AminoAcidChar aa) const
| get the integer code of an amino acid enum
uint8_t | getAaCodeByMass (double mass, PrecisionPtr precision) const
| get the integer code of an amino acid given a mass and a precision
const Aa & | getAa (char aa_letter) const
| get the Aa object from the one letter code
const Aa & | getAa (uint8_t aa_code) const
| get the Aa object from the amino acid integer code
double | getMass (uint8_t aa_code) const
| get the mass of the amino acid given its integer code the amino acid can bear some modification (if addAaModification function was used)
double | getMass (char aa_letter) const
void | addAaModification (char aa_letter, AaModificationP aaModification)
| add a modification on an amino acid for example carbamido on C
std::size_t | getSize () const
| number of amino acid coded letters in this aa code
const std::vector< Aa > & | getAaCollection () const

## Private Member Functions

void | updateNumbers ()
| give a number (the code) to each amino acid sorted by mass
void | updateMass ()
| update mass cache

## Private Attributes

std::vector< uint8_t > | m_asciiTable
std::vector< Aa > | m_aaCollection
std::vector< double > | m_massCollection
pappso::Aa | m_leucine = Aa('L')

## Detailed Description

collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (lower to higher). Leucine is replaced by Isoleucine

Definition at line 43 of file aacode.h.

## Constructor & Destructor Documentation

## AaCode() [1/2]

AaCode::AaCode | ( |  | ) |

Default constructor

Definition at line 34 of file aacode.cpp.

{
m_asciiTable.resize(90, 0);
m_aaCollection.push_back(Aa('A'));
m_aaCollection.push_back(Aa('C'));
m_aaCollection.push_back(Aa('D'));
m_aaCollection.push_back(Aa('E'));
m_aaCollection.push_back(Aa('F'));
m_aaCollection.push_back(Aa('G'));
m_aaCollection.push_back(Aa('H'));
m_aaCollection.push_back(Aa('I'));
m_aaCollection.push_back(Aa('K'));
m_aaCollection.push_back(Aa('M'));
m_aaCollection.push_back(Aa('N'));
m_aaCollection.push_back(Aa('P'));
m_aaCollection.push_back(Aa('Q'));
m_aaCollection.push_back(Aa('R'));
m_aaCollection.push_back(Aa('S'));
m_aaCollection.push_back(Aa('T'));
m_aaCollection.push_back(Aa('V'));
m_aaCollection.push_back(Aa('W'));
m_aaCollection.push_back(Aa('Y'));
updateNumbers();
}
pappso::AaCode::updateNumbers
void updateNumbers()
give a number (the code) to each amino acid sorted by mass
Definition aacode.cpp:192
pappso::AaCode::m_asciiTable
std::vector< uint8_t > m_asciiTable
Definition aacode.h:113
pappso::AaCode::m_aaCollection
std::vector< Aa > m_aaCollection
Definition aacode.h:115

References m_aaCollection, m_asciiTable, and updateNumbers().

## AaCode() [2/2]

pappso::AaCode::AaCode | ( | const AaCode & | other | ) |

Default copy constructor

Definition at line 61 of file aacode.cpp.

{
m_asciiTable = other.m_asciiTable;
m_aaCollection = other.m_aaCollection;
}

References m_aaCollection, and m_asciiTable.

## ~AaCode()

AaCode::~AaCode | ( |  | ) |

Destructor

Definition at line 69 of file aacode.cpp.

{
}

## Member Function Documentation

## addAaModification()

void pappso::AaCode::addAaModification | ( | char | aa_letter,
|  | pappso::AaModificationP | aaModification )

add a modification on an amino acid for example carbamido on C

Definition at line 169 of file aacode.cpp.

{
auto it = std::find_if(m_aaCollection.begin(), m_aaCollection.end(), [aa_letter](const Aa &aa) {
if(aa.getLetter() == aa_letter)
return true;
return false;
});
if(it != m_aaCollection.end())
{
it->addAaModification(aaModification);
}
else
{
throw pappso::ExceptionNotFound(
QObject::tr("error, %1 amino acid not found in m_aaCollection").arg(aa_letter));
}
updateNumbers();
}

References m_aaCollection, and updateNumbers().

## getAa() [1/2]

const pappso::Aa & pappso::AaCode::getAa | ( | char | aa_letter | ) | const

get the Aa object from the one letter code

Definition at line 132 of file aacode.cpp.

{
if(aa_letter == 'L')
return m_leucine;
auto it = std::find_if(m_aaCollection.begin(), m_aaCollection.end(), [aa_letter](const Aa &aa) {
if(aa.getLetter() == aa_letter)
return true;
return false;
});
if(it != m_aaCollection.end())
{
return *it;
}
throw pappso::ExceptionNotFound(
QObject::tr("error, %1 amino acid not found in m_aaCollection").arg(aa_letter));
}
pappso::AaCode::m_leucine
pappso::Aa m_leucine
Definition aacode.h:118

References m_aaCollection, and m_leucine.

## getAa() [2/2]

const pappso::Aa & pappso::AaCode::getAa | ( | uint8_t | aa_code | ) | const

get the Aa object from the amino acid integer code

Definition at line 152 of file aacode.cpp.

{
if(aa_code == 0)
{
throw pappso::ExceptionOutOfRange(
QObject::tr("error, 0 is null : no amino acid").arg(aa_code));
}
else if(aa_code > 19)
{
throw pappso::ExceptionOutOfRange(
QObject::tr("error, %1 amino acid code not found in m_aaCollection").arg(aa_code));
}
return m_aaCollection[aa_code - 1];
}

References m_aaCollection.

## getAaCode() [1/2]

uint8_t pappso::AaCode::getAaCode | ( | char | aa_letter | ) | const

get the integer code of an amino acid with the one letter code

Returns
  integer 1 to 20, 0 if not found

Definition at line 81 of file aacode.cpp.

{
// qDebug() << aa_letter << " " << (uint8_t)aa_letter;
// qDebug() << m_asciiTable[77];
uint8_t aa_code = m_asciiTable[aa_letter];
if(aa_code == 0)
{
throw pappso::ExceptionOutOfRange(
QObject::tr("getAaCode(char aa_letter) error, %1 is null : no amino acid for letter \"%2\"")
.arg(aa_code)
.arg(aa_letter));
}
else if(aa_code >= m_massCollection.size())
{
throw pappso::ExceptionOutOfRange(
QObject::tr("getAaCode(char aa_letter) error, %1 amino acid code not found in "
"m_aaCollection for letter \"%2\"")
.arg(aa_code)
.arg(aa_letter));
}
return aa_code;
}
pappso::AaCode::m_massCollection
std::vector< double > m_massCollection
Definition aacode.h:116

References m_asciiTable, and m_massCollection.

Referenced by pappso::ProteinIntegerCode::ProteinIntegerCode(), pappso::specpeptidoms::SpOMSProtein::SpOMSProtein(), and getMass().

## getAaCode() [2/2]

uint8_t pappso::AaCode::getAaCode | ( | pappso::Enums::AminoAcidChar | aa | ) | const

get the integer code of an amino acid enum

Returns
  integer 1 to 20, 0 if not found

Definition at line 106 of file aacode.cpp.

{
uint8_t aa_code = m_asciiTable[(char)aa];
if(aa_code == 0)
{
throw pappso::ExceptionOutOfRange(
QObject::tr("getAaCode(pappso::Enums::AminoAcidChar aa) error, %1 is null : no amino acid "
"for letter \"%2\"")
.arg(aa_code)
.arg(char(aa)));
}
else if(aa_code >= m_massCollection.size())
{
throw pappso::ExceptionOutOfRange(
QObject::tr("getAaCode(pappso::Enums::AminoAcidChar aa) error, %1 amino acid code not "
"found in m_aaCollection for letter \"%2\"")
.arg(aa_code)
.arg(char(aa)));
}
return aa_code;
}

References m_asciiTable, and m_massCollection.

## getAaCodeByMass()

uint8_t pappso::AaCode::getAaCodeByMass | ( | double | mass,
|  | pappso::PrecisionPtr | precision ) const

get the integer code of an amino acid given a mass and a precision

Returns
  integer 1 to 20, 0 if not found

Definition at line 245 of file aacode.cpp.

{
double delta = precision->delta(mass);
double mass_min = mass - delta;
double mass_max = mass + delta;
uint8_t aa_code = 0;
for(uint8_t i = 1; i < m_massCollection.size(); i++)
{
if(m_massCollection.at(i) >= mass_min)
{
if(m_massCollection.at(i) <= mass_max)
{
aa_code = i;
}
break;
}
}
return aa_code;
}
pappso::PrecisionBase::delta
virtual pappso_double delta(pappso_double value) const =0

References pappso::PrecisionBase::delta(), and m_massCollection.

## getAaCollection()

const std::vector< Aa > & pappso::AaCode::getAaCollection | ( |  | ) | const

Definition at line 266 of file aacode.cpp.

{
return m_aaCollection;
}

References m_aaCollection.

## getMass() [1/2]

double pappso::AaCode::getMass | ( | char | aa_letter | ) | const

Definition at line 230 of file aacode.cpp.

{
try
{
return m_massCollection[this->getAaCode(aa_letter)];
}
catch(const pappso::PappsoException &err)
{
throw pappso::PappsoException(
QObject::tr("getMass(char aa_letter) failed :\n%1").arg(err.qwhat()));
}
}
pappso::AaCode::getAaCode
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
Definition aacode.cpp:81
pappso::PappsoException::qwhat
virtual const QString & qwhat() const
Definition pappsoexception.h:66

References getAaCode(), m_massCollection, and pappso::PappsoException::qwhat().

## getMass() [2/2]

double pappso::AaCode::getMass | ( | uint8_t | aa_code | ) | const

get the mass of the amino acid given its integer code the amino acid can bear some modification (if addAaModification function was used)

Definition at line 224 of file aacode.cpp.

{
return m_massCollection[aa_code];
}

References m_massCollection.

Referenced by pappso::specpeptidoms::SpOMSProtein::SpOMSProtein(), and pappso::specpeptidoms::SemiGlobalAlignment::getPotentialMassErrors().

## getSize()

std::size_t pappso::AaCode::getSize | ( |  | ) | const

number of amino acid coded letters in this aa code

Definition at line 74 of file aacode.cpp.

{
return 19;
}

## updateMass()

void pappso::AaCode::updateMass | ( |  | ) |

private

update mass cache

Definition at line 212 of file aacode.cpp.

{
m_massCollection.resize(1);
for(const Aa &aa : m_aaCollection)
{
m_massCollection.push_back(aa.getMass());
}
}
pappso::masschroq::PeakQualityCategory::aa
@ aa
best possible : more than one direct MS2 fragmentation in same MSRUN
Definition types.h:45

References m_aaCollection, and m_massCollection.

Referenced by updateNumbers().

## updateNumbers()

void pappso::AaCode::updateNumbers | ( |  | ) |

private

give a number (the code) to each amino acid sorted by mass

Definition at line 192 of file aacode.cpp.

{
std::sort(m_aaCollection.begin(), m_aaCollection.end(), [](const Aa &aa1, const Aa &aa2) {
return aa1.getMass() < aa2.getMass();
});
std::size_t n = 1;
for(const Aa &aa : m_aaCollection)
{
// qDebug() << aa.getLetter() << " " << n;
m_asciiTable[aa.getLetter()] = n;
n++;
}
m_asciiTable['L'] = m_asciiTable['I'];
updateMass();
}
pappso::AaCode::updateMass
void updateMass()
update mass cache
Definition aacode.cpp:212

References m_aaCollection, m_asciiTable, and updateMass().

Referenced by AaCode(), and addAaModification().

## Member Data Documentation

## m_aaCollection

std::vector<Aa> pappso::AaCode::m_aaCollection

private

Definition at line 115 of file aacode.h.

Referenced by AaCode(), AaCode(), addAaModification(), getAa(), getAa(), getAaCollection(), updateMass(), and updateNumbers().

## m_asciiTable

std::vector<uint8_t> pappso::AaCode::m_asciiTable

private

Definition at line 113 of file aacode.h.

Referenced by AaCode(), AaCode(), getAaCode(), getAaCode(), and updateNumbers().

## m_leucine

pappso::Aa pappso::AaCode::m_leucine = Aa('L')

private

Definition at line 118 of file aacode.h.

Referenced by getAa().

## m_massCollection

std::vector<double> pappso::AaCode::m_massCollection

private

Definition at line 116 of file aacode.h.

Referenced by getAaCode(), getAaCode(), getAaCodeByMass(), getMass(), getMass(), and updateMass().

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

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