Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_ANALYSIS_QUANTITATION_PEPTIDEANDPROTEINQUANT_H
00036 #define OPENMS_ANALYSIS_QUANTITATION_PEPTIDEANDPROTEINQUANT_H
00037
00038 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00039 #include <OpenMS/KERNEL/ConsensusMap.h>
00040 #include <OpenMS/KERNEL/FeatureMap.h>
00041 #include <OpenMS/METADATA/PeptideIdentification.h>
00042 #include <OpenMS/METADATA/ProteinIdentification.h>
00043
00044 namespace OpenMS
00045 {
00053 class OPENMS_DLLAPI PeptideAndProteinQuant :
00054 public DefaultParamHandler
00055 {
00056 public:
00057
00059 typedef std::map<UInt64, DoubleReal> SampleAbundances;
00060
00062 struct PeptideData
00063 {
00065 std::map<Int, SampleAbundances> abundances;
00066
00068 SampleAbundances total_abundances;
00069
00071 std::set<String> accessions;
00072
00074 Size id_count;
00075
00077 PeptideData() :
00078 id_count(0) {}
00079 };
00080
00082 typedef std::map<AASequence, PeptideData> PeptideQuant;
00083
00085 struct ProteinData
00086 {
00088 std::map<String, SampleAbundances> abundances;
00089
00091 SampleAbundances total_abundances;
00092
00094 Size id_count;
00095
00097 ProteinData() :
00098 id_count(0) {}
00099 };
00100
00102 typedef std::map<String, ProteinData> ProteinQuant;
00103
00105 struct Statistics
00106 {
00108 Size n_samples;
00109
00111 Size quant_proteins, too_few_peptides;
00112
00114 Size quant_peptides, total_peptides;
00115
00117 Size quant_features, total_features, blank_features, ambig_features;
00118
00120 Statistics() :
00121 n_samples(0), quant_proteins(0), too_few_peptides(0),
00122 quant_peptides(0), total_peptides(0), quant_features(0),
00123 total_features(0), blank_features(0), ambig_features(0) {}
00124 };
00125
00127 PeptideAndProteinQuant();
00128
00130 ~PeptideAndProteinQuant() {}
00131
00137 void quantifyPeptides(FeatureMap<> & features);
00138
00144 void quantifyPeptides(ConsensusMap & consensus);
00145
00151 void quantifyProteins(const ProteinIdentification & proteins =
00152 ProteinIdentification());
00153
00155 const Statistics & getStatistics();
00156
00158 const PeptideQuant & getPeptideResults();
00159
00161 const ProteinQuant & getProteinResults();
00162
00163 private:
00164
00166 Statistics stats_;
00167
00169 PeptideQuant pep_quant_;
00170
00172 ProteinQuant prot_quant_;
00173
00174
00181 PeptideHit getAnnotation_(std::vector<PeptideIdentification> & peptides);
00182
00188 void quantifyFeature_(const FeatureHandle & feature, const PeptideHit & hit);
00189
00195 template <typename T>
00196 void orderBest_(const std::map<T, SampleAbundances> abundances,
00197 std::vector<T> & result)
00198 {
00199 typedef std::pair<Size, DoubleReal> PairType;
00200 std::multimap<PairType, T, std::greater<PairType> > order;
00201 for (typename std::map<T, SampleAbundances>::const_iterator ab_it =
00202 abundances.begin(); ab_it != abundances.end(); ++ab_it)
00203 {
00204 DoubleReal total = 0.0;
00205 for (SampleAbundances::const_iterator samp_it = ab_it->second.begin();
00206 samp_it != ab_it->second.end(); ++samp_it)
00207 {
00208 total += samp_it->second;
00209 }
00210 if (total <= 0.0) continue;
00211 PairType key = std::make_pair(ab_it->second.size(), total);
00212 order.insert(std::make_pair(key, ab_it->first));
00213 }
00214 result.clear();
00215 for (typename std::multimap<PairType, T, std::greater<PairType> >::
00216 iterator ord_it = order.begin(); ord_it != order.end(); ++ord_it)
00217 {
00218 result.push_back(ord_it->second);
00219 }
00220 }
00221
00227 void quantifyPeptides_();
00228
00232 void normalizePeptides_();
00233
00246 String getAccession_(const std::set<String> & pep_accessions,
00247 std::map<String, String> & accession_to_leader);
00248
00254 void countPeptides_(std::vector<PeptideIdentification> & peptides);
00255
00257 void updateMembers_();
00258
00259 };
00260
00261 }
00262
00263 #endif // OPENMS_ANALYSIS_QUANTITATION_PEPTIDEANDPROTEINQUANT_H