libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::AaStringCodeMassMatching Class Reference

convert a list of mass to amino acid string codes More...

#include <aastringcodemassmatching.h>

Classes

struct  aaCodeAndMassRange
 

Public Member Functions

 AaStringCodeMassMatching (const AaCode &aa_code, std::size_t model_max_size, PrecisionPtr precision)
 
 AaStringCodeMassMatching (const AaStringCodeMassMatching &other)
 
 ~AaStringCodeMassMatching ()
 
PrecisionPtr getPrecisionPtr () const
 
std::vector< uint32_t > getAaCodeFromMassList (std::vector< double > &mass_list) const
 
std::vector< uint32_t > getAaCodeFromMass (double mass) const
 get amino acid string code from a single mass delta
 
std::vector< uint32_t > getAaCodeFromMassWearingModification (double mass, const Aa &aa, int quantifier) const
 get amino acid string code from a single mass delta wearing a specific modification
 
std::vector< uint32_t > filterCodeList (std::vector< uint32_t > &code_list) const
 filter a list of amino acid string code find elementary amino acids (one base only) in the list and retrieve 2 or more amino acid string containing only basic aminio acid found
 

Private Attributes

PrecisionPtr m_precision = nullptr
 
const AaCodem_aaCode
 
AaStringCodec m_aaCodec
 
uint32_t m_base = 0
 
std::vector< aaCodeAndMassRangem_codeMassList
 

Detailed Description

convert a list of mass to amino acid string codes

Definition at line 40 of file aastringcodemassmatching.h.

Constructor & Destructor Documentation

◆ AaStringCodeMassMatching() [1/2]

AaStringCodeMassMatching::AaStringCodeMassMatching ( const AaCode aa_code,
std::size_t  model_max_size,
PrecisionPtr  precision 
)

Default constructor

Definition at line 36 of file aastringcodemassmatching.cpp.

39 : m_precision(precision), m_aaCode(aa_code), m_aaCodec(aa_code)
40{
41 m_base = m_aaCode.getSize() + 1;
42
43 std::vector<pappso::CodeToMass> code_to_mass =
45
46 for(auto &code_mass : code_to_mass)
47 {
48 aaCodeAndMassRange aaCodeMassRange;
49 aaCodeMassRange.code = code_mass.code;
50 double delta = precision->delta(code_mass.mass);
51 aaCodeMassRange.mz_range_low = code_mass.mass - delta;
52 aaCodeMassRange.mz = code_mass.mass;
53 aaCodeMassRange.mz_range_up = code_mass.mass + delta;
54
55 m_codeMassList.push_back(aaCodeMassRange);
56 }
57
58
59 std::sort(m_codeMassList.begin(),
60 m_codeMassList.end(),
61 [](const aaCodeAndMassRange &a, const aaCodeAndMassRange &b) {
62 return a.mz_range_low < b.mz_range_low;
63 });
64}
std::size_t getSize() const
Definition aacode.cpp:74
std::vector< aaCodeAndMassRange > m_codeMassList
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...
virtual pappso_double delta(pappso_double value) const =0

References pappso::a, pappso::b, pappso::AaStringCodeMassMatching::aaCodeAndMassRange::code, pappso::PrecisionBase::delta(), pappso::AaStringCodec::generateLlcCodeListUpToMaxPeptideSize(), pappso::AaCode::getSize(), m_aaCode, m_aaCodec, m_base, m_codeMassList, pappso::AaStringCodeMassMatching::aaCodeAndMassRange::mz, pappso::AaStringCodeMassMatching::aaCodeAndMassRange::mz_range_low, and pappso::AaStringCodeMassMatching::aaCodeAndMassRange::mz_range_up.

◆ AaStringCodeMassMatching() [2/2]

AaStringCodeMassMatching::AaStringCodeMassMatching ( const AaStringCodeMassMatching other)

Copy constructor

Parameters
otherTODO

Definition at line 66 of file aastringcodemassmatching.cpp.

68{
69 m_base = m_aaCode.getSize() + 1;
70}

References pappso::AaCode::getSize(), m_aaCode, and m_base.

◆ ~AaStringCodeMassMatching()

AaStringCodeMassMatching::~AaStringCodeMassMatching ( )

Destructor

Definition at line 72 of file aastringcodemassmatching.cpp.

73{
74}

Member Function Documentation

◆ filterCodeList()

std::vector< uint32_t > pappso::AaStringCodeMassMatching::filterCodeList ( std::vector< uint32_t > &  code_list) const

filter a list of amino acid string code find elementary amino acids (one base only) in the list and retrieve 2 or more amino acid string containing only basic aminio acid found

Definition at line 212 of file aastringcodemassmatching.cpp.

213{
214 std::sort(code_list.begin(), code_list.end(), [](uint32_t a, uint32_t b) { return a < b; });
215 std::vector<uint32_t> filtered_aa_code_list;
216
217 std::vector<uint8_t> aa_ok;
218
219 auto it = code_list.begin();
220 while(*it < m_base)
221 {
222 aa_ok.push_back((uint8_t)*it);
223 // qDebug() << (uint8_t)*it << " "
224 // << m_aaCode.getAa((uint8_t)*it).getLetter();
225 it++;
226 }
227
228 for(uint32_t code : code_list)
229 {
230 if(m_aaCodec.codeOnlyContains(code, aa_ok))
231 {
232 filtered_aa_code_list.push_back(code);
233 }
234 }
235 return filtered_aa_code_list;
236}
bool codeOnlyContains(uint32_t code, const std::vector< uint8_t > &aa_ok) const
tell if a code only contains a list of amino acid

References pappso::a, and pappso::b.

◆ getAaCodeFromMass()

std::vector< uint32_t > pappso::AaStringCodeMassMatching::getAaCodeFromMass ( double  mass) const

get amino acid string code from a single mass delta

Parameters
massthe mass to look for

Definition at line 85 of file aastringcodemassmatching.cpp.

86{
87 std::vector<uint32_t> aa_code_list;
88
89 // auto it_aacode = m_codeMassList.begin();
90
91 auto it_aacode = std::upper_bound(
92 m_codeMassList.begin(),
93 m_codeMassList.end(),
94 mass,
95 [](double mass, const pappso::AaStringCodeMassMatching::aaCodeAndMassRange &mass_range) {
96 return mass_range.mz_range_up > mass;
97 });
98
99 bool previous_out_of_range = false;
100
101 while(it_aacode != m_codeMassList.end())
102 {
103 if(mass < it_aacode->mz_range_low)
104 {
105
106 if(previous_out_of_range)
107 break;
108 previous_out_of_range = true;
109 it_aacode++;
110 }
111 else
112 {
113 if(mass <= it_aacode->mz_range_up)
114 {
115 previous_out_of_range = false;
116 aa_code_list.push_back(it_aacode->code);
117 it_aacode++;
118 }
119 else
120 {
121 it_aacode++;
122 }
123 }
124 }
125 return aa_code_list;
126}

Referenced by pappso::specself::SelfSpectrumDataPoint::fillAntiSpectrumDataPoint(), and pappso::specself::SelfSpectrumDataPoint::fillSelfSpectrumDataPoint().

◆ getAaCodeFromMassList()

std::vector< uint32_t > pappso::AaStringCodeMassMatching::getAaCodeFromMassList ( std::vector< double > &  mass_list) const

Definition at line 181 of file aastringcodemassmatching.cpp.

182{
183 std::sort(mass_list.begin(), mass_list.end(), [](double a, double b) { return a < b; });
184 std::vector<uint32_t> aa_code_list;
185
186 auto it_aacode = m_codeMassList.begin();
187 auto it_mass = mass_list.begin();
188
189 while((it_aacode != m_codeMassList.end()) && (it_mass != mass_list.end()))
190 {
191 if(*it_mass < it_aacode->mz_range_low)
192 {
193 it_mass++;
194 }
195 else
196 {
197 if(*it_mass <= it_aacode->mz_range_up)
198 {
199 aa_code_list.push_back(it_aacode->code);
200 it_aacode++;
201 }
202 else
203 {
204 it_aacode++;
205 }
206 }
207 }
208 return aa_code_list;
209}

References pappso::a, and pappso::b.

◆ getAaCodeFromMassWearingModification()

std::vector< uint32_t > pappso::AaStringCodeMassMatching::getAaCodeFromMassWearingModification ( double  mass,
const Aa aa,
int  quantifier 
) const

get amino acid string code from a single mass delta wearing a specific modification

Parameters
massthe mass to look for
aaamino acid with modification
quantifierthe minimum number of this aa modified required in the given aa sequence

Definition at line 129 of file aastringcodemassmatching.cpp.

132{
133 try
134 {
135 std::vector<uint32_t> aa_code_list;
136
137 double total_modification_mass = aa.getTotalModificationMass();
138 total_modification_mass *= quantifier;
139 mass = mass - total_modification_mass;
140 if(mass < 0)
141 return aa_code_list;
142
143 uint8_t aamodCode = m_aaCode.getAaCode(aa.getLetter());
144
145 auto it_aacode = m_codeMassList.begin();
146
147 while(it_aacode != m_codeMassList.end())
148 {
149 if(mass < it_aacode->mz_range_low)
150 {
151 it_aacode++;
152 }
153 else
154 {
155 if(mass <= it_aacode->mz_range_up)
156 {
157 if(m_aaCodec.uniqueCodeContainsAminoAcid(it_aacode->code, aamodCode, quantifier))
158 {
159 aa_code_list.push_back(it_aacode->code);
160 }
161
162 it_aacode++;
163 }
164 else
165 {
166 it_aacode++;
167 }
168 }
169 }
170 return aa_code_list;
171 }
172 catch(const pappso::PappsoException &err)
173 {
175 QObject::tr("getAaCodeFromMassWearingModification failed :\n%1").arg(err.qwhat()));
176 }
177}
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
Definition aacode.cpp:81
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
virtual const QString & qwhat() const
@ aa
best possible : more than one direct MS2 fragmentation in same MSRUN

References pappso::PappsoException::qwhat().

Referenced by pappso::specself::SelfSpectrumDataPoint::setVariableModification().

◆ getPrecisionPtr()

pappso::PrecisionPtr pappso::AaStringCodeMassMatching::getPrecisionPtr ( ) const

Member Data Documentation

◆ m_aaCode

const AaCode& pappso::AaStringCodeMassMatching::m_aaCode
private

◆ m_aaCodec

AaStringCodec pappso::AaStringCodeMassMatching::m_aaCodec
private

Definition at line 100 of file aastringcodemassmatching.h.

Referenced by AaStringCodeMassMatching().

◆ m_base

uint32_t pappso::AaStringCodeMassMatching::m_base = 0
private

◆ m_codeMassList

std::vector<aaCodeAndMassRange> pappso::AaStringCodeMassMatching::m_codeMassList
private

Definition at line 113 of file aastringcodemassmatching.h.

Referenced by AaStringCodeMassMatching().

◆ m_precision

PrecisionPtr pappso::AaStringCodeMassMatching::m_precision = nullptr
private

Definition at line 97 of file aastringcodemassmatching.h.


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