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

#include <proteinpresenceabsencematrix.h>

Public Types

enum class  ProteinPresenceAbsenceMatrixElement : std::uint8_t { absent = 0 , present = 1 }

Public Member Functions

 ProteinPresenceAbsenceMatrix ()
 ProteinPresenceAbsenceMatrix (const ProteinPresenceAbsenceMatrix &other)
virtual ~ProteinPresenceAbsenceMatrix ()
ProteinPresenceAbsenceMatrixoperator= (const ProteinPresenceAbsenceMatrix &other)
void fillMatrix (const pappso::ProteinIntegerCode &coded_protein, const std::vector< uint32_t > &code_list_from_spectrum)
std::vector< double > convolution () const
 process convolution of spectrum code list along protein sequence
const boost::numeric::ublas::matrix< pappso::ProteinPresenceAbsenceMatrix::ProteinPresenceAbsenceMatrixElement > & getPresenceAbsenceMatrix () const

Private Member Functions

double convolutionKernel (std::size_t position) const
double getScore (std::size_t seq_position, std::size_t aa_fragment_size) const

Private Attributes

boost::numeric::ublas::matrix< ProteinPresenceAbsenceMatrixElementm_presenceAbsenceMatrix

Detailed Description

Definition at line 43 of file proteinpresenceabsencematrix.h.

Member Enumeration Documentation

◆ ProteinPresenceAbsenceMatrixElement

Enumerator
absent 

the aa sequence code is not present

present 

the aa sequence code is present

Definition at line 72 of file proteinpresenceabsencematrix.h.

73 {
74 absent = 0, ///< the aa sequence code is not present
75 present = 1, ///< the aa sequence code is present
76 };

Constructor & Destructor Documentation

◆ ProteinPresenceAbsenceMatrix() [1/2]

pappso::ProteinPresenceAbsenceMatrix::ProteinPresenceAbsenceMatrix ( )

Default constructor

Definition at line 32 of file proteinpresenceabsencematrix.cpp.

33{
34}

◆ ProteinPresenceAbsenceMatrix() [2/2]

pappso::ProteinPresenceAbsenceMatrix::ProteinPresenceAbsenceMatrix ( const ProteinPresenceAbsenceMatrix & other)

copy constructor

Definition at line 41 of file proteinpresenceabsencematrix.cpp.

43{
44 m_presenceAbsenceMatrix = other.m_presenceAbsenceMatrix;
45}
boost::numeric::ublas::matrix< ProteinPresenceAbsenceMatrixElement > m_presenceAbsenceMatrix

References m_presenceAbsenceMatrix.

◆ ~ProteinPresenceAbsenceMatrix()

pappso::ProteinPresenceAbsenceMatrix::~ProteinPresenceAbsenceMatrix ( )
virtual

Destructor

Definition at line 36 of file proteinpresenceabsencematrix.cpp.

37{
38}

Member Function Documentation

◆ convolution()

std::vector< double > pappso::ProteinPresenceAbsenceMatrix::convolution ( ) const

process convolution of spectrum code list along protein sequence

Definition at line 139 of file proteinpresenceabsencematrix.cpp.

140{
141
142 std::vector<double> convolution_score;
143
144 for(std::size_t ipos = 0; ipos < m_presenceAbsenceMatrix.size1(); ipos++)
145 {
146 convolution_score.push_back(convolutionKernel(ipos));
147 }
148
149 return convolution_score;
150}
double convolutionKernel(std::size_t position) const

References convolutionKernel(), and m_presenceAbsenceMatrix.

◆ convolutionKernel()

double pappso::ProteinPresenceAbsenceMatrix::convolutionKernel ( std::size_t position) const
private

Definition at line 198 of file proteinpresenceabsencematrix.cpp.

199{
200 double score = 0;
201
202 std::size_t size_seq = m_presenceAbsenceMatrix.size1();
203 // single :
204 double single_score = 0;
205 std::size_t endpos = std::min(position + 5, size_seq);
206 for(std::size_t ipos = position; ipos < endpos; ipos++)
207 {
208 single_score += getScore(ipos, 0);
209 }
210
211 // duo
212 double duo_score = 0;
213 endpos = std::min(position + 4, size_seq);
214 for(std::size_t ipos = position; ipos < endpos; ipos++)
215 {
216 duo_score += getScore(ipos, 1);
217 }
218
219
220 // trio
221 double trio_score = 0;
222 endpos = std::min(position + 3, size_seq);
223 for(std::size_t ipos = position; ipos < endpos; ipos++)
224 {
225 trio_score += getScore(ipos, 2);
226 }
227
228
229 // quatro
230 double quatro_score = 0;
231 endpos = std::min(position + 2, size_seq);
232 for(std::size_t ipos = position; ipos < endpos; ipos++)
233 {
234 quatro_score += getScore(ipos, 3);
235 }
236
237 // cinqo
238 score += getScore(position, 4);
239 return score * single_score * duo_score * trio_score * quatro_score;
240}
double getScore(std::size_t seq_position, std::size_t aa_fragment_size) const

References getScore(), and m_presenceAbsenceMatrix.

Referenced by convolution().

◆ fillMatrix()

void pappso::ProteinPresenceAbsenceMatrix::fillMatrix ( const pappso::ProteinIntegerCode & coded_protein,
const std::vector< uint32_t > & code_list_from_spectrum )

Definition at line 64 of file proteinpresenceabsencematrix.cpp.

67{
68 const std::vector<std::uint8_t> &seq_aa_code = coded_protein.getSeqAaCode();
69
70 m_presenceAbsenceMatrix.resize(seq_aa_code.size(), 5);
71 std::vector<std::uint8_t>::const_iterator it_aa = seq_aa_code.begin();
72 auto it_couple = coded_protein.getPeptideCodedFragment(2).begin();
73 auto it_trio = coded_protein.getPeptideCodedFragment(3).begin();
74 auto it_quatro = coded_protein.getPeptideCodedFragment(4).begin();
75 auto it_cinqo = coded_protein.getPeptideCodedFragment(5).begin();
76
77 for(std::size_t i = 0; i < seq_aa_code.size(); i++)
78 {
79 if(std::binary_search(
80 code_list_from_spectrum.begin(), code_list_from_spectrum.end(), (std::uint32_t)(*it_aa)))
81 {
82 // presence
84 }
85 else
86 {
88 }
89 if(std::binary_search(
90 code_list_from_spectrum.begin(), code_list_from_spectrum.end(), *it_couple))
91 {
92 // presence
94 }
95 else
96 {
98 }
99 if(std::binary_search(
100 code_list_from_spectrum.begin(), code_list_from_spectrum.end(), *it_trio))
101 {
102 // presence
104 }
105 else
106 {
108 }
109 if(std::binary_search(
110 code_list_from_spectrum.begin(), code_list_from_spectrum.end(), *it_quatro))
111 {
112 // presence
114 }
115 else
116 {
118 }
119 if(std::binary_search(
120 code_list_from_spectrum.begin(), code_list_from_spectrum.end(), *it_cinqo))
121 {
122 // presence
124 }
125 else
126 {
128 }
129 it_aa++;
130 it_couple++;
131 it_trio++;
132 it_quatro++;
133 it_cinqo++;
134 }
135}
const std::vector< std::uint32_t > & getPeptideCodedFragment(std::size_t size) const
const std::vector< std::uint8_t > & getSeqAaCode() const

References absent, pappso::ProteinIntegerCode::getPeptideCodedFragment(), pappso::ProteinIntegerCode::getSeqAaCode(), m_presenceAbsenceMatrix, and present.

◆ getPresenceAbsenceMatrix()

const boost::numeric::ublas::matrix< pappso::ProteinPresenceAbsenceMatrix::ProteinPresenceAbsenceMatrixElement > & pappso::ProteinPresenceAbsenceMatrix::getPresenceAbsenceMatrix ( ) const

Definition at line 58 of file proteinpresenceabsencematrix.cpp.

59{
61}

References m_presenceAbsenceMatrix.

◆ getScore()

double pappso::ProteinPresenceAbsenceMatrix::getScore ( std::size_t seq_position,
std::size_t aa_fragment_size ) const
private

Definition at line 153 of file proteinpresenceabsencematrix.cpp.

155{
156 if(m_presenceAbsenceMatrix(seq_position, aa_fragment_size) ==
158 {
159 switch(aa_fragment_size)
160 {
161 case 0:
162 return 1;
163 case 1:
164 return 3;
165 case 2:
166 return 6;
167 case 3:
168 return 8;
169 case 4:
170 return 10;
171 default:
172 break;
173 }
174 }
175 else
176 {
177 // absent
178 switch(aa_fragment_size)
179 {
180 case 0:
181 return 0.1;
182 case 1:
183 return 0.3;
184 case 2:
185 return 0.6;
186 case 3:
187 return 0.8;
188 case 4:
189 return 1;
190 default:
191 break;
192 }
193 }
194 return 0.1;
195}

References m_presenceAbsenceMatrix, and present.

Referenced by convolutionKernel().

◆ operator=()

pappso::ProteinPresenceAbsenceMatrix & pappso::ProteinPresenceAbsenceMatrix::operator= ( const ProteinPresenceAbsenceMatrix & other)

Definition at line 48 of file proteinpresenceabsencematrix.cpp.

49{
50 m_presenceAbsenceMatrix = other.m_presenceAbsenceMatrix;
51
52 return *this;
53}

References m_presenceAbsenceMatrix.

Member Data Documentation

◆ m_presenceAbsenceMatrix

boost::numeric::ublas::matrix<ProteinPresenceAbsenceMatrixElement> pappso::ProteinPresenceAbsenceMatrix::m_presenceAbsenceMatrix
private

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