libpappsomspp
Library for mass spectrometry
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
 
const AagetAa (char aa_letter) const
 
const AagetAa (uint8_t aa_code) const
 
double getMass (uint8_t aa_code) const
 
void addAaModification (char aa_letter, AaModificationP aaModification)
 
std::size_t getSize () 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< Aam_aaCollection
 
std::vector< double > m_massCollection
 

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 42 of file aacode.h.

Constructor & Destructor Documentation

◆ AaCode() [1/2]

AaCode::AaCode ( )

Default constructor

Definition at line 34 of file aacode.cpp.

35{
36 m_asciiTable.resize(90, 0);
37
38 m_aaCollection.push_back(Aa('A'));
39 m_aaCollection.push_back(Aa('C'));
40 m_aaCollection.push_back(Aa('D'));
41 m_aaCollection.push_back(Aa('E'));
42 m_aaCollection.push_back(Aa('F'));
43 m_aaCollection.push_back(Aa('G'));
44 m_aaCollection.push_back(Aa('H'));
45 m_aaCollection.push_back(Aa('I'));
46 m_aaCollection.push_back(Aa('K'));
47 m_aaCollection.push_back(Aa('M'));
48 m_aaCollection.push_back(Aa('N'));
49 m_aaCollection.push_back(Aa('P'));
50 m_aaCollection.push_back(Aa('Q'));
51 m_aaCollection.push_back(Aa('R'));
52 m_aaCollection.push_back(Aa('S'));
53 m_aaCollection.push_back(Aa('T'));
54 m_aaCollection.push_back(Aa('V'));
55 m_aaCollection.push_back(Aa('W'));
56 m_aaCollection.push_back(Aa('Y'));
57
59}
void updateNumbers()
give a number (the code) to each amino acid sorted by mass
Definition aacode.cpp:153
std::vector< uint8_t > m_asciiTable
Definition aacode.h:81
std::vector< Aa > m_aaCollection
Definition aacode.h:83

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.

62{
63
65
67}

References m_aaCollection, and m_asciiTable.

◆ ~AaCode()

AaCode::~AaCode ( )

Destructor

Definition at line 69 of file aacode.cpp.

70{
71}

Member Function Documentation

◆ addAaModification()

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

Definition at line 127 of file aacode.cpp.

129{
130
131 auto it = std::find_if(
132 m_aaCollection.begin(), m_aaCollection.end(), [aa_letter](const Aa &aa) {
133 if(aa.getLetter() == aa_letter)
134 return true;
135 return false;
136 });
137 if(it != m_aaCollection.end())
138 {
139 it->addAaModification(aaModification);
140 }
141 else
142 {
144 QObject::tr("error, %1 amino acid not found in m_aaCollection")
145 .arg(aa_letter));
146 }
147
149}

◆ getAa() [1/2]

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

Definition at line 89 of file aacode.cpp.

90{
91
92 auto it = std::find_if(
93 m_aaCollection.begin(), m_aaCollection.end(), [aa_letter](const Aa &aa) {
94 if(aa.getLetter() == aa_letter)
95 return true;
96 return false;
97 });
98 if(it != m_aaCollection.end())
99 {
100 return *it;
101 }
103 QObject::tr("error, %1 amino acid not found in m_aaCollection")
104 .arg(aa_letter));
105}

◆ getAa() [2/2]

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

Definition at line 109 of file aacode.cpp.

110{
111 if(aa_code == 0)
112 {
114 QObject::tr("error, 0 is null : no amino acid").arg(aa_code));
115 }
116 else if(aa_code > 19)
117 {
119 QObject::tr("error, %1 amino acid code not found in m_aaCollection")
120 .arg(aa_code));
121 }
122 return m_aaCollection[aa_code - 1];
123}

◆ getAaCode()

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

Definition at line 81 of file aacode.cpp.

82{
83 // qDebug() << aa_letter << " " << (uint8_t)aa_letter;
84 // qDebug() << m_asciiTable[77];
85 return m_asciiTable[aa_letter];
86}

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

◆ getMass()

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

Definition at line 186 of file aacode.cpp.

187{
188 return m_massCollection[aa_code];
189}
std::vector< double > m_massCollection
Definition aacode.h:84

◆ getSize()

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

◆ updateMass()

void pappso::AaCode::updateMass ( )
private

update mass cache

Definition at line 174 of file aacode.cpp.

175{
176 m_massCollection.resize(1);
177
178 for(const Aa &aa : m_aaCollection)
179 {
180 m_massCollection.push_back(aa.getMass());
181 }
182}

◆ updateNumbers()

void pappso::AaCode::updateNumbers ( )
private

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

Definition at line 153 of file aacode.cpp.

154{
155
156 std::sort(
157 m_aaCollection.begin(),
158 m_aaCollection.end(),
159 [](const Aa &aa1, const Aa &aa2) { return aa1.getMass() < aa2.getMass(); });
160
161 std::size_t n = 1;
162 for(const Aa &aa : m_aaCollection)
163 {
164 // qDebug() << aa.getLetter() << " " << n;
165 m_asciiTable[aa.getLetter()] = n;
166 n++;
167 }
168 m_asciiTable['L'] = m_asciiTable['I'];
169
170 updateMass();
171}
void updateMass()
update mass cache
Definition aacode.cpp:174

Referenced by AaCode().

Member Data Documentation

◆ m_aaCollection

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

Definition at line 83 of file aacode.h.

Referenced by AaCode(), and AaCode().

◆ m_asciiTable

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

Definition at line 81 of file aacode.h.

Referenced by AaCode(), and AaCode().

◆ m_massCollection

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

Definition at line 84 of file aacode.h.


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