Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_quant_helper.hpp
1/*
2##############################################################################
3# file: ms_quant_helper.hpp #
4# 'msparser' toolkit #
5# Helper routines for peptide and protein quantitation #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2013 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11# $Author: robertog@matrixscience.com $ #
12# $Date: 2024-12-06 16:25:26 +0000 $ #
13# $Revision: 53c727846710c2257d3679fe39685ff0517ec176 | MSPARSER_REL_3_1_0-2025-07-27-0-gea47708fac $ #
14# $NoKeywords:: $ #
15##############################################################################
16*/
17
18#ifndef MS_QUANT_HELPER_HPP
19#define MS_QUANT_HELPER_HPP
20
21
22#include <string>
23#include <vector>
24#include <list>
25
26namespace msparser_internal {
27 typedef std::pair<char, int> modification_site_t;
28 typedef std::vector<modification_site_t> modification_sites_t;
29 typedef std::map<std::string, char> varmod_title_map_t;
30}
31
32namespace matrix_science {
33 class ms_quant_method;
34 class ms_quant_localdef;
35 class ms_quant_unmodified;
36 class ms_peptide;
37 class ms_peptidesummary;
38 class ms_protein;
39 class ms_ms1quant_match;
40
47
49 class MS_MASCOTRESFILE_API ms_quant_helper: public ms_errors
50 {
51 public:
54 PEPTIDE_IS_QUANTIFIABLE = 0x0000,
55 PEPTIDE_HAS_NO_REQUIRED_FIXEDMOD = 0x0001,
56 PEPTIDE_HAS_NO_REQUIRED_VARMOD = 0x0002,
57 PEPTIDE_HAS_EXCLUDED_FIXEDMOD = 0x0010,
58 PEPTIDE_HAS_EXCLUDED_LOCAL_FIXEDMOD = 0x0011,
59 PEPTIDE_HAS_EXCLUDED_VARMOD = 0x0012,
60 PEPTIDE_HAS_UNMODIFIED_SITE = 0x0013,
61 PEPTIDE_HAS_EXCLUDED_LOCAL_VARMOD = 0x0014,
62 PEPTIDE_HAS_NO_EXCLUSIVE_MODS = 0x0015,
63
64 PEPTIDE_QUANTIFIABILITY_UNAVAILABLE = 0xf000
65 };
66
69 PEPTIDE_QUALITY_IS_OK = 0x0000,
70 PEPTIDE_CHARGE_BELOW_PRECURSOR_MIN = 0x0001,
71 PEPTIDE_SCORE_BELOW_SCORE_THR = 0x0002,
72 PEPTIDE_EXPECT_ABOVE_THRESHOLD = 0x0003,
73 PEPTIDE_SCORE_BELOW_IDENTITY_THR = 0x0004,
74 PEPTIDE_SCORE_BELOW_IDENTITY_THR_NOHOM = 0x0005,
75 PEPTIDE_SCORE_BELOW_HOMOLOGY_THR = 0x0006,
76 PEPTIDE_NOT_UNIQUE = 0x0007,
77
78 PEPTIDE_QUALITY_UNAVAILABLE = 0xf000
79 };
80
82 ms_quant_helper(const ms_peptidesummary &pepsum, const ms_quant_method &qm, const ms_umod_configfile &umodfile, const int file_index = ms_quant_file_index::file_index_value_not_set);
83
86
87 const ms_peptidesummary & getSummary() const;
88 const ms_quant_method & getMethod() const;
89#ifndef SWIG
91 int isPeptideQuantifiable(int q, int p, const ms_protein *protein, int peptideIndex, std::string & reasonStrRef) const;
92
94 int isPeptideQualityOK(int q, int p, std::string & reasonStrRef) const;
95
97 int isPeptideQualityOK(const ms_peptide* pep, std::string & resonStrRef) const;
98
99#else // SWIG Multiple return values
100 int isPeptideQuantifiable(int q, int p, const ms_protein *protein, int peptideIndex, std::string & OUTPUT) const;
101 int isPeptideQualityOK(int q, int p, std::string & OUTPUT) const;
102#endif
104 int testProteinTerminusExclusion(int q, int p, const ms_protein *, int peptideIndex, std::string & reason) const;
105
107 int createMissingComponents(matrix_science::ms_ms1quant_match * match) const;
108
109 // For a given file_index (1..num raw files), return the fraction
110 int getFraction(const int file_index) const;
111
113 const matrix_science::ms_protein & hit,
114 int iPeptide,
120 std::string * reason = 0 ) const;
121
123 const matrix_science::ms_peptide & peptide,
128 std::string * reason = 0,
129 const matrix_science::ms_protein * hit = 0,
130 int iPeptide = 0
131 ) const;
132
133 private:
134 // No copying.
136 ms_quant_helper& operator=(const ms_quant_helper& right);
137
138 void applyComponentMods(
139 std::string * newVarMods,
140 std::string * newSummedMods,
141 const matrix_science::ms_quant_component & targetComponent,
142 const std::string & pepStr,
143 const std::string & labelFreeVarMods,
144 bool isProteinNterm,
145 bool isProteinCterm
146 ) const;
147
148 void applyComponentMods(
149 std::string * newVarMods,
150 std::string * newSummedMods,
151 const matrix_science::ms_quant_component & targetComponent,
152 const matrix_science::ms_quant_component & sourceComponent,
153 const std::string & pepStr,
154 const std::string & labelFreeVarMods,
155 const std::string & sourceVarMods,
156 const std::string & sourceSummedMods,
157 bool isProteinNterm,
158 bool isProteinCterm
159 ) const;
160
161 char ModLetter(const std::string & modName) const;
162
163 const ms_peptidesummary &pepsum_;
164 const ms_quant_method &method_;
165 const ms_umod_configfile & umodfile_;
166 const int this_file_index_;
167 std::map<int, int> indexToFraction_;
168
169 std::map<char, std::string> varModTitles_;
170 std::map<char, std::string> fixedModTitles_;
171
172 bool haveRequiredMods_;
173 std::string sortedRequiredFixedMods_;
174 std::string sortedRequiredVarMods_;
175
176 bool haveExclusions_;
177 bool haveProteinTerminusTest_;
178
179 bool initRequiredMods(const ms_quant_modgroup *modgroup, const ms_umod_configfile &umodfile, const msparser_internal::varmod_title_map_t &varmod_title_map, std::set<char> &requiredFixedMods, std::set<char> &requiredVarMods);
180 bool initFixedExclusion(const ms_quant_modgroup *modgroup, const ms_umod_configfile &umodfile);
181
182 int testRequiredMods(const std::string &peptide_str, const std::string &varmods_str, std::string & reason) const;
183
184 int testFixedExclusions(const std::string &peptide_str, const std::string &varmods_str, const ms_protein *protein, int peptideIndex, std::string & reason) const;
185 int testVariableExclusions(const std::string &peptide_str, const std::string &varmods_str, const ms_protein *protein, int peptideIndex, std::string & reason) const;
186
187 bool requireUniquePeptide_;
188 int minPrecursorCharge_;
189 double ionsScoreThreshold_;
190 double expectationValueThreshold_;
191 bool mustPassIdentityThreshold_;
192 bool mustPassHomologyThreshold_;
193 bool isAverageProtocol_;
194
195//Warning 325: Nested struct not currently supported
196#ifndef SWIG
197 typedef struct {
198 int why;
199 std::string fmt;
200 msparser_internal::modification_sites_t modsites;
201 } fixed_exclusion_t;
202
203 typedef struct {
204 int why;
205 std::string fmt;
206 char varmod_id;
207 msparser_internal::modification_sites_t modsites;
208 } variable_exclusion_t;
209
210 std::list<fixed_exclusion_t> fixedExclusions_;
211 std::list<variable_exclusion_t> variableExclusions_;
212
213 std::list< std::list<variable_exclusion_t> > qualityExclusions_;
214
215 bool initVariableExclusion(const ms_quant_modgroup *modgroup, const ms_umod_configfile &umodfile, const msparser_internal::varmod_title_map_t &varmod_title_map, std::list<variable_exclusion_t> &variableExclusions);
216#endif
217
218 bool peptideFitsExclusiveGroup(const std::string &peptide_str, const std::string &varmods_str) const;
219 bool peptideFitsExclusiveGroupMods(const std::string &peptide_str, const std::string &varmods_str, const std::list<variable_exclusion_t> &qualityExclusions) const;
220
221 static bool mod_can_be_fixed(char site, int position);
222 static bool excluded_due_to_fixed_mod(const std::string &peptide_str, char site, int position);
223 static bool excluded_due_to_variable_mod(const std::string &peptide_str, const std::string &varmods_str, char site, int position, char varmod_id, const ms_protein *protein, int peptideIndex);
224
225 }; // end of quantitation_group
227} // matrix_science namespace
228
229#endif // MS_QUANT_HELPER_HPP
230
231/*------------------------------- End of File -------------------------------*/
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
QUANT_COMPONENT_STATUS
Return codes for getQuantitationComponentForPeptide().
Definition: ms_mascotresults.hpp:279
A peptide that has been matched, in quantitation, to a protein hit.
Definition: ms_ms1quant_match.hpp:47
peptideStatus
Status codes from fitting peptides.
Definition: ms_ms1quant_peptide_status.hpp:48
This class encapsulates a peptide from the mascot results file.
Definition: ms_peptide.hpp:57
Use this class to get peptide summary results.
Definition: ms_peptidesummary.hpp:51
This class encapsulates a protein in the mascot results file.
Definition: ms_protein.hpp:57
An object of this class represent a single component element in quantitation.xml.
Definition: ms_quant_component.hpp:48
Helper routines for peptide quantitation.
Definition: ms_quant_helper.hpp:50
PEPTIDE_QUANTIFIABILITY
Possible reasons a peptide is not quantifiable using a given quantitation method.
Definition: ms_quant_helper.hpp:53
PEPTIDE_QUALITY
Possible reasons why a peptide does not pass quality tests using a given quantitation method.
Definition: ms_quant_helper.hpp:68
An object of this class represent a single quantitation method from quantitation.xml.
Definition: ms_quant_method.hpp:51
An object of this class represent a single modification group element in quantitation....
Definition: ms_quant_modgroup.hpp:46
This class represents the file unimod.xml.
Definition: ms_umod_configfile.hpp:54