Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_aahelper.hpp
1/*
2##############################################################################
3# File: ms_aahelper.hpp #
4# Mascot Parser toolkit #
5# Utility functions for generating peptides, peptide and fragment masses #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2006 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11# $Source: parser/inc/ms_aahelper.hpp $
12# $Author: robertog@matrixscience.com $
13# $Date: 2022-06-13 11:48:05 +0100 $
14# $Revision: 8fe02c5d122124d6c17183492bfe19018028b6e5 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
15##############################################################################
16*/
17
18#ifndef MS_AAHELPER_HPP
19#define MS_AAHELPER_HPP
20
21
22#include <string>
23#include <vector>
24
25
26namespace matrix_science {
34 class MS_MASCOTRESFILE_API ms_aahelper: public ms_errors
35 {
36 public:
38
47 enum FRAG_NL {
48 FRAG_NL_PRIMARY = 0x0001,
49 FRAG_NL_SECONDARY = 0x0010
50 };
51
54
56 ms_aahelper(const ms_mascotresfilebase& resfile,
57 const char * enzymeFileName,
58 const char * quantSchemaFilePath = "http://www.matrixscience.com/xmlns/schema/quantitation_2 ../html/xmlns/schema/quantitation_2/quantitation_2.xsd http://www.matrixscience.com/xmlns/schema/quantitation_1 ../html/xmlns/schema/quantitation_1/quantitation_1.xsd",
59 const char * unimodSchemaFilePath = "http://www.unimod.org/xmlns/schema/unimod_2 ../html/xmlns/schema/unimod_2/unimod_2.xsd");
60
62 ms_aahelper(const ms_mascotresults & summary,
63 const char * enzymeFileName,
64 const char * quantSchemaFilePath = "http://www.matrixscience.com/xmlns/schema/quantitation_2 ../html/xmlns/schema/quantitation_2/quantitation_2.xsd http://www.matrixscience.com/xmlns/schema/quantitation_1 ../html/xmlns/schema/quantitation_1/quantitation_1.xsd",
65 const char * unimodSchemaFilePath = "http://www.unimod.org/xmlns/schema/unimod_2 ../html/xmlns/schema/unimod_2/unimod_2.xsd");
66
68 ms_aahelper(const ms_aahelper& right);
69
72
73#ifndef SWIG
75 ms_aahelper& operator=(const ms_aahelper& right);
76#endif
78 void copyFrom(const ms_aahelper* right);
79
81 void defaultValues();
82
84 void setEnzyme(const ms_enzyme* enzyme);
85
87 const ms_enzyme* getEnzyme() const;
88
90 void setMasses(const ms_masses *masses);
91
93 const ms_masses* getMasses() const;
94
96 void setAvailableModifications(const ms_modvector *fixedModVector,
97 const ms_modvector *varModVector);
98
100 ms_modvector getFixedMods() const;
101
103 ms_modvector getVarMods() const;
104
106 void startIteratePeptides(const char* sequenceProtein,
107 const int sizeProtein,
108 const int pfa);
109
111 bool getNextPeptide();
112
114 int getPepStart() const;
115
117 int getPepEnd() const;
118
120 int getMissed() const;
121
123 void stopIteratePeptides();
124
126 double calcPeptideMZ(const char* proteinStr,
127 const int proteinLen,
128 const int startPos,
129 const int endPos,
130 const std::vector< int > numThatMustBeModded,
131 const int charge,
132 const MASS_TYPE massType,
133 ms_errs *err) const;
134
136 ms_peptide createPeptide(const char* proteinStr,
137 const int proteinLen,
138 const int startPos,
139 const int endPos,
140 const std::vector< int > varMods,
141 const std::vector< int > varModsWhichNl,
142 const int charge,
143 const MASS_TYPE massType,
144 ms_errs *err) const;
145
147 ms_peptide createPeptide(const char* proteinStr,
148 const int proteinLen,
149 const int startPos,
150 const int endPos,
151 const std::vector< int > varMods,
152 const std::vector< int > varModsWhichNl,
153 const std::vector< int > summedMods,
154 const std::vector< int > summedModsWhichNl,
155 const int charge,
156 const MASS_TYPE massType,
157 ms_errs *err) const;
158
160 ms_peptide createCrosslinkedPeptide(const ms_peptide &pepAlpha,
161 const ms_peptide &pepBeta,
162 const ms_linker_site_vector &linkedSites,
163 ms_errs *err) const;
164
166 std::vector< double > calcFragments(const ms_peptide* peptide,
167 const int seriesID,
168 const bool doubleCharged,
169 const double minMass,
170 const double maxMass,
171 const MASS_TYPE massType,
172 ms_fragmentvector* fragments,
173 ms_errs* err,
174 const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
175
177 bool calcFragmentsEx(const ms_peptide* peptide,
178 const int seriesID,
179 const int fragCharge,
180 const double minMass,
181 const double maxMass,
182 const MASS_TYPE massType,
183 ms_fragmentvector* fragments,
184 ms_errs* err,
185 const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
186
187#ifndef SWIG
189 std::vector< double > calcFragments(const ms_peptide* peptide,
190 const int seriesID,
191 const bool doubleCharged,
192 const double minMass,
193 const double maxMass,
194 const MASS_TYPE massType,
195 std::vector< ms_fragment > *fragments,
196 ms_errs* err,
197 const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
198
200 bool calcFragmentsEx(const ms_peptide* peptide,
201 const int seriesID,
202 const int fragCharge,
203 const double minMass,
204 const double maxMass,
205 const MASS_TYPE massType,
206 std::vector< ms_fragment > *fragments,
207 ms_errs* err,
208 const FRAG_NL fragNlType = FRAG_NL_PRIMARY) const;
209#endif
210
211
212 private:
213 // Nasty const issue with logging and tracing.
214 ms_errs* getLog() const { return const_cast<ms_errs*>(getErrorHandler()); }
215
216 std::string convertPrimaryNlVectorToString(const std::vector< int > modded,
217 const std::vector< int > whichNl,
218 const ms_modvector &varMods,
219 const ms_modvector &varMods_used,
220 ms_errs* err) const;
221
222 std::vector< int > convertPrimaryNlStringToVector(const std::string varModStr,
223 const std::string primaryNlStr,
224 const ms_modvector &varMods_used,
225 ms_errs* err) const;
226
227 void initialiseFromResfile(const ms_mascotresfilebase& resfile,
228 const char * enzymeFileName,
229 const char * quantSchemaFilePath,
230 const char * unimodSchemaFilePath);
231 bool checkVarModConflicts(const ms_modvector *varModVector, ms_modvector &varMods, std::vector<int> &varModsSrc, ms_modvector &varMods_used, ms_errs &err) const;
232 bool iscleavagepoint(const char left, const char right) const;
233 bool switchIndependent();
234 void updatemissed(const int leftPos);
235 void dropmissed();
236 void clearMods();
237 bool calcUnionFragmentList(const ms_peptide* peptide,
238 const int seriesID,
239 const int fragCharge,
240 const double minMass,
241 const double maxMass,
242 const MASS_TYPE massType,
243 const FRAG_NL fragNlType,
244 std::vector< ms_fragment > *fragments,
245 ms_errs *err,
246 std::vector< double > *vi) const;
247 bool calcCrosslinkedFragments(const ms_peptide *peptide,
248 const int seriesID,
249 const int fragCharge,
250 const double minMass,
251 const double maxMass,
252 const MASS_TYPE massType,
253 const FRAG_NL fragNlType,
254 std::vector< ms_fragment > *fragments,
255 ms_errs *err,
256 std::vector< double > *vi) const;
257 bool cfr(const ms_peptide* peptide,
258 const ms_peptide::PSM psmComponent,
259 const int seriesID,
260 const int fragCharge,
261 const double minMass,
262 const double maxMass,
263 const MASS_TYPE massType,
264 const FRAG_NL fragNlType,
265 const int linkerColumn,
266 const double linkerMassOffset,
267 std::vector< ms_fragment > *fragments,
268 ms_errs* err,
269 std::vector< double > *vi) const;
270
271 void getSeriesParams(const char* pepStr,
272 const int seriesID,
273 const ms_masses & masses,
274 const MASS_TYPE massType,
275 double& delta,
276 int& start,
277 int& end,
278 bool& forward) const;
279
280 void prepareCumulativeMassAndNL(const std::string &pepStr,
281 const ms_masses *pMasses,
282 const MASS_TYPE massType,
283 const std::vector<bool> &residue_has_varmod,
284 const std::vector<double> &fixedModNlVals,
285 const std::vector<double> &totalModDelta,
286 const std::vector<double> &totalNlVals,
287 const bool isMasterNL,
288 std::vector<double> &m,
289 std::vector<double> &cumulativeNlVals) const;
290
291 class IonSet;
292 void calculateSeriesMasses(const int seriesID,
293 const int fragCharge,
294 const MASS_TYPE massType,
295 const ms_peptide::PSM psmComponent,
296 const int linkerColumn,
297 const double linkerMassOffset,
298 const ms_masses *pMasses,
299 const std::string &pepStr,
300 const std::vector<double> &m,
301 const std::vector<double> &cumulativeNlVals,
302 const std::vector<bool> &loopLinkingAllows,
303 IonSet &ionSet) const;
304
305 void setupFromPre2_2ResultsFile(const std::string & peptide, const std::string & varMods);
306
307 class ModLookupHelper;
308 bool initialiseModsAtResidues(const ModLookupHelper &lookupHelper,
309 const std::string &pepStr,
310 const std::string &modStr,
311 const std::vector<int> &primaryNl,
312 const std::string &monoLinkStr,
313 const ms_modvector *varmods,
314 const std::vector<int> *varmods_src,
315 const ms_modvector *varmods_used,
316 const ms_peptide::PSM psmComponent,
317 std::vector< const ms_modification* > &mod_at_residue,
318 ms_errs *err) const;
319
320 bool lookupLocalModVectors(int q, const ms_modvector* &local_mods, const std::vector<int>* &local_mods_src, const ms_modvector* &local_mods_used);
321 void clearLocalModVectors();
322
323 ms_masses massesUnmod_;
324 ms_masses masses_;
325 ms_umod_configfile umodFile_;
326 ms_quant_configfile quantFile_;
327 const ms_mascotresfilebase* pResfile_;
328 const ms_mascotresults * pSummary_;
329
330 ms_modvector fixedMods_;
331 ms_modvector varMods_;
332 std::vector< int > varModsSrc_;
333 ms_modvector varMods_used_;
334
335 typedef std::map<int, ms_modvector > queryParsedLocalMods_t;
336 typedef std::map<int, std::vector<int> > queryParsedLocalModsSrc_t;
337 queryParsedLocalMods_t queryParsedLocalMods_;
338 queryParsedLocalModsSrc_t queryParsedLocalModsSrc_;
339 queryParsedLocalMods_t queryParsedLocalModsUsed_;
340
341 ms_enzyme enzyme_;
342 bool bEnzymeSet_;
343 std::string protStr_;
344 int protLen_;
345 int pfa_; // missed cleavages limit
346
347 // internal iteration parameters
348 int numInd_; // current independent enzyme ID
349 int l_, r_; // the last peptide ends
350 int missed_; // number of missed cleavages in the current peptide
351 int enzymesPassed_;
352
353 // for the sake of semi-specific enzymes
354 bool forward_;
355
356 // For a pre 2.2 results file, need to keep track of what we know
357 enum DERIVED_MOD_SPECIFICITY_STATUS
358 {
359 DMSS_NOT_INITIALISED,
360 DMSS_WORKING,
361 DMSS_COMPLETED,
362 DMSS_FROM_V2_2_OR_LATER_RESFILE,
363 DMSS_NOT_FROM_RESFILE
364 };
365 DERIVED_MOD_SPECIFICITY_STATUS derivedModSpecificityStatus_;
366 std::vector<MOD_TYPES> derivedModSpecificities_;
367 typedef std::vector< std::vector<bool> > modifiedResidues_t;
368 modifiedResidues_t derivedModifiedResidues_;
369
370 }; // ms_aahelper // end of mass_calculation_group
372} // matrix_science
373
374#endif // MS_AAHELPER_HPP
375
376/*------------------------------- End of File -------------------------------*/
This class facilitates creation of peptides and calculation of MS-fragment masses.
Definition: ms_aahelper.hpp:35
FRAG_NL
Flag for controlling iteration over multiple neutral losses.
Definition: ms_aahelper.hpp:47
Represent a single entry in the enzymes file.
Definition: ms_enzyme.hpp:67
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
All errors are collected in an instance of this class.
Definition: ms_errors.hpp:37
Class for holding a list of ms_fragment objects.
Definition: ms_fragmentvector.hpp:47
A vector of linker sites.
Definition: ms_linker_site_vector.hpp:46
Abstract base class of ms_mascotresfile_dat and ms_mascotresfile_msr.
Definition: ms_mascotresfilebase.hpp:72
Abstract class for either ms_peptidesummary or ms_proteinsummary.
Definition: ms_mascotresults.hpp:83
Reads and parses the masses file with residue and atom masses.
Definition: ms_masses.hpp:48
General usage class for creating lists of modifications to be passed as parameters.
Definition: ms_modfile.hpp:339
This class encapsulates a peptide from the mascot results file.
Definition: ms_peptide.hpp:57
MASS_TYPE
All possible mass types.
Definition: ms_modfile.hpp:65