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
30#include "../exportinmportconfig.h"
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
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 double getMass(uint32_t code) const;
96
97
98 /** @brief generates all possible combination of llc code mass
99 * llc : the lowest common code denominator for a given aa formula
100 *
101 * generate from peptide size =1 to peptide size
102 */
103 std::vector<CodeToMass>
104 generateLlcCodeListUpToMaxPeptideSize(std::size_t size) const;
105
106 /** @brief generates all possible combination of llc code mass
107 * llc : the lowest common code denominator for a given aa formula
108 *
109 * generate only for this peptide size
110 */
111 std::vector<CodeToMass>
112 generateLlcCodeListByMaxPeptideSize(std::size_t size) const;
113
114 bool codeOnlyContains(uint32_t code, const std::vector<uint8_t> &aa_ok) const;
115
116
117 const AaCode &getAaCode() const;
118
119 private:
120 /** @brief recursive method to generate models
121 */
122 void recGenerateModel(std::vector<CodeToMass> &glist,
123 std::vector<uint8_t> &model,
124 std::size_t position) const;
125
126 CodeToMass generateCodeMassFromModel(const std::vector<uint8_t> &model) const;
127
128 private:
129 uint32_t m_base = 0;
131 std::vector<uint32_t> m_units;
132};
133} // 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
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