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

#include <proteinintegercode.h>

Public Member Functions

 ProteinIntegerCode (ProteinSp protein, const AaStringCodec &codec, std::size_t aa_str_max_size=5)
 
 ProteinIntegerCode (const ProteinIntegerCode &other)
 
virtual ~ProteinIntegerCode ()
 
const std::vector< std::uint8_t > & getSeqAaCode () const
 
const std::vector< std::uint32_t > & getPeptideCodedFragment (std::size_t size) const
 
std::vector< std::pair< std::size_t, std::uint32_t > > match (const std::vector< uint32_t > &code_list) const
 list of positions and matched codes along protein sequence
 
std::vector< double > convolution (const std::vector< uint32_t > &code_list_from_spectrum) const
 process convolution of spectrum code list along protein sequence
 
pappso::ProteinSp getProteinSp () const
 

Private Member Functions

std::vector< std::uint32_t > computePeptideCodeFragments (const AaStringCodec &codec, std::size_t fragment_size) const
 
double convolutionKernel (const std::vector< uint32_t > &spectrum_code_list, std::vector< std::uint8_t >::const_iterator it_aa, std::vector< std::uint32_t >::const_iterator it_couple, std::vector< std::uint32_t >::const_iterator it_trio, std::vector< std::uint32_t >::const_iterator it_quatro, std::vector< std::uint32_t >::const_iterator it_cinqo) const
 

Private Attributes

ProteinSp msp_protein
 
std::vector< std::uint8_t > m_seqAaCode
 
std::vector< std::vector< std::uint32_t > > m_peptideCodedFragments
 

Detailed Description

Definition at line 43 of file proteinintegercode.h.

Constructor & Destructor Documentation

◆ ProteinIntegerCode() [1/2]

ProteinIntegerCode::ProteinIntegerCode ( ProteinSp protein,
const AaStringCodec & codec,
std::size_t aa_str_max_size = 5 )

Default constructor

Definition at line 35 of file proteinintegercode.cpp.

38{
39 msp_protein = protein;
40
41 if(aa_str_max_size > 7)
42 {
44 QObject::tr("aa_str_max_size exceeds max size"));
45 }
46
47 QString seq_str = protein.get()->getSequence();
48 m_seqAaCode.clear();
49
50 for(const QChar &aa_str : seq_str)
51 {
52 m_seqAaCode.push_back(codec.getAaCode().getAaCode(aa_str.toLatin1()));
53 }
54
55 for(std::size_t i = 2; i <= aa_str_max_size; i++)
56 {
58 }
59}
uint8_t getAaCode(char aa_letter) const
Definition aacode.cpp:81
const AaCode & getAaCode() const
std::vector< std::uint8_t > m_seqAaCode
std::vector< std::vector< std::uint32_t > > m_peptideCodedFragments
std::vector< std::uint32_t > computePeptideCodeFragments(const AaStringCodec &codec, std::size_t fragment_size) const
const QString & getSequence() const
Definition protein.cpp:122

References computePeptideCodeFragments(), pappso::AaCode::getAaCode(), pappso::AaStringCodec::getAaCode(), pappso::Protein::getSequence(), m_peptideCodedFragments, m_seqAaCode, and msp_protein.

◆ ProteinIntegerCode() [2/2]

ProteinIntegerCode::ProteinIntegerCode ( const ProteinIntegerCode & other)

Copy constructor

Parameters
otherTODO

Definition at line 61 of file proteinintegercode.cpp.

References m_peptideCodedFragments, m_seqAaCode, and msp_protein.

◆ ~ProteinIntegerCode()

ProteinIntegerCode::~ProteinIntegerCode ( )
virtual

Destructor

Definition at line 70 of file proteinintegercode.cpp.

71{
72}

Member Function Documentation

◆ computePeptideCodeFragments()

std::vector< std::uint32_t > pappso::ProteinIntegerCode::computePeptideCodeFragments ( const AaStringCodec & codec,
std::size_t fragment_size ) const
private

Definition at line 87 of file proteinintegercode.cpp.

89{
90 std::vector<std::uint32_t> fragments;
91
92 int max = (m_seqAaCode.size() - fragment_size);
93 if(max < 0)
94 return fragments;
95
96 auto it = m_seqAaCode.begin();
97 for(int i = 0; i <= max; i++)
98 {
99 fragments.push_back(codec.codeLlc(it, fragment_size));
100 it++;
101 }
102
103 return fragments;
104}
uint32_t codeLlc(const QString &aa_str) const
get the lowest common denominator integer from amino acide suite string
@ max
maximum of intensities

References pappso::AaStringCodec::codeLlc(), and pappso::max.

Referenced by ProteinIntegerCode().

◆ convolution()

std::vector< double > pappso::ProteinIntegerCode::convolution ( const std::vector< uint32_t > & code_list_from_spectrum) const

process convolution of spectrum code list along protein sequence

Parameters
code_list_from_spectrumunique sorted sequence codes given by the spectrum decoder

Definition at line 165 of file proteinintegercode.cpp.

167{
168 std::vector<double> convolution_score;
169
170
171 std::vector<std::uint8_t>::const_iterator it_aa = m_seqAaCode.begin();
172 auto it_couple = m_peptideCodedFragments[0].begin();
173 auto it_trio = m_peptideCodedFragments[1].begin();
174 auto it_quatro = m_peptideCodedFragments[2].begin();
175 auto it_cinqo = m_peptideCodedFragments[3].begin();
176 for(std::uint8_t aa_code [[maybe_unused]] : m_seqAaCode)
177 {
178 convolution_score.push_back(convolutionKernel(code_list_from_spectrum,
179 it_aa,
180 it_couple,
181 it_trio,
182 it_quatro,
183 it_cinqo));
184 it_aa++;
185 it_couple++;
186 it_trio++;
187 it_quatro++;
188 it_cinqo++;
189 }
190
191 return convolution_score;
192}
double convolutionKernel(const std::vector< uint32_t > &spectrum_code_list, std::vector< std::uint8_t >::const_iterator it_aa, std::vector< std::uint32_t >::const_iterator it_couple, std::vector< std::uint32_t >::const_iterator it_trio, std::vector< std::uint32_t >::const_iterator it_quatro, std::vector< std::uint32_t >::const_iterator it_cinqo) const

◆ convolutionKernel()

double pappso::ProteinIntegerCode::convolutionKernel ( const std::vector< uint32_t > & spectrum_code_list,
std::vector< std::uint8_t >::const_iterator it_aa,
std::vector< std::uint32_t >::const_iterator it_couple,
std::vector< std::uint32_t >::const_iterator it_trio,
std::vector< std::uint32_t >::const_iterator it_quatro,
std::vector< std::uint32_t >::const_iterator it_cinqo ) const
private

Definition at line 195 of file proteinintegercode.cpp.

202{
203 double score = 0;
204
205 // single :
206 auto it_end = it_aa + 5;
207 auto it = it_aa;
208 double single_score = 0;
209 while(it != it_end)
210 {
211 if(std::binary_search(spectrum_code_list.begin(),
212 spectrum_code_list.end(),
213 (std::uint32_t)(*it)))
214 {
215 single_score += 1;
216 }
217 else
218 {
219 single_score += 0.1;
220 }
221 it++;
222 }
223
224 // duo
225 auto itduo_end = it_couple + 4;
226 auto itduo = it_couple;
227 double duo_score = 0;
228 while(itduo != itduo_end)
229 {
230 if(std::binary_search(
231 spectrum_code_list.begin(), spectrum_code_list.end(), *itduo))
232 {
233 duo_score += 3;
234 }
235 else
236 {
237 duo_score += 0.2;
238 }
239 itduo++;
240 }
241
242
243 // trio
244 auto it3_end = it_trio + 3;
245 auto it3 = it_trio;
246 double trio_score = 0;
247 while(it3 != it3_end)
248 {
249 if(std::binary_search(
250 spectrum_code_list.begin(), spectrum_code_list.end(), *it3))
251 {
252 trio_score += 6;
253 }
254 else
255 {
256 trio_score += 0.5;
257 }
258 it3++;
259 }
260
261
262 // quatro
263 auto it4_end = it_quatro + 2;
264 auto it4 = it_quatro;
265 double quatro_score = 0;
266 while(it4 != it4_end)
267 {
268 // element < value
269 if(std::binary_search(
270 spectrum_code_list.begin(), spectrum_code_list.end(), *it4))
271 {
272 quatro_score += 8;
273 }
274 quatro_score += 0.8;
275 it4++;
276 }
277
278 // cinqo
279 if(std::binary_search(
280 spectrum_code_list.begin(), spectrum_code_list.end(), *it_cinqo))
281 {
282 score += 10;
283 }
284 else
285 {
286 score += 1;
287 }
288 return score * single_score * duo_score * trio_score * quatro_score;
289}

◆ getPeptideCodedFragment()

const std::vector< std::uint32_t > & pappso::ProteinIntegerCode::getPeptideCodedFragment ( std::size_t size) const

Definition at line 108 of file proteinintegercode.cpp.

109{
110 if(size < 2)
111 {
112
113 throw ExceptionOutOfRange(QObject::tr("size too small"));
114 }
115 std::size_t indice = size - 2;
116 if(indice < m_peptideCodedFragments.size())
117 {
118 return m_peptideCodedFragments.at(indice);
119 }
120
121 throw ExceptionOutOfRange(QObject::tr("size too big"));
122}

Referenced by pappso::ProteinPresenceAbsenceMatrix::fillMatrix().

◆ getProteinSp()

pappso::ProteinSp pappso::ProteinIntegerCode::getProteinSp ( ) const

Definition at line 80 of file proteinintegercode.cpp.

81{
82 return msp_protein;
83}

◆ getSeqAaCode()

const std::vector< std::uint8_t > & pappso::ProteinIntegerCode::getSeqAaCode ( ) const

Definition at line 74 of file proteinintegercode.cpp.

75{
76 return m_seqAaCode;
77}

Referenced by pappso::ProteinPresenceAbsenceMatrix::fillMatrix().

◆ match()

std::vector< std::pair< std::size_t, std::uint32_t > > pappso::ProteinIntegerCode::match ( const std::vector< uint32_t > & code_list) const

list of positions and matched codes along protein sequence

Definition at line 126 of file proteinintegercode.cpp.

128{
129 std::vector<std::pair<std::size_t, std::uint32_t>> return_pos;
130 std::vector<uint32_t> code_list = code_list_in;
131
132 std::sort(code_list.begin(), code_list.end());
133 auto it_end = std::unique(code_list.begin(), code_list.end());
134 for(auto it_code = code_list.begin(); it_code != it_end; it_code++)
135 {
136
137 std::size_t size = 2;
138 for(auto &liste_protein_seq_code : m_peptideCodedFragments)
139 {
140
141 auto it_seq_position = std::find(liste_protein_seq_code.begin(),
142 liste_protein_seq_code.end(),
143 *it_code);
144 while(it_seq_position != liste_protein_seq_code.end())
145 {
146 // found
147 std::size_t position =
148 std::distance(liste_protein_seq_code.begin(), it_seq_position);
149 return_pos.push_back({size, position});
150
151 it_seq_position = std::find(
152 ++it_seq_position, liste_protein_seq_code.end(), *it_code);
153 qDebug();
154 }
155 size++;
156 qDebug();
157 }
158 qDebug();
159 }
160
161 return return_pos;
162}

Member Data Documentation

◆ m_peptideCodedFragments

std::vector<std::vector<std::uint32_t> > pappso::ProteinIntegerCode::m_peptideCodedFragments
private

Definition at line 104 of file proteinintegercode.h.

Referenced by ProteinIntegerCode(), and ProteinIntegerCode().

◆ m_seqAaCode

std::vector<std::uint8_t> pappso::ProteinIntegerCode::m_seqAaCode
private

Definition at line 103 of file proteinintegercode.h.

Referenced by ProteinIntegerCode(), and ProteinIntegerCode().

◆ msp_protein

ProteinSp pappso::ProteinIntegerCode::msp_protein
private

Definition at line 101 of file proteinintegercode.h.

Referenced by ProteinIntegerCode(), and ProteinIntegerCode().


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