Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_quantitation.hpp
1/*
2##############################################################################
3# file: ms_quantitation.hpp #
4# 'msparser' toolkit #
5# Base class for the main quantitation interface #
6##############################################################################
7# COPYRIGHT NOTICE #
8# Copyright 1998-2013 Matrix Science Limited All Rights Reserved. #
9# #
10##############################################################################
11# $Author: villek@matrixscience.com $ #
12# $Date: 2023-12-07 11:32:07 +0000 $ #
13# $Revision: b2f6316623fa89979f3ea09df34209662543707e | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
14# $NoKeywords:: $ #
15##############################################################################
16*/
17
18#ifndef MS_QUANTITATION_HPP
19#define MS_QUANTITATION_HPP
20
21
22// Includes from the standard template library
23#include <string>
24#include <vector>
25#include <map>
26#include <set>
27#include <utility>
28
29namespace msparser_internal
30{
31 class ms_XMLElement;
32 class ms_XMLHelper;
33}
34
35namespace matrix_science {
36 class ms_errors;
37 class ms_peptide_quant_key;
38 class ms_peptide_quant_key_vector;
39 class ms_peptide_quant_ratio;
40 class ms_protein_quant_ratio;
41 class ms_quant_outliers;
42 class ms_peptidesummary;
43 class ms_protein;
44 class ms_peptide;
45 class ms_progress_info;
46
53
137 class MS_MASCOTRESFILE_API ms_quantitation: public ms_errors
138 {
139 public:
141 virtual ~ms_quantitation() = 0;
142
144 virtual bool hasPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const = 0;
145
147 virtual ms_peptide_quant_ratio getPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const = 0;
148
150 virtual void setPeptideRatioIncluded(const ms_peptide_quant_key &key, const std::string &ratioName) = 0;
151
153 virtual void setPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName) = 0;
154
156 virtual bool isPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName) const = 0;
157
159 virtual void setQuantOutliers(const ms_quant_outliers *) = 0;
160
162 void setMinNumPeptides(int value);
163
165 virtual void setProteinRatioType(const char *value) = 0;
166
168 const ms_quant_method& getQuantitationMethod() const;
169
171 virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName) const = 0;
172
174 virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName, const ms_peptide_quant_key_vector &includeKeys, const ms_peptide_quant_key_vector &excludeKeys) const = 0;
175
177 virtual std::vector<double> getAllProteinRatios(const std::string & accession, const int dbIdx, const std::string & ratioName) const = 0;
178
180 virtual std::vector<std::vector<bool> > getAllProteinRatioFlags(const std::string & accession, const int dbIdx, const std::string & ratioName) const = 0;
181
182
184 ms_peptide_quant_key_vector getPeptideQuantKeys(const std::string &accession, int dbIdx) const;
185
187 double getPeptideRatioNormalisationBase(const std::string &ratioName) const;
188
190 void setPeptideRatioNormalisationBase(const std::string &ratioName, double b);
191
193 void removePeptideRatioNormalisationBase(const std::string &ratioName);
194
196 void removePeptideRatioNormalisationBases();
197
199 const ms_progress_info & getProgressInfo();
200
202 void addRawFileField(const unsigned int id, const std::string & name, const std::string & value);
204 void addHeaderField(const std::string & name, const std::string & value);
209
210#ifndef SWIG
212 virtual int countDistinctPeptides(const std::vector<ms_peptide_quant_key> & activeKeys) const;
213#endif
215 virtual int countDistinctPeptides(const ms_peptide_quant_key_vector & activeKeys) const;
216
217
218 protected:
220
221 ms_quant_method quantMethod_;
222 typedef std::map<std::string, std::string> HeaderInfo_t;
223 typedef std::vector<HeaderInfo_t> RawFileInfo_t;
224 RawFileInfo_t rawFileInfo_;
225 HeaderInfo_t headerInfo_;
226
228 virtual void getSortedFinitePeptideRatioValues(const std::string &ratioName, const std::set<ms_peptide_quant_key> &keys, const std::set<ms_peptide_quant_key> &includeKeys, const std::set<ms_peptide_quant_key> &excludeKeys, std::vector<double> &values, std::vector<double> &weights, std::vector<ms_peptide_quant_key> &activeKeys, std::map<ms_peptide_quant_key, int> &inactiveKeys) const = 0;
229
231 void getProteinRatioSample(const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector<ms_peptide_quant_key> &includeKeys, const std::vector<ms_peptide_quant_key> &excludeKeys, std::vector<double> &sample, std::vector<double> &logSample, std::vector<double> &weights, std::vector<ms_peptide_quant_key> &activeKeys, std::map<ms_peptide_quant_key, int> &inactiveKeys, double &normalityPvalue) const;
232
234 ms_protein_quant_ratio calculateMedianRatio(const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector<double> &sample, const std::vector<double> &logSample, const std::vector<ms_peptide_quant_key> &activeKeys, const std::map<ms_peptide_quant_key, int> &inactiveKeys, double normalityPvalue) const;
235
237 ms_protein_quant_ratio calculateGeometricMeanRatio(const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector<double> &sample, const std::vector<double> &logSample, const std::vector<ms_peptide_quant_key> &activeKeys, const std::map<ms_peptide_quant_key, int> &inactiveKeys, double normalityPvalue) const;
238
240 ms_protein_quant_ratio calculateWeightedGeometricMeanRatio(const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector<double> &sample, const std::vector<double> &logSample, const std::vector<double> &weights, const std::vector<ms_peptide_quant_key> &activeKeys, const std::map<ms_peptide_quant_key, int> &inactiveKeys, double normalityPvalue) const;
241
242 typedef std::pair<std::string, int> protein_key_t; // accession, dbIdx
243 typedef std::map< protein_key_t, std::set<ms_peptide_quant_key> > protein_to_peptide_quant_key_t; // maps from [accession, dbidx] to set<ms_peptide_quant_key>
245 protein_to_peptide_quant_key_t proteinKeys_;
246
248 bool initialiseBaseSettings(const ms_quant_method &qmBase, const ms_quant_method &qmConfig);
249
251 int getMinNumPeptides() const;
252
255 std::string encodeForXml(const std::string & value) const;
256
258 msparser_internal::ms_XMLElement createXmlRoot(msparser_internal::ms_XMLHelper & helper) const;
259
261 msparser_internal::ms_XMLElement createRawFilesElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root) const;
262
264 msparser_internal::ms_XMLElement createHeaderElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root) const;
265
267 bool addQuantitationMethodXml(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root) const;
268
270 bool populateProteinHitXml(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & proteinHitElement, const matrix_science::ms_protein * protein, const matrix_science::ms_peptidesummary & peptideSummary, int hitId, int memberNumber);
271
273 bool addPeptideElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root, const matrix_science::ms_peptide & peptide, const std::string & component) const;
274
276 bool createPeptideGroupStatusElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & hitElement, const matrix_science::ms_peptidesummary & peptideSummary, long q, long p, const std::string & status, const std::string & component, char residueBefore, char residueAfter) const;
278
279 mutable ms_progress_info * progressInfo_;
280 private:
281 int minNumPeptides_;
282
283 std::map< std::string, double > logH0ProteinRatio_;
284 typedef std::map< std::string, double > ratio_name_to_normalisation_base_t;
285 ratio_name_to_normalisation_base_t peptideNormalisationBases_;
286 }; // end of quantitation_group
288} // matrix_science namespace
289
290#endif // MS_QUANTITATION_HPP
291
292/*------------------------------- End of File -------------------------------*/
This class is used as a base class for several Mascot Parser classes.
Definition: ms_errors.hpp:696
A vector of peptide quant keys.
Definition: ms_peptide_quant_key_vector.hpp:47
Feature key identifying a peptide ratio.
Definition: ms_peptide_quant_key.hpp:69
Peptide abundance in one component relative to another in a quantitation experiment.
Definition: ms_peptide_quant_ratio.hpp:61
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
Contains information of the current progress of a task being performed.
Definition: ms_progress_info.hpp:40
Protein abundance in one component relative to another in a quantitation experiment,...
Definition: ms_protein_quant_ratio.hpp:72
This class encapsulates a protein in the mascot results file.
Definition: ms_protein.hpp:57
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 OUTLIERS element in quantitation.xml.
Definition: ms_quant_outliers.hpp:44
Base class for peptide and protein quantitation.
Definition: ms_quantitation.hpp:138
virtual bool isPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName) const =0
Boolean flag: is the given peptide ratio globally excluded from protein ratio calculation?
protein_to_peptide_quant_key_t proteinKeys_
Protein-to-peptide mapping.
Definition: ms_quantitation.hpp:245
virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName) const =0
Given the protein accession, database ID and ratio name, return the protein ratio data.
void clearRawFileFields()
Clears any raw file header information from the result.
virtual void setQuantOutliers(const ms_quant_outliers *)=0
Set new peptide ratio outlier settings.
virtual void getSortedFinitePeptideRatioValues(const std::string &ratioName, const std::set< ms_peptide_quant_key > &keys, const std::set< ms_peptide_quant_key > &includeKeys, const std::set< ms_peptide_quant_key > &excludeKeys, std::vector< double > &values, std::vector< double > &weights, std::vector< ms_peptide_quant_key > &activeKeys, std::map< ms_peptide_quant_key, int > &inactiveKeys) const =0
Given a list of q,p values and ratio name, find the non-infinite peptide ratio values and return them...
void addHeaderField(const std::string &name, const std::string &value)
Adds an item of project or search header information.
virtual void setPeptideRatioIncluded(const ms_peptide_quant_key &key, const std::string &ratioName)=0
Globally include a particular peptide ratio in protein ratio calculation.
void clearHeaderFields()
Clears any header information from the result.
virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName, const ms_peptide_quant_key_vector &includeKeys, const ms_peptide_quant_key_vector &excludeKeys) const =0
Given the protein accession, database ID and ratio name, return the protein ratio data,...
void addRawFileField(const unsigned int id, const std::string &name, const std::string &value)
Adds an item of raw file header information.
virtual ms_peptide_quant_ratio getPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const =0
Given peptide quant key and ratio name, return the corresponding peptide ratio data.
virtual bool hasPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const =0
Existence check: return true if a peptide ratio with the associated peptide quant key and ratio name ...
virtual void setPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName)=0
Globally exclude a particular peptide ratio from protein ratio calculation.
virtual void setProteinRatioType(const char *value)=0
Set the protein ratio type.