00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
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