Matrix Science header

ms_ms2quantitation.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_ms2quantitation.hpp                                               #
00004 # 'msparser' toolkit                                                         #
00005 # Quantitation for Reporter and Multiplex protocols                          #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2013 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011 #     $Author: villek $ #
00012 #       $Date: 2016/07/01 11:02:23 $ #
00013 #   $Revision: 1.25 $ #
00014 # $NoKeywords::                                                            $ #
00015 ##############################################################################
00016 */
00017 
00018 #ifndef MS_MS2QUANTITATION_HPP
00019 #define MS_MS2QUANTITATION_HPP
00020 
00021 #ifdef _WIN32
00022 #pragma warning(disable:4251)   // Don't want all classes to be exported
00023 #pragma warning(disable:4786)   // Debug symbols too long
00024 #   ifndef _MATRIX_USE_STATIC_LIB
00025 #       ifdef MS_MASCOTRESFILE_EXPORTS
00026 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00027 #       else
00028 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00029 #       endif
00030 #   else
00031 #       define MS_MASCOTRESFILE_API
00032 #   endif
00033 #else
00034 #   define MS_MASCOTRESFILE_API
00035 #endif
00036 
00037 // Includes from the standard template library
00038 #include <string>
00039 #include <vector>
00040 #include <list>
00041 #include <utility>
00042 
00043 namespace msparser_internal {
00044     class ms_ms2ratiocalculator;
00045 }
00046 
00047 namespace matrix_science {
00048     class ms_quant_ratio;
00049     class ms_quantitation;
00050     class ms_peptidesummary;
00051     class ms_peptide_quant_key;
00052     class ms_peptide_quant_key_vector;
00053     class ms_quant_helper;
00054     class ms_protein;
00055 
00061 
00062 
00138     class MS_MASCOTRESFILE_API ms_ms2quantitation: public ms_quantitation
00139     {
00140         friend class ms_customquantitation;
00141         public:
00143             explicit ms_ms2quantitation(const ms_peptidesummary& pepsum);
00144 
00146             ms_ms2quantitation(const ms_peptidesummary& pepsum, const ms_quant_method &qm);
00147 
00149             virtual ~ms_ms2quantitation();
00150 
00151             virtual bool hasPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const;
00152             virtual ms_peptide_quant_ratio getPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName) const;
00153 
00154             virtual void setPeptideRatioIncluded(const ms_peptide_quant_key &key, const std::string &ratioName);
00155             virtual void setPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName);
00156             virtual bool isPeptideRatioExcluded(const ms_peptide_quant_key &key, const std::string &ratioName) const;
00157 
00158             virtual void setProteinRatioType(const char *value);
00159 
00160             virtual void setQuantOutliers(const ms_quant_outliers *);
00161 
00162             virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName) const;
00163 
00164             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;
00165 
00167             void setQuantNormalisation(const ms_quant_normalisation *norm);
00168 
00170             bool hasPeptideRatioNormalisation() const;
00171 
00173             void normalisePeptideRatios();
00174 
00176             std::vector<double> getComponentIntensities(const ms_peptide_quant_key &key, bool raw = false) const;
00177 
00178 
00180             std::vector<std::string> getReportRatioNamesInFile(unsigned int fileNum) const;
00181 
00183             const ms_quant_ratio* getReportRatioFromFile(unsigned int fileNum, const std::string &ratioName) const;
00184 
00186             void setReportRatioInFile(unsigned int fileNum, const std::string &ratioName, const ms_quant_ratio &ratioDef);
00187 
00189             void removeReportRatioInFile(unsigned int fileNum, const std::string &ratioName);
00190 
00191 
00193             std::vector<std::string> getCombinedReportRatioNames() const;
00194 
00196             const ms_quant_ratio* getCombinedReportRatio(const std::string &ratioName) const;
00197 
00199             void removeCombinedReportRatio(const std::string &ratioName);
00200 
00202             void setCombinedReportRatio(const std::string &ratioName, const ms_quant_ratio &ratioDef);
00203 
00205             double getIntensityNormalisationBase(const std::string &componentName) const;
00206 
00208             void setIntensityNormalisationBase(const std::string &componentName, double b);
00209 
00211             void removeIntensityNormalisationBase(const std::string &componentName);
00212 
00214             void removeIntensityNormalisationBases();
00215 
00217             bool hasIntensityNormalisation() const;
00218 
00220             void normaliseIntensities();
00221 
00222         protected:
00223             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;
00224 
00225             virtual int countDistinctPeptides(const std::vector<ms_peptide_quant_key> & activeKeys) const;
00226 
00227         private:
00228             // No copying.
00229             ms_ms2quantitation(const ms_ms2quantitation &copyFrom);
00230             ms_ms2quantitation& operator=(const ms_ms2quantitation &right);
00231 
00232             enum SUPPORTED_PROTEIN_RATIO_TYPE {
00233                 PROTEIN_RATIO_TYPE_MEDIAN = 0,
00234                 PROTEIN_RATIO_TYPE_AVERAGE,
00235                 PROTEIN_RATIO_TYPE_WEIGHTED
00236             };
00237 
00238             int proteinRatioType_;
00239 
00240             const ms_peptidesummary &pepsum_;
00241             const unsigned int numResfiles_;
00242 
00243             std::vector<std::string> componentNames_;
00244             std::vector<double>::size_type numComponents_;
00245 
00246             std::vector<double> componentIntensityNormalisationBase_;
00247             bool normaliseComponentIntensities_;
00248 
00249             bool renormaliseOnDemand_;
00250 
00251             std::map<ms_peptide_quant_key, bool> peptideQuantKeyQualityTest_;
00252             bool testPeptideQuantKeyUniqueness_;
00253             bool testedAllKeysForNormalisation_;
00254             ms_quant_helper *quantHelper_;
00255 
00256             typedef std::map< std::string, std::set<ms_peptide_quant_key> > ratio_name_to_peptide_quant_key_exclusion_t;
00257             std::vector< ratio_name_to_peptide_quant_key_exclusion_t > isPeptideQuantKeyExcluded_;
00258 
00259             bool useCanonicalQPvalues_;
00260 
00261             typedef std::pair<int, int> qp_t;
00262             qp_t keyToCanonicalQP(const ms_peptide_quant_key &key) const;
00263             int rankToCanonicalRank(int p) const;
00264 
00265             std::vector<double> loadIntensities(const ms_peptide_quant_key &key) const;
00266             std::vector<double> loadIntensities(int q, int p) const;
00267 
00268             static const unsigned int FILENUM_LOWER_BOUND = 0;
00269             static const unsigned int FILENUM_UPPER_BOUND;
00270 
00271             typedef std::pair<std::string, unsigned int> ratio_name_and_file_index_t;
00272             typedef std::set<ratio_name_and_file_index_t> ratio_name_in_files_t;
00273             ratio_name_in_files_t ratioNamesInFiles_;
00274 
00275             typedef std::list<ms_quant_ratio> quant_ratio_list_t;
00276             std::vector<quant_ratio_list_t> fileToQuantRatioList_;
00277 
00278             std::vector<msparser_internal::ms_ms2ratiocalculator> ratioCalculators_;
00279 
00280             typedef std::map<std::string, std::set<ms_peptide_quant_key> > sequence_to_peptide_quant_key_t;
00281             sequence_to_peptide_quant_key_t sequencePeptideQuantKeys_;
00282             std::map<ms_peptide_quant_key, std::string> peptideQuantKeySequence_;
00283 
00284             void fixRatioSourceRemovalInQM(const std::string &ratioName);
00285             void setRatioContentInQM(const std::string &ratioName, unsigned int fileNum);
00286 
00287             bool calculateUnnormalisedPeptideRatio(const ms_peptide_quant_key &key, const std::string &ratioName, int *fileNum, bool *isInfinite, double *value) const;
00288 
00289             void setQuantNormalisationOnly(const ms_quant_normalisation *norm);
00290 
00291             double calculatePeptideNormalisationBase(const std::string &ratioName) const;
00292             std::map<std::string, double> calculatePeptideNormalisationBases() const;
00293             std::list<ms_peptide_quant_key> selectKeysForNormalisation(const ms_quant_normalisation *norm);
00294             void selectAllKeysForNormalisation(std::map<int, std::pair<int, ms_peptide_quant_key> > &query_keys);
00295             std::vector<double> normalisedComponentIntensities(const std::vector<double> &intensities) const;
00296 
00297             bool initialiseReportRatios();
00298 
00299             bool initialiseQuantHelper();
00300 
00301             void setReportRatioInFileOnly(unsigned int fileNum, const std::string &ratioName, const ms_quant_ratio &ratioDef);
00302             void setReportRatioInFileOnly(unsigned int fileNum, const std::string &ratioName, const ms_quant_ratio &ratioDef, std::string &oldName, std::string &newName);
00303 
00304             bool removeReportRatioInFileOnly(unsigned int fileNum, const std::string &ratioName);
00305 
00306             std::map<ms_peptide_quant_key, bool>::const_iterator testPeptideQuantKeyQuality(int q, int p, const ms_peptide_quant_key &key);
00307             void initialiseProteinPeptideMapping(const std::string &accession, int dbIdx);
00308     }; // end of quantitation_group
00310 }   // matrix_science namespace
00311 
00312 #endif // MS_MS2QUANTITATION_HPP
00313 
00314 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51