libpappsomspp
Library for mass spectrometry
Toggle main menu visibility
Loading...
Searching...
No Matches
aastringcodec.h
Go to the documentation of this file.
1
/**
2
* \file pappsomspp/amino_acid/aastringcodec.h
3
* \date 09/05/2023
4
* \author Olivier Langella
5
* \brief code and decodefrom amino acid string to integer
6
*/
7
8
/*******************************************************************************
9
* Copyright (c) 2023 Olivier Langella <Olivier.Langella@u-psud.fr>.
10
*
11
* This file is part of PAPPSOms-tools.
12
*
13
* PAPPSOms-tools is free software: you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation, either version 3 of the License, or
16
* (at your option) any later version.
17
*
18
* PAPPSOms-tools is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with PAPPSOms-tools. If not, see <http://www.gnu.org/licenses/>.
25
*
26
******************************************************************************/
27
28
#pragma once
29
30
#include "
pappsomspp/export-import-config.h
"
31
#include "
pappsomspp/core/amino_acid/aacode.h
"
32
33
namespace
pappso
34
{
35
36
37
class
AaStringCodec
;
38
39
/** \brief shared pointer on a Protein object
40
*/
41
typedef
std::shared_ptr<const AaStringCodec>
AaStringCodecSp
;
42
43
struct
CodeToMass
44
{
45
uint32_t
code
= 0;
46
double
mass
= 0;
47
};
48
/**
49
* @brief code and decode amino acid string sequence to unique integer
50
*/
51
class
PMSPP_LIB_DECL
AaStringCodec
52
{
53
public
:
54
/**
55
* Default constructor
56
*/
57
AaStringCodec
(
const
AaCode
&aaCode);
58
59
/**
60
* Copy constructor
61
*
62
* @param other TODO
63
*/
64
AaStringCodec
(
const
AaStringCodec
&other);
65
66
/**
67
* Destructor
68
*/
69
~AaStringCodec
();
70
71
72
/** @brief get the maximum code number for a given peptide size
73
*/
74
std::size_t
getLimitMax
(std::size_t size)
const
;
75
76
/** @brief get integer from amino acide suite string
77
*/
78
uint32_t
code
(
const
QString &aa_str)
const
;
79
80
81
/** @brief get the lowest common denominator integer from amino acide suite
82
* string
83
*/
84
uint32_t
codeLlc
(
const
QString &aa_str)
const
;
85
86
/** @brief get the lowest common denominator integer from amino acide code
87
* vector
88
*/
89
uint32_t
codeLlc
(std::vector<uint8_t>::const_iterator it_begin,
90
std::size_t size)
const
;
91
92
93
QString
decode
(uint32_t
code
)
const
;
94
95
QStringList
decode
(
const
std::vector<uint32_t> &code_list)
const
;
96
97
double
getMass
(uint32_t
code
)
const
;
98
99
100
/** @brief generates all possible combination of llc code mass
101
* llc : the lowest common code denominator for a given aa formula
102
*
103
* generate from peptide size =1 to peptide size
104
*/
105
std::vector<CodeToMass>
106
generateLlcCodeListUpToMaxPeptideSize
(std::size_t size)
const
;
107
108
/** @brief generates all possible combination of llc code mass
109
* llc : the lowest common code denominator for a given aa formula
110
*
111
* generate only for this peptide size
112
*/
113
std::vector<CodeToMass>
114
generateLlcCodeListByMaxPeptideSize
(std::size_t size)
const
;
115
116
/** @brief tell if a code only contains a list of amino acid
117
*
118
* @param code the code to valid
119
* @param aa_ok list of required amino acids
120
*/
121
bool
codeOnlyContains
(uint32_t
code
,
const
std::vector<uint8_t> &aa_ok)
const
;
122
123
124
/** @brief tell if a unique code only contains one amino acid 1 or n times
125
*
126
* @param code the code to valid
127
* @param aa_ok the amino acid the code must contains
128
* @param times the number of aa_ok presence in code
129
*/
130
bool
131
uniqueCodeContainsAminoAcid
(uint32_t
code
, uint8_t aa_ok,
int
times)
const
;
132
133
134
const
AaCode
&
getAaCode
()
const
;
135
136
private
:
137
/** @brief recursive method to generate models
138
*/
139
void
recGenerateModel
(std::vector<CodeToMass> &glist,
140
std::vector<uint8_t> &model,
141
std::size_t position)
const
;
142
143
CodeToMass
generateCodeMassFromModel
(
const
std::vector<uint8_t> &model)
const
;
144
145
private
:
146
uint32_t
m_base
= 0;
147
const
AaCode
&
m_aaCode
;
148
std::vector<uint32_t>
m_units
;
149
};
150
}
// namespace pappso
aacode.h
pappso::AaCode
collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (...
Definition
aacode.h:44
pappso::AaStringCodec
code and decode amino acid string sequence to unique integer
Definition
aastringcodec.h:52
pappso::AaStringCodec::getLimitMax
std::size_t getLimitMax(std::size_t size) const
get the maximum code number for a given peptide size
Definition
aastringcodec.cpp:253
pappso::AaStringCodec::getMass
double getMass(uint32_t code) const
Definition
aastringcodec.cpp:147
pappso::AaStringCodec::getAaCode
const AaCode & getAaCode() const
Definition
aastringcodec.cpp:299
pappso::AaStringCodec::decode
QString decode(uint32_t code) const
Definition
aastringcodec.cpp:119
pappso::AaStringCodec::codeLlc
uint32_t codeLlc(const QString &aa_str) const
get the lowest common denominator integer from amino acide suite string
Definition
aastringcodec.cpp:72
pappso::AaStringCodec::recGenerateModel
void recGenerateModel(std::vector< CodeToMass > &glist, std::vector< uint8_t > &model, std::size_t position) const
recursive method to generate models
Definition
aastringcodec.cpp:207
pappso::AaStringCodec::m_units
std::vector< uint32_t > m_units
Definition
aastringcodec.h:148
pappso::AaStringCodec::uniqueCodeContainsAminoAcid
bool uniqueCodeContainsAminoAcid(uint32_t code, uint8_t aa_ok, int times) const
tell if a unique code only contains one amino acid 1 or n times
Definition
aastringcodec.cpp:279
pappso::AaStringCodec::m_base
uint32_t m_base
Definition
aastringcodec.h:146
pappso::AaStringCodec::code
uint32_t code(const QString &aa_str) const
get integer from amino acide suite string
Definition
aastringcodec.cpp:58
pappso::AaStringCodec::m_aaCode
const AaCode & m_aaCode
Definition
aastringcodec.h:147
pappso::AaStringCodec::generateCodeMassFromModel
CodeToMass generateCodeMassFromModel(const std::vector< uint8_t > &model) const
Definition
aastringcodec.cpp:235
pappso::AaStringCodec::AaStringCodec
AaStringCodec(const AaCode &aaCode)
Definition
aastringcodec.cpp:33
pappso::AaStringCodec::generateLlcCodeListByMaxPeptideSize
std::vector< CodeToMass > generateLlcCodeListByMaxPeptideSize(std::size_t size) const
generates all possible combination of llc code mass llc : the lowest common code denominator for a gi...
Definition
aastringcodec.cpp:190
pappso::AaStringCodec::codeOnlyContains
bool codeOnlyContains(uint32_t code, const std::vector< uint8_t > &aa_ok) const
tell if a code only contains a list of amino acid
Definition
aastringcodec.cpp:265
pappso::AaStringCodec::generateLlcCodeListUpToMaxPeptideSize
std::vector< CodeToMass > generateLlcCodeListUpToMaxPeptideSize(std::size_t size) const
generates all possible combination of llc code mass llc : the lowest common code denominator for a gi...
Definition
aastringcodec.cpp:162
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition
export-import-config.h:14
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition
aa.cpp:39
pappso::AaStringCodecSp
std::shared_ptr< const AaStringCodec > AaStringCodecSp
shared pointer on a Protein object
Definition
aastringcodec.h:41
pappso::CodeToMass
Definition
aastringcodec.h:44
pappso::CodeToMass::code
uint32_t code
Definition
aastringcodec.h:45
pappso::CodeToMass::mass
double mass
Definition
aastringcodec.h:46
pappsomspp
core
amino_acid
aastringcodec.h
Generated on
for libpappsomspp by
1.17.0