35 #ifndef OPENMS_ANALYSIS_TARGETED_PSLPFORMULATION_H
36 #define OPENMS_ANALYSIS_TARGETED_PSLPFORMULATION_H
47 class PrecursorIonSelectionPreprocessing;
48 class PSProteinInference;
91 template <
typename InputPeakType>
92 void createAndSolveILPForKnownLCMSMapFeatureBased(
const FeatureMap& features,
94 std::vector<IndexTriple>& variable_indices,
95 std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
96 std::set<Int>& charges_set,
UInt ms2_spectra_per_rt_bin,
97 std::vector<int>& solution_indices);
104 UInt ms2_spectra_per_rt_bin,
UInt max_list_size,
106 bool solve_ILP =
true);
108 template <
typename InputPeakType>
109 void createAndSolveCombinedLPForKnownLCMSMapFeatureBased(
const FeatureMap& features,
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);
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);
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);
129 void solveILP(std::vector<int>& solution_indices);
142 std::binary_function<IndexTriple, IndexTriple, bool>
154 std::binary_function<IndexTriple, IndexTriple, bool>
165 std::binary_function<IndexTriple, IndexTriple, bool>
177 template <
typename InputPeakType>
178 void getXIC_(
const std::vector<std::pair<Size, Size> >& end_points,
179 std::vector<double>& weights,
186 template <
typename InputPeakType>
187 void calculateXICs_(std::vector<std::vector<double> >& xics,
190 const std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
196 void createAndSolveILP_(
const FeatureMap& features, std::vector<std::vector<double> >& intensity_weights,
197 std::set<Int>& charges_set, std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
198 std::vector<IndexTriple>& variable_indices, std::vector<int>& solution_indices,
199 UInt ms2_spectra_per_rt_bin,
Size number_of_scans);
201 void createAndSolveCombinedLPFeatureBased_(
const FeatureMap& features, std::vector<std::vector<double> >& intensity_weights,
202 std::set<Int>& charges_set, std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
203 std::vector<IndexTriple>& variable_indices, std::vector<Int>& solution_indices,
204 UInt ms2_spectra_per_rt_bin,
Size number_of_scans,
Size step_size = 0,
bool sequential_order =
false);
207 std::map<
String, std::vector<double> >::const_iterator map_iter,
208 Size& counter,
Size& pep_counter,
Size& feature_counter,
209 std::vector<IndexTriple>& variable_indices,
210 std::map<String, Size>& protein_penalty_index_map,
FeatureMap& precursors);
212 void addPrecursorAcquisitionNumberConstraint_(std::vector<IndexTriple>& variable_indices,
Size number_of_features,
UInt number_of_msms_per_precursor);
214 void addMaxInclusionListSizeConstraints_(std::vector<IndexTriple>& variable_indices,
UInt max_list_size);
216 void addRTBinCapacityConstraint_(std::vector<IndexTriple>& variable_indices,
217 Size max_rt_index,
UInt ms2_spectra_per_rt_bin,
bool sequential_order =
false);
219 void addProteinCoverageConstraint_(std::vector<IndexTriple>& variable_indices,
221 std::map<String, Size> protein_variable_index_map);
223 void addStepSizeConstraint_(std::vector<IndexTriple>& variable_indices,
UInt step_size);
231 Int getNumberOfPrecsInSpectrum_(
Int constr_idx);
237 template <
typename InputPeakType>
239 std::vector<double>& weights,
243 double max_weight = 0.;
245 for (
Size i = 0; i < end_points.size(); i += 2)
248 for (
Size j = end_points[i].second; j <= end_points[i + 1].second; ++j)
250 weight += experiment[end_points[i].first][j].getIntensity();
253 if (weight > max_weight)
256 weights.push_back(weight);
262 for (
Size i = 0; i < weights.size(); ++i)
265 if (end_points.size() >= i)
267 std::cout <<
"scan " << end_points[i].first <<
" " << weights[i] <<
" " << max_weight
268 <<
" " << weights[i] / max_weight << std::endl;
271 weights[i] /= max_weight;
276 template <
typename InputPeakType>
280 const std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
284 xics.resize(features.size());
285 for (
Size i = 0; i < features.size(); ++i)
287 getXIC_(mass_ranges[i], xics[i], experiment, normalize);
291 template <
typename InputPeakType>
294 std::vector<IndexTriple>& variable_indices,
295 std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
296 std::set<Int>& charges_set,
UInt ms2_spectra_per_rt_bin,
297 std::vector<int>& solution_indices)
300 std::vector<std::vector<double> > intensity_weights;
301 if (
param_.
getValue(
"feature_based:no_intensity_normalization") ==
"false")
303 calculateXICs_(intensity_weights, features, experiment, mass_ranges,
true);
307 calculateXICs_(intensity_weights, features, experiment, mass_ranges,
false);
310 std::cout <<
"got xics" << std::endl;
313 createAndSolveILP_(features, intensity_weights, charges_set, mass_ranges, variable_indices, solution_indices,
314 ms2_spectra_per_rt_bin, experiment.
size());
319 os <<
"feature: " << triple.
feature <<
" scan: " << triple.
scan <<
" variable: " << triple.
variable <<
" prot_acc: " << triple.
prot_acc;
323 template <
typename InputPeakType>
326 std::vector<IndexTriple>& variable_indices,
327 std::vector<Int>& solution_indices,
328 std::vector<std::vector<std::pair<Size, Size> > >& mass_ranges,
329 std::set<Int>& charges_set,
UInt ms2_spectra_per_rt_bin,
330 Size step_size,
bool sequential_order)
333 std::vector<std::vector<double> > intensity_weights;
334 calculateXICs_(intensity_weights, features, experiment, mass_ranges,
true);
336 std::cout <<
"got xics" << std::endl;
340 experiment.
size(), step_size, sequential_order);
345 #endif // OPENMS_ANALYSIS_ID_PSLPFORMULATION_H
A more convenient string class.
Definition: String.h:57
Size size() const
Definition: MSExperiment.h:117
Param param_
Container for current parameters.
Definition: DefaultParamHandler.h:150
SOLVER
Definition: LPWrapper.h:129
A container for features.
Definition: FeatureMap.h:93
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.
const DataValue & getValue(const String &key) const
Returns a value of a parameter.
This class implements the database preprocessing needing for precursor ion selection.
Definition: PrecursorIonSelectionPreprocessing.h:56
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
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:69
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
int Int
Signed integer type.
Definition: Types.h:96