Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
PSLPFormulation.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-2017.
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 #ifndef OPENMS_ANALYSIS_TARGETED_PSLPFORMULATION_H
36 #define OPENMS_ANALYSIS_TARGETED_PSLPFORMULATION_H
37 
41 
44 
45 //#define DEBUG_OPS
46 namespace OpenMS
47 {
48  class PrecursorIonSelectionPreprocessing;
49  class PSProteinInference;
50 
56  class OPENMS_DLLAPI PSLPFormulation :
57  public DefaultParamHandler
58  {
59 
60 
61 
62 public:
63 
65 
66  virtual ~PSLPFormulation();
67 
71  struct IndexTriple
72  {
77  double signal_weight;
79  };
80 
81 
93  void createAndSolveILPForKnownLCMSMapFeatureBased(const FeatureMap& features,
94  const PeakMap& experiment,
95  std::vector<IndexTriple>& variable_indices,
96  std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
97  std::set<Int>& charges_set, UInt ms2_spectra_per_rt_bin,
98  std::vector<int>& solution_indices);
99 
104  void createAndSolveILPForInclusionListCreation(PrecursorIonSelectionPreprocessing& preprocessing,
105  UInt ms2_spectra_per_rt_bin, UInt max_list_size,
106  FeatureMap& precursors,
107  bool solve_ILP = true);
108 
109  void createAndSolveCombinedLPForKnownLCMSMapFeatureBased(const FeatureMap& features,
110  const PeakMap& experiment,
111  std::vector<IndexTriple>& variable_indices,
112  std::vector<int>& solution_indices,
113  std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
114  std::set<Int>& charges_set, UInt ms2_spectra_per_rt_bin,
115  Size step_size = 0, bool sequential_order = false);
116 
117  void updateStepSizeConstraint(Size iteration, UInt step_size);
118  void updateFeatureILPVariables(FeatureMap& new_features, std::vector<IndexTriple>& variable_indices, std::map<Size, std::vector<String> >& feature_constraints_map);
119  void updateRTConstraintsForSequentialILP(Size& rt_index, UInt ms2_spectra_per_rt_bin, Size max_rt_index);
120  void updateCombinedILP(FeatureMap& features, PrecursorIonSelectionPreprocessing& preprocessed_db, std::vector<IndexTriple>& variable_indices,
121  std::vector<String>& new_protein_accs, std::vector<String>& protein_accs, PSProteinInference& prot_inference, Size& variable_counter,
122  std::map<String, std::vector<Size> >& protein_feature_map, Feature& new_feature, std::map<String, Size>& protein_variable_index_map,
123  std::map<String, std::set<String> >& prot_id_counter);
124 
125 
129  void solveILP(std::vector<int>& solution_indices);
130 
132  {
133  solver_ = solver;
134  }
135 
137  {
138  return solver_;
139  }
140 
141  struct IndexLess :
142  std::binary_function<IndexTriple, IndexTriple, bool>
143  {
144  inline bool operator()(IndexTriple const& left,
145  IndexTriple const& right) const
146  {
147  return left.feature < right.feature;
148  }
149 
150  };
151 
152 
153  struct ScanLess :
154  std::binary_function<IndexTriple, IndexTriple, bool>
155  {
156  inline bool operator()(IndexTriple const& left,
157  IndexTriple const& right) const
158  {
159  return left.scan < right.scan;
160  }
161 
162  };
163 
165  std::binary_function<IndexTriple, IndexTriple, bool>
166  {
167  inline bool operator()(IndexTriple const& left,
168  IndexTriple const& right) const
169  {
170  return left.variable < right.variable;
171  }
172 
173  };
174 
175 protected:
176 
177  void getXIC_(const std::vector<std::pair<Size, Size> >& end_points,
178  std::vector<double>& weights,
179  const PeakMap& experiment,
180  const bool normalize);
181 
185  void calculateXICs_(std::vector<std::vector<double> >& xics,
186  const FeatureMap& features,
187  const PeakMap& experiment,
188  const std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
189  const bool normalize);
190 
194  void createAndSolveILP_(const FeatureMap& features, std::vector<std::vector<double> >& intensity_weights,
195  std::set<Int>& charges_set, std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
196  std::vector<IndexTriple>& variable_indices, std::vector<int>& solution_indices,
197  UInt ms2_spectra_per_rt_bin, Size number_of_scans);
198 
199  void createAndSolveCombinedLPFeatureBased_(const FeatureMap& features, std::vector<std::vector<double> >& intensity_weights,
200  std::set<Int>& charges_set, std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
201  std::vector<IndexTriple>& variable_indices, std::vector<Int>& solution_indices,
202  UInt ms2_spectra_per_rt_bin, Size number_of_scans, Size step_size = 0, bool sequential_order = false);
203 
204  void addProteinToILP_(PrecursorIonSelectionPreprocessing& preprocessing,
205  std::map<String, std::vector<double> >::const_iterator map_iter,
206  Size& counter, Size& pep_counter, Size& feature_counter,
207  std::vector<IndexTriple>& variable_indices,
208  std::map<String, Size>& protein_penalty_index_map, FeatureMap& precursors);
209 
210  void addPrecursorAcquisitionNumberConstraint_(std::vector<IndexTriple>& variable_indices, Size number_of_features, UInt number_of_msms_per_precursor);
211 
212  void addMaxInclusionListSizeConstraints_(std::vector<IndexTriple>& variable_indices, /*Size number_of_features,*/ UInt max_list_size);
213 
214  void addRTBinCapacityConstraint_(std::vector<IndexTriple>& variable_indices,
215  Size max_rt_index, UInt ms2_spectra_per_rt_bin, bool sequential_order = false);
216 
217  void addProteinCoverageConstraint_(std::vector<IndexTriple>& variable_indices,
218  PrecursorIonSelectionPreprocessing& preprocessing,
219  std::map<String, Size> protein_variable_index_map);
220 
221  void addStepSizeConstraint_(std::vector<IndexTriple>& variable_indices, UInt step_size);
222 
223 
224  void assembleInclusionListForProteinBasedLP_(std::vector<IndexTriple>& variable_indices, FeatureMap& precursors, std::vector<int>& solution_indices, PrecursorIonSelectionPreprocessing& preprocessing);
225 
226  void updateObjFunction_(String acc, FeatureMap& features, PrecursorIonSelectionPreprocessing& preprocessed_db, std::vector<IndexTriple>& variable_indices);
227 
228 
229  Int getNumberOfPrecsInSpectrum_(Int constr_idx);
230 
233  };
234 
235  inline OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const PSLPFormulation::IndexTriple& triple)
236  {
237  os << "feature: " << triple.feature << " scan: " << triple.scan << " variable: " << triple.variable << " prot_acc: " << triple.prot_acc;
238  return os;
239  }
240 
241 } // namespace
242 
243 #endif // OPENMS_ANALYSIS_ID_PSLPFORMULATION_H
bool operator()(IndexTriple const &left, IndexTriple const &right) const
Definition: PSLPFormulation.h:167
A more convenient string class.
Definition: String.h:57
SOLVER
Definition: LPWrapper.h:129
Definition: PSLPFormulation.h:141
A container for features.
Definition: FeatureMap.h:94
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
Struct that holds the indices of the precursors in the feature map and the ilp formulation.
Definition: PSLPFormulation.h:71
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: LPWrapper.h:66
OPENSWATHALGO_DLLAPI void normalize(const std::vector< double > &intensities, double normalization_factor, std::vector< double > &normalized_intensities)
Normalize intensities in vector by normalization_factor.
Definition: PSLPFormulation.h:164
Definition: PSLPFormulation.h:153
LPWrapper::SOLVER solver_
Definition: PSLPFormulation.h:232
void setLPSolver(LPWrapper::SOLVER solver)
Definition: PSLPFormulation.h:131
double rt_probability
Definition: PSLPFormulation.h:76
This class implements the database preprocessing needing for precursor ion selection.
Definition: PrecursorIonSelectionPreprocessing.h:56
Size feature
Definition: PSLPFormulation.h:73
Size variable
Definition: PSLPFormulation.h:75
double signal_weight
Definition: PSLPFormulation.h:77
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
bool operator()(IndexTriple const &left, IndexTriple const &right) const
Definition: PSLPFormulation.h:156
bool operator()(IndexTriple const &left, IndexTriple const &right) const
Definition: PSLPFormulation.h:144
LPWrapper::SOLVER getLPSolver()
Definition: PSLPFormulation.h:136
An LC-MS feature.
Definition: Feature.h:70
This class implements protein inference for the precursor ion selection strategies.
Definition: PSProteinInference.h:53
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
String prot_acc
Definition: PSLPFormulation.h:78
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
LPWrapper * model_
Definition: PSLPFormulation.h:231
Int scan
Definition: PSLPFormulation.h:74
int Int
Signed integer type.
Definition: Types.h:103
Implements ILP formulation of precursor selection problems.
Definition: PSLPFormulation.h:56

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13