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
 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 AagetAa (char aa_letter) const
 get the Aa object from the one letter code
 
const AagetAa (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
 
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< 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 43 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:187
std::vector< uint8_t > m_asciiTable
Definition aacode.h:110
std::vector< Aa > m_aaCollection
Definition aacode.h:112

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 )

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

Definition at line 164 of file aacode.cpp.

165{
166
167 auto it = std::find_if(m_aaCollection.begin(), m_aaCollection.end(), [aa_letter](const Aa &aa) {
168 if(aa.getLetter() == aa_letter)
169 return true;
170 return false;
171 });
172 if(it != m_aaCollection.end())
173 {
174 it->addAaModification(aaModification);
175 }
176 else
177 {
178 throw pappso::ExceptionNotFound(
179 QObject::tr("error, %1 amino acid not found in m_aaCollection").arg(aa_letter));
180 }
181
183}

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 129 of file aacode.cpp.

130{
131
132 auto it = std::find_if(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 return *it;
140 }
141 throw pappso::ExceptionNotFound(
142 QObject::tr("error, %1 amino acid not found in m_aaCollection").arg(aa_letter));
143}

References m_aaCollection.

◆ 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 147 of file aacode.cpp.

148{
149 if(aa_code == 0)
150 {
151 throw pappso::ExceptionOutOfRange(
152 QObject::tr("error, 0 is null : no amino acid").arg(aa_code));
153 }
154 else if(aa_code > 19)
155 {
156 throw pappso::ExceptionOutOfRange(
157 QObject::tr("error, %1 amino acid code not found in m_aaCollection").arg(aa_code));
158 }
159 return m_aaCollection[aa_code - 1];
160}

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.

82{
83 // qDebug() << aa_letter << " " << (uint8_t)aa_letter;
84 // qDebug() << m_asciiTable[77];
85 uint8_t aa_code = m_asciiTable[aa_letter];
86
87 if(aa_code == 0)
88 {
89 throw pappso::ExceptionOutOfRange(
90 QObject::tr("error, %1 is null : no amino acid for letter \"%2\"")
91 .arg(aa_code)
92 .arg(aa_letter));
93 }
94 else if(aa_code >= m_massCollection.size())
95 {
96 throw pappso::ExceptionOutOfRange(
97 QObject::tr("error, %1 amino acid code not found in m_aaCollection for letter \"%2\"")
98 .arg(aa_code)
99 .arg(aa_letter));
100 }
101 return aa_code;
102}
std::vector< double > m_massCollection
Definition aacode.h:113

References m_asciiTable, and m_massCollection.

Referenced by pappso::ProteinIntegerCode::ProteinIntegerCode(), 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 105 of file aacode.cpp.

106{
107
108 uint8_t aa_code = m_asciiTable[(char)aa];
109
110 if(aa_code == 0)
111 {
112 throw pappso::ExceptionOutOfRange(
113 QObject::tr("error, %1 is null : no amino acid for letter \"%2\"")
114 .arg(aa_code)
115 .arg(char(aa)));
116 }
117 else if(aa_code >= m_massCollection.size())
118 {
119 throw pappso::ExceptionOutOfRange(
120 QObject::tr("error, %1 amino acid code not found in m_aaCollection for letter \"%2\"")
121 .arg(aa_code)
122 .arg(char(aa)));
123 }
124 return aa_code;
125}

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 231 of file aacode.cpp.

232{
233 double delta = precision->delta(mass);
234 double mass_min = mass - delta;
235 double mass_max = mass + delta;
236 uint8_t aa_code = 0;
237 for(uint8_t i = 1; i < m_massCollection.size(); i++)
238 {
239 if(m_massCollection.at(i) >= mass_min)
240 {
241 if(m_massCollection.at(i) <= mass_max)
242 {
243 aa_code = i;
244 }
245 break;
246 }
247 }
248 return aa_code;
249}
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 252 of file aacode.cpp.

253{
254 return m_aaCollection;
255}

References m_aaCollection.

◆ getMass() [1/2]

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

Definition at line 225 of file aacode.cpp.

226{
227 return m_massCollection[this->getAaCode(aa_letter)];
228}
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
Definition aacode.cpp:81

References getAaCode(), and m_massCollection.

◆ 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 219 of file aacode.cpp.

220{
221 return m_massCollection[aa_code];
222}

References m_massCollection.

Referenced by pappso::specpeptidoms::SemiGlobalAlignment::getPotentialMassErrors().

◆ getSize()

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

Definition at line 74 of file aacode.cpp.

75{
76 return 19;
77}

◆ updateMass()

void pappso::AaCode::updateMass ( )
private

update mass cache

Definition at line 207 of file aacode.cpp.

208{
209 m_massCollection.resize(1);
210
211 for(const Aa &aa : m_aaCollection)
212 {
213 m_massCollection.push_back(aa.getMass());
214 }
215}
@ 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 187 of file aacode.cpp.

188{
189
190 std::sort(m_aaCollection.begin(), m_aaCollection.end(), [](const Aa &aa1, const Aa &aa2) {
191 return aa1.getMass() < aa2.getMass();
192 });
193
194 std::size_t n = 1;
195 for(const Aa &aa : m_aaCollection)
196 {
197 // qDebug() << aa.getLetter() << " " << n;
198 m_asciiTable[aa.getLetter()] = n;
199 n++;
200 }
201 m_asciiTable['L'] = m_asciiTable['I'];
202
203 updateMass();
204}
void updateMass()
update mass cache
Definition aacode.cpp:207

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

◆ m_asciiTable

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

Definition at line 110 of file aacode.h.

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

◆ m_massCollection

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

Definition at line 113 of file aacode.h.

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


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