Matrix Science header

ms_quantitation.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_quantitation.hpp                                                  #
00004 # 'msparser' toolkit                                                         #
00005 # Base class for the main quantitation interface                             #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2013 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011 #     $Author: patricke@matrixscience.com $ #
00012 #       $Date: 2019-10-07 14:25:02 +0100 $ #
00013 #   $Revision: 7c90b0aa9fbdfe0a1d8c51bc7935dfea43c25dbb | MSPARSER_REL_2_8_1-0-gea32989045 $ #
00014 # $NoKeywords::                                                            $ #
00015 ##############################################################################
00016 */
00017 
00018 #ifndef MS_QUANTITATION_HPP
00019 #define MS_QUANTITATION_HPP
00020 
00021 
00022 // Includes from the standard template library
00023 #include <string>
00024 #include <vector>
00025 #include <map>
00026 #include <set>
00027 #include <utility>
00028 
00029 namespace msparser_internal
00030 {
00031     class ms_XMLElement;
00032     class ms_XMLHelper;
00033 }
00034 
00035 namespace matrix_science {
00036     class ms_errors;
00037     class ms_mascotresfile;
00038     class ms_peptide_quant_key;
00039     class ms_peptide_quant_key_vector;
00040     class ms_peptide_quant_ratio;
00041     class ms_protein_quant_ratio;
00042     class ms_quant_outliers;
00043     class ms_peptidesummary;
00044     class ms_protein;
00045     class ms_peptide;
00046     class ms_progress_info;
00047 
00053 
00054 
00138     class MS_MASCOTRESFILE_API ms_quantitation: public ms_errors
00139     {
00140         public:
00142             virtual ~ms_quantitation() = 0;
00143 
00145             virtual bool hasPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const = 0;
00146 
00148             virtual ms_peptide_quant_ratio getPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const = 0;
00149 
00151             virtual void setPeptideRatioIncluded(const ms_peptide_quant_key &key, const std::string &ratioName) = 0;
00152 
00154             virtual void setPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName) = 0;
00155 
00157             virtual bool isPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName) const = 0;
00158 
00160             virtual void setQuantOutliers(const ms_quant_outliers *) = 0;
00161 
00163             void setMinNumPeptides(int value);
00164 
00166             virtual void setProteinRatioType(const char *value) = 0;
00167 
00169             const ms_quant_method& getQuantitationMethod() const;
00170 
00172             virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName) const = 0;
00173 
00175             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;
00176 
00178             virtual std::vector<double> getAllProteinRatios(const std::string & accession, const int dbIdx, const std::string & ratioName) const = 0;
00179 
00181             virtual std::vector<std::vector<bool> > getAllProteinRatioFlags(const std::string & accession, const int dbIdx, const std::string & ratioName) const = 0;
00182 
00183 
00185             ms_peptide_quant_key_vector getPeptideQuantKeys(const std::string &accession, int dbIdx) const;
00186 
00188             double getPeptideRatioNormalisationBase(const std::string &ratioName) const;
00189 
00191             void setPeptideRatioNormalisationBase(const std::string &ratioName, double b);
00192 
00194             void removePeptideRatioNormalisationBase(const std::string &ratioName);
00195 
00197             void removePeptideRatioNormalisationBases();
00198 
00200             const ms_progress_info & getProgressInfo();
00201 
00203             void addRawFileField(const unsigned int id, const std::string & name, const std::string & value);
00205             void addHeaderField(const std::string & name, const std::string & value);
00207             void clearHeaderFields();
00209             void clearRawFileFields();            
00210 
00211 #ifndef SWIG
00212 
00213             virtual int countDistinctPeptides(const std::vector<ms_peptide_quant_key> & activeKeys) const;
00214 #endif
00215 
00216             virtual int countDistinctPeptides(const ms_peptide_quant_key_vector & activeKeys) const;
00217 
00218 
00219         protected:
00220             ms_quantitation();
00221 
00222             ms_quant_method quantMethod_;
00223             typedef std::map<std::string, std::string> HeaderInfo_t;
00224             typedef std::vector<HeaderInfo_t> RawFileInfo_t;
00225             RawFileInfo_t rawFileInfo_;
00226             HeaderInfo_t  headerInfo_;
00227 
00229             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;
00230 
00232             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;
00233 
00235             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;
00236 
00238             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;
00239 
00241             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;
00242 
00243             typedef std::pair<std::string, int> protein_key_t; // accession, dbIdx
00244             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>
00246             protein_to_peptide_quant_key_t proteinKeys_;
00247 
00249             bool initialiseBaseSettings(const ms_quant_method &qmBase, const ms_quant_method &qmConfig);
00250 
00252             int getMinNumPeptides() const;
00253 
00256             std::string encodeForXml(const std::string & value) const;
00257 
00259             msparser_internal::ms_XMLElement createXmlRoot(msparser_internal::ms_XMLHelper & helper) const;
00260 
00262             msparser_internal::ms_XMLElement createRawFilesElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root) const;
00263 
00265             msparser_internal::ms_XMLElement createHeaderElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root) const;
00266 
00268             bool addQuantitationMethodXml(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root) const;            
00269 
00271             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);
00272 
00274             bool addPeptideElement(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & root, const matrix_science::ms_peptide & peptide, const std::string & component) const;
00275 
00277             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;
00279 
00280             mutable ms_progress_info * progressInfo_;
00281         private:
00282             int minNumPeptides_;
00283 
00284             std::map< std::string, double > logH0ProteinRatio_;
00285             typedef std::map< std::string, double > ratio_name_to_normalisation_base_t;
00286             ratio_name_to_normalisation_base_t peptideNormalisationBases_;
00287     }; // end of quantitation_group
00289 }   // matrix_science namespace
00290 
00291 #endif // MS_QUANTITATION_HPP
00292 
00293 /*------------------------------- End of File -------------------------------*/

Copyright © 2022 Matrix Science Ltd.  All Rights Reserved. Generated on Thu Mar 31 2022 01:12:30