OpenMS  2.4.0
PeptideAndProteinQuant.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2018.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hendrik Weisser $
32 // $Authors: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
42 
43 namespace OpenMS
44 {
52  class OPENMS_DLLAPI PeptideAndProteinQuant :
53  public DefaultParamHandler
54  {
55 public:
56 
58  typedef std::map<UInt64, double> SampleAbundances;
59 
61  struct PeptideData
62  {
64  std::map<Int, SampleAbundances> abundances;
65 
68 
70  std::set<String> accessions;
71 
74 
77  id_count(0) {}
78  };
79 
81  typedef std::map<AASequence, PeptideData> PeptideQuant;
82 
84  struct ProteinData
85  {
87  std::map<String, SampleAbundances> abundances;
88 
91 
94 
97  id_count(0) {}
98  };
99 
101  typedef std::map<String, ProteinData> ProteinQuant;
102 
104  struct Statistics
105  {
108 
110  Size quant_proteins, too_few_peptides;
111 
113  Size quant_peptides, total_peptides;
114 
116  Size quant_features, total_features, blank_features, ambig_features;
117 
120  n_samples(0), quant_proteins(0), too_few_peptides(0),
121  quant_peptides(0), total_peptides(0), quant_features(0),
122  total_features(0), blank_features(0), ambig_features(0) {}
123  };
124 
127 
130 
136  void readQuantData(FeatureMap& features);
137 
143  void readQuantData(ConsensusMap& consensus);
144 
150  void readQuantData(std::vector<ProteinIdentification>& proteins,
151  std::vector<PeptideIdentification>& peptides);
152 
162  void quantifyPeptides(const std::vector<PeptideIdentification>& peptides =
163  std::vector<PeptideIdentification>());
164 
165 
171  void quantifyProteins(const ProteinIdentification& proteins =
173 
175  const Statistics& getStatistics();
176 
178  const PeptideQuant& getPeptideResults();
179 
181  const ProteinQuant& getProteinResults();
182 
183 private:
184 
187 
190 
193 
194 
201  PeptideHit getAnnotation_(std::vector<PeptideIdentification>& peptides);
202 
208  void quantifyFeature_(const FeatureHandle& feature, const PeptideHit& hit);
209 
215  template <typename T>
216  void orderBest_(const std::map<T, SampleAbundances> & abundances,
217  std::vector<T>& result)
218  {
219  typedef std::pair<Size, double> PairType;
220  std::multimap<PairType, T, std::greater<PairType> > order;
221  for (typename std::map<T, SampleAbundances>::const_iterator ab_it =
222  abundances.begin(); ab_it != abundances.end(); ++ab_it)
223  {
224  double total = 0.0;
225  for (SampleAbundances::const_iterator samp_it = ab_it->second.begin();
226  samp_it != ab_it->second.end(); ++samp_it)
227  {
228  total += samp_it->second;
229  }
230  if (total <= 0.0) continue; // not quantified
231  PairType key = std::make_pair(ab_it->second.size(), total);
232  order.insert(std::make_pair(key, ab_it->first));
233  }
234  result.clear();
235  for (typename std::multimap<PairType, T, std::greater<PairType> >::
236  iterator ord_it = order.begin(); ord_it != order.end(); ++ord_it)
237  {
238  result.push_back(ord_it->second);
239  }
240  }
241 
245  void normalizePeptides_();
246 
259  String getAccession_(const std::set<String>& pep_accessions,
260  std::map<String, String>& accession_to_leader);
261 
267  void countPeptides_(std::vector<PeptideIdentification>& peptides);
268 
270  void updateMembers_() override;
271 
272  }; // class
273 
274 } // namespace
275 
Size too_few_peptides
Definition: PeptideAndProteinQuant.h:110
Representation of a protein identification run.
Definition: ProteinIdentification.h:61
Statistics()
constructor
Definition: PeptideAndProteinQuant.h:119
Size total_peptides
Definition: PeptideAndProteinQuant.h:113
A more convenient string class.
Definition: String.h:57
Size n_samples
number of samples
Definition: PeptideAndProteinQuant.h:107
ProteinData()
constructor
Definition: PeptideAndProteinQuant.h:96
A container for features.
Definition: FeatureMap.h:93
Size total_features
Definition: PeptideAndProteinQuant.h:116
A container for consensus elements.
Definition: ConsensusMap.h:75
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
~PeptideAndProteinQuant() override
Destructor.
Definition: PeptideAndProteinQuant.h:129
std::set< String > accessions
protein accessions for this peptide
Definition: PeptideAndProteinQuant.h:70
PeptideQuant pep_quant_
Peptide quantification data.
Definition: PeptideAndProteinQuant.h:189
std::map< String, ProteinData > ProteinQuant
Mapping: protein accession -> protein data.
Definition: PeptideAndProteinQuant.h:101
std::map< Int, SampleAbundances > abundances
mapping: charge -> sample -> abundance
Definition: PeptideAndProteinQuant.h:64
std::map< AASequence, PeptideData > PeptideQuant
Mapping: peptide sequence (modified) -> peptide data.
Definition: PeptideAndProteinQuant.h:81
PeptideData()
constructor
Definition: PeptideAndProteinQuant.h:76
Helper class for peptide and protein quantification based on feature data annotated with IDs...
Definition: PeptideAndProteinQuant.h:52
Representation of a peptide hit.
Definition: PeptideHit.h:54
Size id_count
number of identifications
Definition: PeptideAndProteinQuant.h:73
Quantitative and associated data for a peptide.
Definition: PeptideAndProteinQuant.h:61
Statistics stats_
Processing statistics for output in the end.
Definition: PeptideAndProteinQuant.h:186
SampleAbundances total_abundances
mapping: sample -> total abundance
Definition: PeptideAndProteinQuant.h:67
SampleAbundances total_abundances
mapping: sample -> total abundance
Definition: PeptideAndProteinQuant.h:90
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
Statistics for processing summary.
Definition: PeptideAndProteinQuant.h:104
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
void orderBest_(const std::map< T, SampleAbundances > &abundances, std::vector< T > &result)
Order keys (charges/peptides for peptide/protein quantification) according to how many samples they a...
Definition: PeptideAndProteinQuant.h:216
std::map< String, SampleAbundances > abundances
mapping: peptide (unmodified) -> sample -> abundance
Definition: PeptideAndProteinQuant.h:87
Quantitative and associated data for a protein.
Definition: PeptideAndProteinQuant.h:84
Size id_count
total number of identifications (of peptides mapping to this protein)
Definition: PeptideAndProteinQuant.h:93
ProteinQuant prot_quant_
Protein quantification data.
Definition: PeptideAndProteinQuant.h:192
std::map< UInt64, double > SampleAbundances
Mapping: sample ID -> abundance.
Definition: PeptideAndProteinQuant.h:58