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 35 of file aastringcodemassmatching.cpp.

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

67 : m_precision(other.m_precision),
68 m_aaCode(other.m_aaCode),
69 m_aaCodec(other.m_aaCode)
70{
71 m_base = m_aaCode.getSize() + 1;
72}

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

◆ ~AaStringCodeMassMatching()

AaStringCodeMassMatching::~AaStringCodeMassMatching ( )

Destructor

Definition at line 74 of file aastringcodemassmatching.cpp.

75{
76}

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 210 of file aastringcodemassmatching.cpp.

212{
213 std::sort(code_list.begin(), code_list.end(), [](uint32_t a, uint32_t b) {
214 return a < b;
215 });
216 std::vector<uint32_t> filtered_aa_code_list;
217
218 std::vector<uint8_t> aa_ok;
219
220 auto it = code_list.begin();
221 while(*it < m_base)
222 {
223 aa_ok.push_back((uint8_t)*it);
224 // qDebug() << (uint8_t)*it << " "
225 // << m_aaCode.getAa((uint8_t)*it).getLetter();
226 it++;
227 }
228
229 for(uint32_t code : code_list)
230 {
231 if(m_aaCodec.codeOnlyContains(code, aa_ok))
232 {
233 filtered_aa_code_list.push_back(code);
234 }
235 }
236 return filtered_aa_code_list;
237}
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 87 of file aastringcodemassmatching.cpp.

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

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 176 of file aastringcodemassmatching.cpp.

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

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 132 of file aastringcodemassmatching.cpp.

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 {
158 it_aacode->code, aamodCode, quantifier))
159 {
160 aa_code_list.push_back(it_aacode->code);
161 }
162
163 it_aacode++;
164 }
165 else
166 {
167 it_aacode++;
168 }
169 }
170 }
171 return aa_code_list;
172}
virtual const char & getLetter() const
Definition aabase.cpp:433
uint8_t getAaCode(char aa_letter) const
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
double getTotalModificationMass() const
get the sum of mass modifications
Definition aa.cpp:79

References pappso::AaBase::getLetter(), and pappso::Aa::getTotalModificationMass().

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: