00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef MS_MS1QUANTITATION_HPP
00018 #define MS_MS1QUANTITATION_HPP
00019
00020
00021
00022
00023
00024 #include <string>
00025 #include <vector>
00026
00027 namespace msparser_internal
00028 {
00029 class ms_XMLElement;
00030 class ms_XMLHelper;
00031 }
00032
00033 namespace matrix_science
00034 {
00035
00041 class ms_msquant1_mod_format;
00042 class ms_cache_stream;
00043 class ms_progress_info;
00044 class ms_mascotresults_params;
00045
00047
00089 class MS_MASCOTRESFILE_API ms_ms1quantitation :
00090 public ms_customquantitation
00091 {
00092 public:
00094 enum MERGE_QUANT_RESULTS_FLAGS {
00095 MERGE_QUANT_QUERY_NUMBERS_ARE_FROM_MERGED_RESULTS = 0x0001,
00096 MERGE_QUANT_MERGE_COMPONENTS_INTO_QUANT_MATCH = 0x0002,
00097 MERGE_QUANT_USE_COMPONENT_FILE_INDEX_TO_FIND_XIC = 0x0004,
00098 MERGE_QUANT_APPLY_THRESHOLDS_AFTER_MERGE = 0x0008,
00099
00100 MERGE_QUANT_DEFAULT_PRECURSOR_METHOD = MERGE_QUANT_APPLY_THRESHOLDS_AFTER_MERGE,
00101 MERGE_QUANT_DEFAULT_REPLICATE_METHOD = (MERGE_QUANT_QUERY_NUMBERS_ARE_FROM_MERGED_RESULTS | MERGE_QUANT_MERGE_COMPONENTS_INTO_QUANT_MATCH | MERGE_QUANT_USE_COMPONENT_FILE_INDEX_TO_FIND_XIC)
00102 };
00103
00105
00114 enum MS1QUANT_BUGFIX_NUM {
00115 BUGFIX_12409 = 12409
00116 };
00117
00119 ms_ms1quantitation(const ms_peptidesummary & summary, const ms_quant_method & method);
00120
00121 ~ms_ms1quantitation();
00122
00124 int getNumPeptideStatuses() const;
00126 ms_ms1quant_peptide_status getPeptideStatus(int index) const;
00127
00129 int getNumHits() const;
00131 ms_protein * getHit(int index1) const;
00132
00134 int getNumProteinFamilies() const;
00135
00137 int getNumMatches() const;
00139 ms_ms1quant_match getMatch(int index) const;
00141 ms_ms1quant_match getMatch(const ms_peptide_quant_key & key) const;
00142
00143 void clearMatches();
00144
00146 void addMatchStatus(
00147 matrix_science::ms_peptide * peptide,
00148 matrix_science::ms_ms1quant_peptide_status::peptideStatus status,
00149 matrix_science::ms_protein * hit = 0);
00150
00152 void addMatchPeptide(
00153 matrix_science::ms_protein * hit,
00154 matrix_science::ms_peptide * peptide,
00155 const matrix_science::ms_quant_component & component,
00156 const std::string & matchBelongsToComponent);
00157
00159 matrix_science::ms_ms1quant_match addMatchInferred(
00160 const ms_ms1quant_match & siblingMatch,
00161 int newCharge);
00162
00164 void removeMatch(matrix_science::ms_peptide_quant_key matchKey);
00165
00167 bool findPeptideStatus(int query, int rank, ms_ms1quant_peptide_status * peptideStatus) const;
00168
00170 bool findMatch(matrix_science::ms_peptide_quant_key matchKey, ms_ms1quant_match * match) const;
00171
00173 const ms_ms1quant_average_results * getAverageResults() const;
00174
00176 bool loadXmlFile(const std::string & filename, const std::string & xmlSchemaPath);
00177
00179 bool saveXmlFile(const std::string & xmlFilename, bool completeReport);
00180
00182 bool loadCdbFile(const std::string & cdbFilename, const std::string & cacheFilename, bool revalidateQualityThresholds=true);
00183
00185 bool saveCdbFile(const std::string & cdbFilename, const std::string & cacheFilename, bool createEmptyMissingComponents = false);
00186
00188 const ms_peptidesummary & getSummary() const;
00189
00191 std::string getReadableVarMods(std::string varmods);
00192
00194 std::string getReadableVarModsConcise(std::string varmods);
00195
00197 std::string getLabelFree(std::string peptideStr, std::string varMods, std::string summedMods, const matrix_science::ms_quant_component & comp) const;
00198
00200 int getNumMatchesForHit(int hitId, int memberNumber) const;
00202 ms_ms1quant_match getMatchForHit(int index, int hitId, int memberNumber) const;
00203
00205 int getNumGroups() const;
00206
00207 int getDatasourceForGroup(int groupIndex1) const;
00208
00210 int getNumMatchesForGroup(int groupIndex1) const;
00211
00212 ms_ms1quant_match getMatchForGroup(int matchIndex1, int groupIndex1) const;
00213
00215 virtual ms_protein_quant_ratio getProteinRatio(const std::string &accession, int dbIdx, const std::string &ratioName) const;
00216
00218 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;
00219
00221 std::vector<double> getAllProteinRatios(const std::string & accession, const int dbIdx, const std::string & ratioName) const;
00222
00224 std::vector<std::vector<bool> > getAllProteinRatioFlags(const std::string & accession, const int dbIdx, const std::string & ratioName) const;
00225
00227 std::vector<std::vector<double> > getAllProteinRatioValues(const std::string & accession, const int dbIdx, const std::string & ratioName) const;
00228
00230 std::vector<std::string> getAllProteinRatioPepSeqs(const std::string & accession, const int dbIdx, const std::string & ratioName) const;
00231
00233 bool isAverageProtocol() const;
00235 void setAverageReferenceProtein(const char *accession, int dbIdx, bool isReferenceUserSelected);
00237 void setAverageNumPeptides(unsigned int num = 3);
00239 void setAverageSelection(const char * value);
00240 #ifndef SWIG
00241
00242 bool getAveragePeptideIntensity(
00243 const std::string &accession,
00244 int dbIdx,
00245 double * averageIntensity,
00246 int * sampleSize,
00247 ms_peptide_quant_key_vector * includeKeys,
00248 ms_peptide_quant_key_vector * excludeKeys
00249 ) const;
00250 #else // SWIG Multiple return values
00251 bool getAveragePeptideIntensity(
00252 const std::string & accession,
00253 int dbIdx,
00254 double * OUTPUT,
00255 int * OUTPUT,
00256 ms_peptide_quant_key_vector * includeKeys,
00257 ms_peptide_quant_key_vector * excludeKeys
00258 ) const;
00259 #endif
00260
00261 std::vector<int> getQuantitationDatasources() const;
00262
00263 int getNumMatchedPeptideStatuses() const;
00264
00266 void initGroupChargeStates(
00267 std::set<int> * calc_chargestates,
00268 int iGroup1,
00269 int minCharge,
00270 int maxCharge);
00271
00272 void calc_complete();
00273
00275 bool isDataCached(MS1QUANT_BUGFIX_NUM bugNum) const;
00276
00278 using ms_quantitation::countDistinctPeptides;
00279
00280 #ifndef SWIG
00281
00282 virtual int countDistinctPeptides(const std::vector<ms_peptide_quant_key> & activeKeys) const;
00283 #endif
00284
00285 static matrix_science::ms_ms1quantitation * openQuantitationCdbResults(
00286 const matrix_science::ms_peptidesummary & summary,
00287 const matrix_science::ms_quant_method & method,
00288 const std::string & cdbFilename,
00289 const std::string & cacheFilename,
00290 const matrix_science::ms_quant_method * originalMethod = 0);
00291
00293 static matrix_science::ms_ms1quantitation * openQuantitationXmlResults(
00294 const matrix_science::ms_peptidesummary & summary,
00295 const matrix_science::ms_quant_method & method,
00296 const std::string & filename,
00297 const std::string & xmlSchemaPath="",
00298 const matrix_science::ms_quant_method * originalMethod = 0);
00299
00301 bool mergeQuantitationResults(const std::vector<std::string> & cdbFilenames,
00302 const std::vector<std::string> & cacheFilenames,
00303 const MERGE_QUANT_RESULTS_FLAGS flags,
00304 const matrix_science::ms_quant_method * originalMethod = 0);
00305
00307 bool mergeQuantitationResults(const std::vector<std::string> & xmlFilenames,
00308 const MERGE_QUANT_RESULTS_FLAGS flags,
00309 const std::string & xmlSchemaPath="",
00310 const matrix_science::ms_quant_method * originalMethod = 0);
00311 #ifndef SWIG
00312
00313 static bool readResultCounters(const std::string & cdbFile,
00314 int &numMatches, int &numHits, int &numPepGrp, int &numPeptideComponents);
00315 #else // SWIG Multiple return values
00316 static bool readResultCounters(const std::string & cdbFile,
00317 int &OUTPUT, int &OUTPUT, int &OUTPUT, int &OUTPUT);
00318 #endif
00319
00320 protected:
00321
00322 private:
00323
00324 ms_ms1quantitation(const ms_ms1quantitation & src);
00325 ms_ms1quantitation& operator=(const ms_ms1quantitation & right);
00326
00327 void initialiseAfterLoad();
00328
00329 std::list<ms_ms1quant_match> selectMatchesForNormalisation(const ms_quant_normalisation *norm);
00330 double calculatePeptideNormalisationBase(const std::string &ratioName) const;
00332 void normalisePeptideRatios();
00333
00334
00335 bool saveHitToCdb(matrix_science::ms_tinycdb & cdbFile, const matrix_science::ms_protein * protein, int streamNumber) const;
00336 bool saveHitToStream(matrix_science::ms_cache_stream & stream, const matrix_science::ms_protein * protein) const;
00337 bool saveHitToXml(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & element, const matrix_science::ms_protein * protein, int hitId, int memberNumber);
00338
00339 void getProteinRatioOverrideKeys(
00340 ms_peptide_quant_key_vector * incFK,
00341 ms_peptide_quant_key_vector * excFK,
00342 const std::string & ratioName,
00343 int hitId,
00344 int memberNumber) const;
00345
00346 ms_protein_quant_ratio getProteinAverageIntensityRatio(
00347 const std::string &accession,
00348 int dbIdx
00349 ) const;
00350
00351 void rematchInferredMatches(const bool allowMassTimeMatches);
00352 void updatePeptideStatus(matrix_science::ms_ms1quant_peptide_status status, const matrix_science::ms_quant_quality * quality);
00353 void updateMatches(const matrix_science::ms_quant_method * method);
00354 void updateMatchPeptideEvidence();
00355 bool updateProteinMatches();
00356
00357
00358 static bool canHandleSettings(const matrix_science::ms_quant_method * originalMethod, const matrix_science::ms_quant_method * newMethod, matrix_science::ms_ms1quantitation * quantResults);
00359
00360 std::map<matrix_science::ms_peptide_quant_key, ms_ms1quant_peptide_status_body> getMatchedPeptideStatuses() const;
00361
00363 std::vector<ms_ms1quant_match> getMatchesForHit(int hitId, int memberNumber) const;
00364
00366 bool saveGroupToXml(msparser_internal::ms_XMLHelper & helper, msparser_internal::ms_XMLElement & element, const matrix_science::ms_protein * protein, int hitId, int memberNumber) const;
00367 void reorderMatchesAfterMerge();
00368
00370 bool mergeCdbFiles(const std::vector<std::string> & cdbFilenames,
00371 const std::vector<std::string> & cacheFilenames,
00372 const std::vector<std::string> & resultFilenames,
00373 const matrix_science::ms_mascotresults_params & parameters,
00374 const std::string & cacheDirectory,
00375 const MERGE_QUANT_RESULTS_FLAGS flags);
00376
00378 bool mergeXmlFiles(
00379 const std::vector<std::string> & xmlFilenames,
00380 const std::vector<std::string> & resultFilenames,
00381 const std::string & cacheDirectory,
00382 const std::string & xmlSchemaPath,
00383 const MERGE_QUANT_RESULTS_FLAGS flags);
00384
00386 void getKeyStrings(const int dataSourceId, const std::string & peptideStr, const std::string & labelFreeVarMods, const int chargeState,
00387 std::string & groupKey, std::string & uniqueKey) const;
00388
00389 const ms_peptidesummary & peptideSummary_;
00390 int nextMatchId_;
00391 std::map<ms_peptide_quant_key, ms_ms1quant_match> matches_;
00392 std::map<std::pair<int, int>, ms_ms1quant_peptide_status> peptideStatuses_;
00393 std::map<std::string, ms_peptide_quant_key> matchKeys_;
00394 std::map<std::string, std::set<ms_peptide_quant_key> > matchGroups_;
00395 std::vector<std::string> matchGroupNames_;
00396
00397
00398
00399 std::map<ms_peptide_quant_key, ms_peptide_quant_key> inferredMatchSource_;
00400
00401 typedef std::pair<int, int> Hitkey;
00402 std::vector<Hitkey> hitkeys_;
00403
00404 bool hasAverageResults_;
00405 ms_ms1quant_average_results averageResults_;
00406
00407 matrix_science::ms_cache_file cacheFile_;
00408
00409 mutable const ms_msquant1_mod_format * modFormat_;
00410
00411 std::vector<matrix_science::ms_cache_file *> multifileCacheFiles_;
00412
00413 std::string bugsfixed_;
00414 };
00415
00417
00418
00419 }
00420
00421
00422 #endif // MS_MS1QUANTITATION_HPP
00423
00424