libpappsomspp
Library for mass spectrometry
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
31#include "aacode.h"
32
33namespace pappso
34{
35
36
37class AaStringCodec;
38
39/** \brief shared pointer on a Protein object
40 */
41typedef std::shared_ptr<const AaStringCodec> AaStringCodecSp;
42
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 */
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 */
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;
148 std::vector<uint32_t> m_units;
149};
150} // namespace pappso
give an integer code to each amino acid
collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (...
Definition aacode.h:43
code and decode amino acid string sequence to unique integer
std::vector< uint32_t > m_units
const AaCode & m_aaCode
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
std::shared_ptr< const AaStringCodec > AaStringCodecSp
shared pointer on a Protein object