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: dcreasy@matrixscience.com $ #
12# $Date: 2022-01-10 16:56:39 +0000 $ #
13# $Revision: 2dcc5a5c97c2ef1f6d52f0f45adbf5cbce43ce2e | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
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#else // SWIG Multiple return values
96 int isPeptideQuantifiable(int q, int p, const ms_protein *protein, int peptideIndex, std::string & OUTPUT) const;
97 int isPeptideQualityOK(int q, int p, std::string & OUTPUT) const;
98#endif
100 int testProteinTerminusExclusion(int q, int p, const ms_protein *, int peptideIndex, std::string & reason) const;
101
103 int createMissingComponents(matrix_science::ms_ms1quant_match * match) const;
104
105 // For a given file_index (1..num raw files), return the fraction
106 int getFraction(const int file_index) const;
107
109 const matrix_science::ms_protein & hit,
110 int iPeptide,
116 std::string * reason = 0 ) const;
117
119 const matrix_science::ms_peptide & peptide,
124 std::string * reason = 0,
125 const matrix_science::ms_protein * hit = 0,
126 int iPeptide = 0
127 ) const;
128
129 private:
130 // No copying.
132 ms_quant_helper& operator=(const ms_quant_helper& right);
133
134 void applyComponentMods(
135 std::string * newVarMods,
136 std::string * newSummedMods,
137 const matrix_science::ms_quant_component & targetComponent,
138 const std::string & pepStr,
139 const std::string & labelFreeVarMods,
140 bool isProteinNterm,
141 bool isProteinCterm
142 ) const;
143
144 void applyComponentMods(
145 std::string * newVarMods,
146 std::string * newSummedMods,
147 const matrix_science::ms_quant_component & targetComponent,
148 const matrix_science::ms_quant_component & sourceComponent,
149 const std::string & pepStr,
150 const std::string & labelFreeVarMods,
151 const std::string & sourceVarMods,
152 const std::string & sourceSummedMods,
153 bool isProteinNterm,
154 bool isProteinCterm
155 ) const;
156
157 char ModLetter(const std::string & modName) const;
158
159 const ms_peptidesummary &pepsum_;
160 const ms_quant_method &method_;
161 const ms_umod_configfile & umodfile_;
162 const int this_file_index_;
163 std::map<int, int> indexToFraction_;
164
165 std::map<char, std::string> varModTitles_;
166 std::map<char, std::string> fixedModTitles_;
167
168 bool haveRequiredMods_;
169 std::string sortedRequiredFixedMods_;
170 std::string sortedRequiredVarMods_;
171
172 bool haveExclusions_;
173 bool haveProteinTerminusTest_;
174
175 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);
176 bool initFixedExclusion(const ms_quant_modgroup *modgroup, const ms_umod_configfile &umodfile);
177
178 int testRequiredMods(const std::string &peptide_str, const std::string &varmods_str, std::string & reason) const;
179
180 int testFixedExclusions(const std::string &peptide_str, const std::string &varmods_str, const ms_protein *protein, int peptideIndex, std::string & reason) const;
181 int testVariableExclusions(const std::string &peptide_str, const std::string &varmods_str, const ms_protein *protein, int peptideIndex, std::string & reason) const;
182
183 bool requireUniquePeptide_;
184 int minPrecursorCharge_;
185 double ionsScoreThreshold_;
186 double expectationValueThreshold_;
187 bool mustPassIdentityThreshold_;
188 bool mustPassHomologyThreshold_;
189 bool isAverageProtocol_;
190
191//Warning 325: Nested struct not currently supported
192#ifndef SWIG
193 typedef struct {
194 int why;
195 std::string fmt;
196 msparser_internal::modification_sites_t modsites;
197 } fixed_exclusion_t;
198
199 typedef struct {
200 int why;
201 std::string fmt;
202 char varmod_id;
203 msparser_internal::modification_sites_t modsites;
204 } variable_exclusion_t;
205
206 std::list<fixed_exclusion_t> fixedExclusions_;
207 std::list<variable_exclusion_t> variableExclusions_;
208
209 std::list< std::list<variable_exclusion_t> > qualityExclusions_;
210
211 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);
212#endif
213
214 bool peptideFitsExclusiveGroup(const std::string &peptide_str, const std::string &varmods_str) const;
215 bool peptideFitsExclusiveGroupMods(const std::string &peptide_str, const std::string &varmods_str, const std::list<variable_exclusion_t> &qualityExclusions) const;
216
217 static bool mod_can_be_fixed(char site, int position);
218 static bool excluded_due_to_fixed_mod(const std::string &peptide_str, char site, int position);
219 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);
220
221 }; // end of quantitation_group
223} // matrix_science namespace
224
225#endif // MS_QUANT_HELPER_HPP
226
227/*------------------------------- 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