libpappsomspp
Library for mass spectrometry
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 More...
 
uint8_t getAaCodeByMass (double mass, PrecisionPtr precision) const
 get the integer code of an amino acid given a mass and a precision More...
 
const AagetAa (char aa_letter) const
 get the Aa object from the one letter code More...
 
const AagetAa (uint8_t aa_code) const
 get the Aa object from the amino acid integer code More...
 
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) More...
 
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 More...
 
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 More...
 
void updateMass ()
 update mass cache More...
 

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:147
std::vector< uint8_t > m_asciiTable
Definition: aacode.h:105
std::vector< Aa > m_aaCollection
Definition: aacode.h:107
Definition: aa.h:45

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

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

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

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

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

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

◆ getAaCode()

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 return m_asciiTable[aa_letter];
86}

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

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

192{
193 double delta = precision->delta(mass);
194 double mass_min = mass - delta;
195 double mass_max = mass + delta;
196 uint8_t aa_code = 0;
197 for(uint8_t i = 1; i < m_massCollection.size(); i++)
198 {
199 if(m_massCollection.at(i) >= mass_min)
200 {
201 if(m_massCollection.at(i) <= mass_max)
202 {
203 aa_code = i;
204 }
205 break;
206 }
207 }
208 return aa_code;
209}
std::vector< double > m_massCollection
Definition: aacode.h:108
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 212 of file aacode.cpp.

213{
214 return m_aaCollection;
215}

◆ getMass() [1/2]

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

Definition at line 185 of file aacode.cpp.

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

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

180{
181 return m_massCollection[aa_code];
182}

◆ getSize()

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

◆ updateMass()

void pappso::AaCode::updateMass ( )
private

update mass cache

Definition at line 167 of file aacode.cpp.

168{
169 m_massCollection.resize(1);
170
171 for(const Aa &aa : m_aaCollection)
172 {
173 m_massCollection.push_back(aa.getMass());
174 }
175}
@ 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 147 of file aacode.cpp.

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

Referenced by AaCode().

Member Data Documentation

◆ m_aaCollection

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

Definition at line 107 of file aacode.h.

Referenced by AaCode().

◆ m_asciiTable

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

Definition at line 105 of file aacode.h.

Referenced by AaCode().

◆ m_massCollection

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

Definition at line 108 of file aacode.h.


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