Matrix Science header

ms_ms1quantitation.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_ms1quantitation.hpp
00004 # 'msparser' toolkit
00005 # An extracted ion chromatogram
00006 ##############################################################################
00007 # COPYRIGHT NOTICE
00008 # Copyright 1998-2014 Matrix Science Limited  All Rights Reserved.
00009 #
00010 ##############################################################################
00011  * @(#)$Source: /vol/cvsroot/parser/inc/ms_ms1quantitation.hpp,v $
00012  * @(#)$Revision: 1.13 $
00013  * @(#)$Date: 2017/04/18 14:34:56 $
00014 ##############################################################################
00015  */
00016 
00017 #ifndef MS_MS1QUANTITATION_HPP
00018 #define MS_MS1QUANTITATION_HPP
00019 
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 
00038 // Includes from the standard template library
00039 #include <string>
00040 #include <vector>
00041 
00042 namespace msparser_internal
00043 {
00044     class ms_XMLElement;
00045     class ms_XMLHelper;
00046 }
00047 
00048 namespace matrix_science
00049 {
00050     //=========================================================================
00056     class ms_msquant1_mod_format;
00057     class ms_cache_stream;
00058     class ms_progress_info;
00059     class ms_mascotresults_params;
00060 
00062 
00104     class MS_MASCOTRESFILE_API ms_ms1quantitation :
00105         public ms_customquantitation
00106     {
00107         public:
00108 
00110             ms_ms1quantitation(const ms_peptidesummary & summary, const ms_quant_method & method);
00111 
00112             ~ms_ms1quantitation();
00113 
00115             int getNumPeptideStatuses() const;
00117             ms_ms1quant_peptide_status getPeptideStatus(int index) const;
00118 
00120             int getNumHits() const;
00122             ms_protein * getHit(int index1) const;
00123 
00125             int getNumMatches() const;
00127             ms_ms1quant_match getMatch(int index) const;
00129             ms_ms1quant_match getMatch(ms_peptide_quant_key & key) const;
00130 
00131             void clearMatches();            
00132 
00134             void addMatchStatus(
00135                     matrix_science::ms_peptide * peptide,
00136                     matrix_science::ms_ms1quant_peptide_status::peptideStatus status,
00137                     matrix_science::ms_protein * hit = 0);
00138 
00140             void addMatchPeptide(
00141                     matrix_science::ms_protein * hit,
00142                     matrix_science::ms_peptide * peptide,
00143                     const matrix_science::ms_quant_component & component);
00144 
00146             matrix_science::ms_ms1quant_match addMatchInferred(
00147                     const ms_ms1quant_match & siblingMatch,
00148                     int newCharge);
00149 
00151             void removeMatch(matrix_science::ms_peptide_quant_key matchKey);
00152 
00153             void addRawFileInfo(const unsigned int id, const std::string & name, const std::string & value);
00154             void addHeaderInfo(const std::string & name, const std::string & value);            
00155 
00157             bool findPeptideStatus(int query, int rank, ms_ms1quant_peptide_status * peptideStatus) const;
00158 
00160             bool findMatch(matrix_science::ms_peptide_quant_key matchKey, ms_ms1quant_match * match) const;
00161 
00163             const ms_ms1quant_average_results * getAverageResults() const;
00164 
00166             bool loadXmlFile(const std::string & filename, const std::string & xmlSchemaPath);
00167 
00169             bool saveXmlFile(const std::string & xmlFilename, bool completeReport);
00170 
00172             bool loadCdbFile(const std::string & cdbFilename, const std::string & cacheFilename, bool revalidateQualityThresholds=true);
00173 
00175             bool saveCdbFile(const std::string & cdbFilename, const std::string & cacheFilename);
00176 
00178             const ms_progress_info & getProgressInfo();
00179 
00181             const ms_peptidesummary & getSummary() const;
00182 
00184             std::string getReadableVarMods(std::string varmods);
00185 
00187             std::string getReadableVarModsConcise(std::string varmods);
00188 
00190             std::string getLabelFree(std::string peptideStr, std::string varMods, std::string summedMods, const matrix_science::ms_quant_component & comp) const;
00191 
00193             int getNumMatchesForHit(int hitId, int memberNumber) const;
00195             ms_ms1quant_match getMatchForHit(int index, int hitId, int memberNumber) const;
00196 
00197             int getNumGroups() const;
00198             int getDatasourceForGroup(int groupIndex1) const;
00199             int getNumMatchesForGroup(int groupIndex1) const;
00200             ms_ms1quant_match getMatchForGroup(int matchIndex1, int groupIndex1) const;
00201 
00203             virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName) const;
00204 
00206             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;
00207 
00209             bool isAverageProtocol() const;
00211             void setAverageReferenceProtein(const char *accession, int dbIdx, double amount = 1.0);
00213             void setAverageNumPeptides(unsigned int num = 3);
00215             void setAverageSelection(const char * value);
00217             bool getAveragePeptideIntensity(
00218                     const std::string &accession,
00219                     int dbIdx,
00220                     double * averageIntensity, // average of grouped intensities (each peptide ratio group summed and then average of those sums)
00221                     int * sampleSize, // number of different peptide groups available (after grouping by selection type)
00222                     ms_peptide_quant_key_vector * includeKeys, // peptide ratios selected (may be greater then sampleSize)
00223                     ms_peptide_quant_key_vector * excludeKeys // peptide ratios not selected
00224                     ) const;
00225 
00227             std::vector<int> getQuantitationDatasources() const;
00228 
00229             int getNumMatchedPeptideStatuses() const;
00230 
00231             void initGroupChargeStates(
00232                     std::set<int> * calc_chargestates,
00233                     int iGroup1,
00234                     int minCharge,
00235                     int maxCharge);
00236 
00237             void calc_complete();
00238 
00240             static matrix_science::ms_ms1quantitation * openQuantitationCdbResults(
00241                 const matrix_science::ms_peptidesummary & summary, 
00242                 const matrix_science::ms_quant_method & method, 
00243                 const std::string & cdbFilename, 
00244                 const std::string & cacheFilename, 
00245                 const matrix_science::ms_quant_method * originalMethod = 0);
00246 
00248             static matrix_science::ms_ms1quantitation * openQuantitationXmlResults(
00249                 const matrix_science::ms_peptidesummary & summary, 
00250                 const matrix_science::ms_quant_method & method,
00251                 const std::string & filename,
00252                 const std::string & xmlSchemaPath="",
00253                 const matrix_science::ms_quant_method * originalMethod = 0);
00254 
00256             static matrix_science::ms_ms1quantitation * mergeQuantitationResults(
00257                 const matrix_science::ms_peptidesummary & summary,
00258                 const matrix_science::ms_quant_method & method,
00259                 const std::vector<std::string> & cdbFilenames, 
00260                 const std::vector<std::string> & cacheFilenames,
00261                 const matrix_science::ms_quant_method * originalMethod = 0);
00262 
00264             static matrix_science::ms_ms1quantitation * mergeQuantitationResults(
00265                 const matrix_science::ms_peptidesummary & summary,
00266                 const matrix_science::ms_quant_method & method,
00267                 const std::vector<std::string> & xmlFilenames,
00268                 const std::string & xmlSchemaPath="",
00269                 const matrix_science::ms_quant_method * originalMethod = 0);
00270 
00271         protected:
00273             virtual int countDistinctPeptides(const std::vector<ms_peptide_quant_key> & activeKeys) const;
00274 
00275         private:
00276             //Do not copy this object
00277             ms_ms1quantitation(const ms_ms1quantitation & src);
00278             ms_ms1quantitation& operator=(const ms_ms1quantitation & right);
00279 
00280             void initialiseAfterLoad();
00281 
00282             bool saveHitToCdb(matrix_science::ms_tinycdb & cdbFile, const matrix_science::ms_protein * protein, int streamNumber) const;
00283             bool saveHitToStream(matrix_science::ms_cache_stream & stream, const matrix_science::ms_protein * protein) const;
00284             bool saveHitToXml(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & element, const matrix_science::ms_protein * protein, int hitId, int memberNumber);
00285             std::string encodeForXml(const std::string & value) const;
00286 
00287             void getProteinRatioOverrideKeys(
00288                     ms_peptide_quant_key_vector * incFK,
00289                     ms_peptide_quant_key_vector * excFK,
00290                     const std::string & ratioName,
00291                     int hitId,
00292                     int memberNumber) const;
00293 
00294             ms_protein_quant_ratio getProteinAverageIntensityRatio(
00295                     const std::string &accession,
00296                     int dbIdx
00297                     ) const;
00298 
00299             void applyMS1Thresholds(matrix_science::ms_ms1quant_match * match); // applies the MS1 specific thresholds
00300             void rematchInferredMatches(const bool allowMassTimeMatches);  // populates inferredMatchSource_
00301             void updatePeptideStatus(matrix_science::ms_ms1quant_peptide_status status, const matrix_science::ms_quant_quality * quality);
00302             void updateMatches(const matrix_science::ms_quant_method * method);           // removes any ms1 quant matches which don't have any valid ms2 peptide matches
00303             void updateMatchPeptideEvidence();  // updates the ms2 matches associated (or not associated) with an ms1 quant match
00304             bool updateProteinMatches();        // looks for additional peptide-anchor protein matches
00305 
00306             // Can the new settings be handled my ms_ms1quantitation, or do additional values need to be calculated by MsQuantLib
00307             static bool canHandleSettings(const matrix_science::ms_quant_method * originalMethod, const matrix_science::ms_quant_method * newMethod, matrix_science::ms_ms1quantitation * quantResults);
00308 
00309             std::map<matrix_science::ms_peptide_quant_key, ms_ms1quant_peptide_status_body> getMatchedPeptideStatuses() const;
00311             bool mergeCdbFiles(const std::vector<std::string> & cdbFilenames, 
00312                 const std::vector<std::string> & cacheFilenames, 
00313                 const std::vector<std::string> & resultFilenames,
00314                 const matrix_science::ms_mascotresults_params & parameters,
00315                 const std::string & cacheDirectory);
00316 
00318             bool mergeXmlFiles(
00319                 const std::vector<std::string> & xmlFilenames,
00320                 const std::vector<std::string> & resultFilenames,
00321                 const std::string & cacheDirectory,
00322                 const std::string & xmlSchemaPath);
00323 
00325             std::vector<ms_ms1quant_match> getMatchesForHit(int hitId, int memberNumber) const;
00326 
00327             const ms_peptidesummary & peptideSummary_;
00328             int nextMatchId_;
00329             std::map<ms_peptide_quant_key, ms_ms1quant_match> matches_; // matchId -> match
00330             std::map<std::pair<int, int>, ms_ms1quant_peptide_status> peptideStatuses_; // [query, rank] -> status
00331             std::map<std::string, ms_peptide_quant_key> matchKeys_; // peptideStr:datasourceId:labelFree:charge -> matchId
00332             std::map<std::string, std::set<ms_peptide_quant_key> > matchGroups_; // "datasource:peptideStr:labelFree" -> matchId[]
00333             std::vector<std::string> matchGroupNames_; // names in matchGroups in order of addition (to match with processing order in Distiller)
00334 
00335             
00336             // matchId -> matchId of the 'source/sibling' identified match - always the most intense sibling if there is more than one possibility
00337             std::map<ms_peptide_quant_key, ms_peptide_quant_key> inferredMatchSource_;  
00338 
00339             typedef std::pair<int, int> Hitkey; // hitId, memberNumber (0 if not a family)
00340             std::vector<Hitkey> hitkeys_;
00341 
00342             typedef std::map<std::string, std::string> HeaderInfo_t;
00343             typedef std::vector<HeaderInfo_t> RawFileInfo_t;
00344             RawFileInfo_t rawFileInfo_;
00345             HeaderInfo_t  headerInfo_;
00346 
00347             bool hasAverageResults_;
00348             ms_ms1quant_average_results averageResults_;
00349 
00350             matrix_science::ms_cache_file cacheFile_;
00351 
00352             mutable const ms_msquant1_mod_format * modFormat_;
00353             mutable ms_progress_info * progressInfo_;
00354 
00355             std::vector<matrix_science::ms_cache_file *> multifileCacheFiles_;
00356     };
00357  // end of quantitation_group
00359     //=========================================================================
00360 
00361 }   // matrix_science namespace
00362 
00363 
00364 #endif // MS_MS1QUANTITATION_HPP
00365 
00366 /*------------------------------- End of File -------------------------------*/
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:51