OpenMS  2.6.0
PrecursorIonSelection.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-2020.
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: Timo Sachsenberg $
32 // $Authors: $
33 // --------------------------------------------------------------------------
34 //
35 
36 #pragma once
37 
41 #include <set>
42 
43 namespace OpenMS
44 {
45  class PrecursorIonSelectionPreprocessing;
46  class PSProteinInference;
52  class OPENMS_DLLAPI PrecursorIonSelection :
53  public DefaultParamHandler
54  {
55 public:
56 
74  enum Type
75  {
76  IPS,
78  SPS,
81  DEX
82  };
83 
86  ~PrecursorIonSelection() override;
87 
88  const double & getMaxScore() const;
89  void setMaxScore(const double & max_score);
90 
91 
93  struct TotalScoreMore :
94  std::binary_function<Feature, Feature, bool>
95  {
96  inline bool operator()(Feature const & left, Feature const & right) const
97  {
98  return (double)left.getMetaValue("msms_score") > (double)right.getMetaValue("msms_score");
99  }
100 
101  };
102 
105  std::binary_function<Feature, Feature, bool>
106  {
107  inline bool operator()(Feature const & left, Feature const & right) const
108  {
109  if (left.getRT() < right.getRT()) return true;
110  else if (left.getRT() > right.getRT()) return false;
111  else return (double)left.getMetaValue("msms_score") > (double)right.getMetaValue("msms_score");
112  }
113 
114  };
115 
116 
120  void sortByTotalScore(FeatureMap & features)
121  {
122  FeatureMap::Iterator beg = features.begin();
123  FeatureMap::Iterator end = features.end();
124  std::sort(beg, end, TotalScoreMore());
125  }
126 
134  void getNextPrecursors(FeatureMap & features, FeatureMap & next_features, UInt number);
135  void getNextPrecursorsSeq(FeatureMap & features, FeatureMap & next_features, UInt number, double & rt);
136  void getNextPrecursors(std::vector<Int> & solution_indices, std::vector<PSLPFormulation::IndexTriple> & variable_indices, std::set<Int> & measured_variables,
137  FeatureMap & features, FeatureMap & new_features, UInt step_size, PSLPFormulation & ilp);
138 
139 // /**
140 // @brief Change scoring of features using peptide identifications only from spectra of the last
141 // iteration
142 //
143 // @param features FeatureMap with all possible precursors
144 // @param new_pep_ids Peptide identifications
145 // @param preprocessed_db Information from preprocessed database
146 //
147 // */
148 // void rescoreIncremental(FeatureMap& features,std::vector<PeptideIdentification>& new_pep_ids,
149 // std::vector<ProteinIdentification>& prot_ids,
150 // PrecursorIonSelectionPreprocessing& preprocessed_db);
151 
152 
162  void rescore(FeatureMap & features, std::vector<PeptideIdentification> & new_pep_ids,
163  std::vector<ProteinIdentification> & prot_ids,
164  PrecursorIonSelectionPreprocessing & preprocessed_db, bool check_meta_values = true);
165 
166 
177  void simulateRun(FeatureMap & features, std::vector<PeptideIdentification> & pep_ids,
178  std::vector<ProteinIdentification> & prot_ids,
179  PrecursorIonSelectionPreprocessing & preprocessed_db,
180  String path, PeakMap & experiment, String precursor_path = "");
181 
183  {
184  solver_ = solver;
185  std::cout << " LPSolver set to " << solver_ << std::endl;
186  }
187 
189  {
190  return solver_;
191  }
192 
193  void reset();
194 
195  const std::map<String, std::set<String> > & getPeptideProteinCounter()
196  {
197  return prot_id_counter_;
198  }
199 
200 private:
201  void simulateILPBasedIPSRun_(FeatureMap & features, PeakMap & experiment,
202  std::vector<PeptideIdentification> & pep_ids,
203  std::vector<ProteinIdentification> & prot_ids,
204  PrecursorIonSelectionPreprocessing & preprocessed_db,
205  String output_path, String precursor_path = "");
206 
207  void simulateRun_(FeatureMap & features, std::vector<PeptideIdentification> & pep_ids,
208  std::vector<ProteinIdentification> & prot_ids,
209  PrecursorIonSelectionPreprocessing & preprocessed_db, String path, String precursor_path = "");
210 
211  void shiftDown_(FeatureMap & features, PrecursorIonSelectionPreprocessing & preprocessed_db, String protein_acc);
212 
213  void shiftUp_(FeatureMap & features, PrecursorIonSelectionPreprocessing & preprocessed_db, String protein_acc);
214 
216  void updateMembers_() override;
217 
218  void rescore_(FeatureMap & features, std::vector<PeptideIdentification> & new_pep_ids,
219  PrecursorIonSelectionPreprocessing & preprocessed_db, PSProteinInference & protein_inference);
220 
226  void checkForRequiredUserParams_(FeatureMap & features);
227 
233  UInt filterProtIds_(std::vector<ProteinIdentification> & prot_ids);
234 
235  std::vector<PeptideIdentification> filterPeptideIds_(std::vector<PeptideIdentification> & pep_ids);
236 
237  void convertPeptideIdScores_(std::vector<PeptideIdentification> & pep_ids);
238 
242  double max_score_;
246  std::map<String, std::set<String> > prot_id_counter_;
248  std::vector<Size> fraction_counter_;
256 
258 
259  };
260 
261 }
262 
double
OpenMS::PrecursorIonSelection::mz_tolerance_unit_
String mz_tolerance_unit_
precursor ion error tolerance unit (ppm or Da)
Definition: PrecursorIonSelection.h:252
OpenMS::FeatureMap::Iterator
Base::iterator Iterator
Definition: FeatureMap.h:143
OpenMS::MetaInfoInterface::getMetaValue
const DataValue & getMetaValue(const String &name, const DataValue &default_value=DataValue::EMPTY) const
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not fo...
OpenMS::PrecursorIonSelection::IPS
Definition: PrecursorIonSelection.h:76
OpenMS::String
A more convenient string class.
Definition: String.h:59
OpenMS::PrecursorIonSelection
This class implements different precursor ion selection strategies.
Definition: PrecursorIonSelection.h:52
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::PrecursorIonSelection::SeqTotalScoreMore
Compare by score.
Definition: PrecursorIonSelection.h:104
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::PrecursorIonSelection::Type
Type
Precursor ion selection type (iterative, static, upshift, downshift, dynamic exclusion).
Definition: PrecursorIonSelection.h:74
OpenMS::PrecursorIonSelection::solver_
LPWrapper::SOLVER solver_
Definition: PrecursorIonSelection.h:257
OpenMS::PrecursorIonSelection::SeqTotalScoreMore::operator()
bool operator()(Feature const &left, Feature const &right) const
Definition: PrecursorIonSelection.h:107
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
OpenMS::PrecursorIonSelection::ILP_IPS
Definition: PrecursorIonSelection.h:77
OpenMS::PrecursorIonSelection::x_variable_number_
Size x_variable_number_
Definition: PrecursorIonSelection.h:255
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
PSLPFormulation.h
OpenMS::PrecursorIonSelection::fraction_counter_
std::vector< Size > fraction_counter_
stores the number of selected precursors per fraction
Definition: PrecursorIonSelection.h:248
OpenMS::PrecursorIonSelection::SPS
Definition: PrecursorIonSelection.h:78
OpenMS::PSLPFormulation
Implements ILP formulation of precursor selection problems.
Definition: PSLPFormulation.h:55
FeatureMap.h
OpenMS::PrecursorIonSelection::getPeptideProteinCounter
const std::map< String, std::set< String > > & getPeptideProteinCounter()
Definition: PrecursorIonSelection.h:195
OpenMS::PrecursorIonSelection::UPSHIFT
Definition: PrecursorIonSelection.h:79
OpenMS::PrecursorIonSelection::setLPSolver
void setLPSolver(LPWrapper::SOLVER solver)
Definition: PrecursorIonSelection.h:182
OpenMS::PrecursorIonSelection::max_iteration_
UInt max_iteration_
maximal number of iterations
Definition: PrecursorIonSelection.h:254
OpenMS::PrecursorIonSelection::min_pep_ids_
UInt min_pep_ids_
minimal number of peptides identified for a protein to be declared identified
Definition: PrecursorIonSelection.h:240
OpenMS::PrecursorIonSelection::TotalScoreMore
Compare by score.
Definition: PrecursorIonSelection.h:93
OpenMS::Peak2D::getRT
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::PrecursorIonSelection::prot_id_counter_
std::map< String, std::set< String > > prot_id_counter_
stores the peptide sequences for all protein identifications
Definition: PrecursorIonSelection.h:246
OpenMS::PrecursorIonSelection::getLPSolver
LPWrapper::SOLVER getLPSolver()
Definition: PrecursorIonSelection.h:188
OpenMS::PSProteinInference
This class implements protein inference for the precursor ion selection strategies.
Definition: PSProteinInference.h:52
OpenMS::PrecursorIonSelection::mz_tolerance_
double mz_tolerance_
precursor ion error tolerance
Definition: PrecursorIonSelection.h:250
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:97
OpenMS::Feature
An LC-MS feature.
Definition: Feature.h:70
OpenMS::LPWrapper::SOLVER
SOLVER
Definition: LPWrapper.h:130
OpenMS::PrecursorIonSelection::max_score_
double max_score_
maximal score in the FeatureMap
Definition: PrecursorIonSelection.h:242
PeptideIdentification.h
OpenMS::PrecursorIonSelection::TotalScoreMore::operator()
bool operator()(Feature const &left, Feature const &right) const
Definition: PrecursorIonSelection.h:96
OpenMS::PrecursorIonSelection::type_
Type type_
precursor ion selection strategy
Definition: PrecursorIonSelection.h:244
OpenMS::PrecursorIonSelection::sortByTotalScore
void sortByTotalScore(FeatureMap &features)
Sort features by total score.
Definition: PrecursorIonSelection.h:120
OpenMS::PrecursorIonSelectionPreprocessing
This class implements the database preprocessing needing for precursor ion selection.
Definition: PrecursorIonSelectionPreprocessing.h:55
OpenMS::PrecursorIonSelection::DOWNSHIFT
Definition: PrecursorIonSelection.h:80