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 {
43 throw ExceptionOutOfRange(QObject::tr("aa_str_max_size exceeds max size"));
44 }
45
46 QString seq_str = protein.get()->getSequence();
47 m_seqAaCode.clear();
48
49 for(const QChar &aa_str : seq_str)
50 {
51 m_seqAaCode.push_back(codec.getAaCode().getAaCode(aa_str.toLatin1()));
52 }
53
54 for(std::size_t i = 2; i <= aa_str_max_size; i++)
55 {
57 }
58}
uint8_t getAaCode(char aa_letter) const
get the integer code of an amino acid with the one letter code
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.

Referenced by ProteinIntegerCode().

◆ ProteinIntegerCode() [2/2]

ProteinIntegerCode::ProteinIntegerCode ( const ProteinIntegerCode & other)

Copy constructor

Parameters
otherTODO

Definition at line 60 of file proteinintegercode.cpp.

References ProteinIntegerCode(), m_peptideCodedFragments, m_seqAaCode, and msp_protein.

◆ ~ProteinIntegerCode()

ProteinIntegerCode::~ProteinIntegerCode ( )
virtual

Destructor

Definition at line 69 of file proteinintegercode.cpp.

70{
71}

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 86 of file proteinintegercode.cpp.

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

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

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 161 of file proteinintegercode.cpp.

162{
163 std::vector<double> convolution_score;
164
165
166 std::vector<std::uint8_t>::const_iterator it_aa = m_seqAaCode.begin();
167 auto it_couple = m_peptideCodedFragments[0].begin();
168 auto it_trio = m_peptideCodedFragments[1].begin();
169 auto it_quatro = m_peptideCodedFragments[2].begin();
170 auto it_cinqo = m_peptideCodedFragments[3].begin();
171 for(std::uint8_t aa_code [[maybe_unused]] : m_seqAaCode)
172 {
173 convolution_score.push_back(
174 convolutionKernel(code_list_from_spectrum, it_aa, it_couple, it_trio, it_quatro, it_cinqo));
175 it_aa++;
176 it_couple++;
177 it_trio++;
178 it_quatro++;
179 it_cinqo++;
180 }
181
182 return convolution_score;
183}
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

References convolutionKernel(), m_peptideCodedFragments, and m_seqAaCode.

◆ 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 186 of file proteinintegercode.cpp.

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

Referenced by convolution().

◆ getPeptideCodedFragment()

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

Definition at line 107 of file proteinintegercode.cpp.

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

References m_peptideCodedFragments.

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

◆ getProteinSp()

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

Definition at line 79 of file proteinintegercode.cpp.

80{
81 return msp_protein;
82}

References msp_protein.

◆ getSeqAaCode()

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

Definition at line 73 of file proteinintegercode.cpp.

74{
75 return m_seqAaCode;
76}

References m_seqAaCode.

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 125 of file proteinintegercode.cpp.

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

References m_peptideCodedFragments.

Member Data Documentation

◆ m_peptideCodedFragments

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

◆ m_seqAaCode

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

◆ msp_protein

ProteinSp pappso::ProteinIntegerCode::msp_protein
private

Definition at line 101 of file proteinintegercode.h.

Referenced by ProteinIntegerCode(), ProteinIntegerCode(), and getProteinSp().


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