Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

PeptideAndProteinQuant.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Hendrik Weisser $
00032 // $Authors: Hendrik Weisser $
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;         // not quantified
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   };   // class
00260 
00261 } // namespace
00262 
00263 #endif // OPENMS_ANALYSIS_QUANTITATION_PEPTIDEANDPROTEINQUANT_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:43 using doxygen 1.7.1