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

PrecursorIonSelection.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: Alexandra Zerck $
00032 // $Authors: $
00033 // --------------------------------------------------------------------------
00034 //
00035 
00036 #ifndef OPENMS_ANALYSIS_TARGETED_PRECURSORIONSELECTION_H
00037 #define OPENMS_ANALYSIS_TARGETED_PRECURSORIONSELECTION_H
00038 
00039 #include <OpenMS/KERNEL/FeatureMap.h>
00040 #include <OpenMS/METADATA/PeptideIdentification.h>
00041 #include <OpenMS/ANALYSIS/TARGETED/PSLPFormulation.h>
00042 #include <set>
00043 
00044 namespace OpenMS
00045 {
00046   class PrecursorIonSelectionPreprocessing;
00047   class PSProteinInference;
00053   class OPENMS_DLLAPI PrecursorIonSelection :
00054     public DefaultParamHandler
00055   {
00056 public:
00057 
00075     enum Type
00076     {
00077       IPS,
00078       ILP_IPS,
00079       SPS,
00080       UPSHIFT,
00081       DOWNSHIFT,
00082       DEX
00083     };
00084 
00085     PrecursorIonSelection();
00086     PrecursorIonSelection(const PrecursorIonSelection & source);
00087     ~PrecursorIonSelection();
00088 
00089     const DoubleReal & getMaxScore() const;
00090     void setMaxScore(const DoubleReal & max_score);
00091 
00092 
00094     struct TotalScoreMore :
00095       std::binary_function<Feature, Feature, bool>
00096     {
00097       inline bool operator()(Feature const & left, Feature const & right) const
00098       {
00099         return (DoubleReal)left.getMetaValue("msms_score") > (DoubleReal)right.getMetaValue("msms_score");
00100       }
00101 
00102     };
00103 
00105     struct SeqTotalScoreMore :
00106       std::binary_function<Feature, Feature, bool>
00107     {
00108       inline bool operator()(Feature const & left, Feature const & right) const
00109       {
00110         if (left.getRT() < right.getRT()) return true;
00111         else if (left.getRT() > right.getRT()) return false;
00112         else return (DoubleReal)left.getMetaValue("msms_score") > (DoubleReal)right.getMetaValue("msms_score");
00113       }
00114 
00115     };
00116 
00117 
00121     void sortByTotalScore(FeatureMap<> & features)
00122     {
00123       FeatureMap<>::Iterator beg = features.begin();
00124       FeatureMap<>::Iterator end  = features.end();
00125       std::sort(beg, end, TotalScoreMore());
00126     }
00127 
00135     void getNextPrecursors(FeatureMap<> & features, FeatureMap<> & next_features, UInt number);
00136     void getNextPrecursorsSeq(FeatureMap<> & features, FeatureMap<> & next_features, UInt number, DoubleReal & rt);
00137     void getNextPrecursors(std::vector<Int> & solution_indices, std::vector<PSLPFormulation::IndexTriple> & variable_indices, std::set<Int> & measured_variables,
00138                            FeatureMap<> & features, FeatureMap<> & new_features, UInt step_size, PSLPFormulation & ilp);
00139 
00140 //      /**
00141 //        @brief Change scoring of features using peptide identifications only from spectra of the last
00142 //        iteration
00143 //
00144 //        @param features FeatureMap with all possible precursors
00145 //        @param new_pep_ids Peptide identifications
00146 //        @param preprocessed_db Information from preprocessed database
00147 //
00148 //     */
00149 //     void rescoreIncremental(FeatureMap<>& features,std::vector<PeptideIdentification>& new_pep_ids,
00150 //                                                      std::vector<ProteinIdentification>& prot_ids,
00151 //                                                      PrecursorIonSelectionPreprocessing& preprocessed_db);
00152 
00153 
00163     void rescore(FeatureMap<> & features, std::vector<PeptideIdentification> & new_pep_ids,
00164                  std::vector<ProteinIdentification> & prot_ids,
00165                  PrecursorIonSelectionPreprocessing & preprocessed_db, bool check_meta_values = true);
00166 
00167 
00178     void simulateRun(FeatureMap<> & features, std::vector<PeptideIdentification> & pep_ids,
00179                      std::vector<ProteinIdentification> & prot_ids,
00180                      PrecursorIonSelectionPreprocessing & preprocessed_db,
00181                      String path, MSExperiment<> & experiment, String precursor_path = "");
00182 
00183     void setLPSolver(LPWrapper::SOLVER solver)
00184     {
00185       solver_ = solver;
00186       std::cout << " LPSolver set to " << solver_ << std::endl;
00187     }
00188 
00189     LPWrapper::SOLVER getLPSolver()
00190     {
00191       return solver_;
00192     }
00193 
00194     void reset();
00195 
00196     const std::map<String, std::set<String> > & getPeptideProteinCounter()
00197     {
00198       return prot_id_counter_;
00199     }
00200 
00201 private:
00202     void simulateILPBasedIPSRun_(FeatureMap<> & features, MSExperiment<> & experiment,
00203                                  std::vector<PeptideIdentification> & pep_ids,
00204                                  std::vector<ProteinIdentification> & prot_ids,
00205                                  PrecursorIonSelectionPreprocessing & preprocessed_db,
00206                                  String output_path, String precursor_path = "");
00207 
00208     void simulateRun_(FeatureMap<> & features, std::vector<PeptideIdentification> & pep_ids,
00209                       std::vector<ProteinIdentification> & prot_ids,
00210                       PrecursorIonSelectionPreprocessing & preprocessed_db, String path, String precursor_path = "");
00211 
00212     void shiftDown_(FeatureMap<> & features, PrecursorIonSelectionPreprocessing & preprocessed_db, String protein_acc);
00213 
00214     void shiftUp_(FeatureMap<> & features, PrecursorIonSelectionPreprocessing & preprocessed_db, String protein_acc);
00215 
00217     void updateMembers_();
00218 
00219     void rescore_(FeatureMap<> & features, std::vector<PeptideIdentification> & new_pep_ids,
00220                   PrecursorIonSelectionPreprocessing & preprocessed_db, PSProteinInference & protein_inference);
00221 
00227     void checkForRequiredUserParams_(FeatureMap<> & features);
00228 
00234     UInt filterProtIds_(std::vector<ProteinIdentification> & prot_ids);
00235 
00236     std::vector<PeptideIdentification> filterPeptideIds_(std::vector<PeptideIdentification> & pep_ids);
00237 
00238     void convertPeptideIdScores_(std::vector<PeptideIdentification> & pep_ids);
00239 
00241     UInt min_pep_ids_;
00243     DoubleReal max_score_;
00245     Type type_;
00247     std::map<String, std::set<String> > prot_id_counter_;
00249     std::vector<Size> fraction_counter_;
00251     DoubleReal mz_tolerance_;
00253     String mz_tolerance_unit_;
00255     UInt max_iteration_;
00256     Size x_variable_number_;
00257 
00258     LPWrapper::SOLVER solver_;
00259 
00260   };
00261 
00262 }
00263 
00264 #endif // #ifndef OPENMS_ANALYSIS_ID_PRECURSORIONSELECTION_H

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