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
 
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:191
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 168 of file aacode.cpp.

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

Referenced by pappso::cbor::psm::PsmSpecPeptidOms::PsmSpecPeptidOms().

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

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

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

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

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

◆ 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 {
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 {
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}

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

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

References pappso::PrecisionBase::delta().

◆ getAaCollection()

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

Definition at line 265 of file aacode.cpp.

266{
267 return m_aaCollection;
268}

◆ getMass() [1/2]

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

Definition at line 229 of file aacode.cpp.

230{
231 try
232 {
233 return m_massCollection[this->getAaCode(aa_letter)];
234 }
235
236 catch(const pappso::PappsoException &err)
237 {
239 QObject::tr("getMass(char aa_letter) failed :\n%1").arg(err.qwhat()));
240 }
241}
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 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 223 of file aacode.cpp.

224{
225 return m_massCollection[aa_code];
226}

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

◆ getSize()

◆ updateMass()

void pappso::AaCode::updateMass ( )
private

update mass cache

Definition at line 211 of file aacode.cpp.

212{
213 m_massCollection.resize(1);
214
215 for(const Aa &aa : m_aaCollection)
216 {
217 m_massCollection.push_back(aa.getMass());
218 }
219}
@ aa
best possible : more than one direct MS2 fragmentation in same MSRUN

◆ updateNumbers()

void pappso::AaCode::updateNumbers ( )
private

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

Definition at line 191 of file aacode.cpp.

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

Referenced by AaCode().

Member Data Documentation

◆ m_aaCollection

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

Definition at line 112 of file aacode.h.

Referenced by AaCode(), and AaCode().

◆ m_asciiTable

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

Definition at line 110 of file aacode.h.

Referenced by AaCode(), and AaCode().

◆ m_leucine

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

Definition at line 115 of file aacode.h.

◆ m_massCollection

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

Definition at line 113 of file aacode.h.


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