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
 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< Aam_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.

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:192
std::vector< uint8_t > m_asciiTable
Definition aacode.h:113
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.

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

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

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.

133{
134
135 if(aa_letter == 'L')
136 return m_leucine;
137 auto it = std::find_if(m_aaCollection.begin(), m_aaCollection.end(), [aa_letter](const Aa &aa) {
138 if(aa.getLetter() == aa_letter)
139 return true;
140 return false;
141 });
142 if(it != m_aaCollection.end())
143 {
144 return *it;
145 }
146 throw pappso::ExceptionNotFound(
147 QObject::tr("error, %1 amino acid not found in m_aaCollection").arg(aa_letter));
148}
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.

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

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("getAaCode(char aa_letter) 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("getAaCode(char aa_letter) error, %1 amino acid code not found in "
98 "m_aaCollection for letter \"%2\"")
99 .arg(aa_code)
100 .arg(aa_letter));
101 }
102 return aa_code;
103}
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.

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

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.

246{
247 double delta = precision->delta(mass);
248 double mass_min = mass - delta;
249 double mass_max = mass + delta;
250 uint8_t aa_code = 0;
251 for(uint8_t i = 1; i < m_massCollection.size(); i++)
252 {
253 if(m_massCollection.at(i) >= mass_min)
254 {
255 if(m_massCollection.at(i) <= mass_max)
256 {
257 aa_code = i;
258 }
259 break;
260 }
261 }
262 return aa_code;
263}
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.

267{
268 return m_aaCollection;
269}

References m_aaCollection.

◆ getMass() [1/2]

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

Definition at line 230 of file aacode.cpp.

231{
232 try
233 {
234 return m_massCollection[this->getAaCode(aa_letter)];
235 }
236
237 catch(const pappso::PappsoException &err)
238 {
239 throw pappso::PappsoException(
240 QObject::tr("getMass(char aa_letter) failed :\n%1").arg(err.qwhat()));
241 }
242}
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
Definition aacode.cpp:81
virtual const QString & qwhat() const

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.

225{
226 return m_massCollection[aa_code];
227}

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.

75{
76 return 19;
77}

◆ updateMass()

void pappso::AaCode::updateMass ( )
private

update mass cache

Definition at line 212 of file aacode.cpp.

213{
214 m_massCollection.resize(1);
215
216 for(const Aa &aa : m_aaCollection)
217 {
218 m_massCollection.push_back(aa.getMass());
219 }
220}
@ 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.

193{
194
195 std::sort(m_aaCollection.begin(), m_aaCollection.end(), [](const Aa &aa1, const Aa &aa2) {
196 return aa1.getMass() < aa2.getMass();
197 });
198
199 std::size_t n = 1;
200 for(const Aa &aa : m_aaCollection)
201 {
202 // qDebug() << aa.getLetter() << " " << n;
203 m_asciiTable[aa.getLetter()] = n;
204 n++;
205 }
206 m_asciiTable['L'] = m_asciiTable['I'];
207
208 updateMass();
209}
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

◆ 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: