35 #ifndef OPENMS_ANALYSIS_OPENSWATH_CONFIDENCESCORING 
   36 #define OPENMS_ANALYSIS_OPENSWATH_CONFIDENCESCORING 
   41 #include <boost/bimap.hpp> 
   42 #include <boost/bimap/multiset_of.hpp> 
   43 #include <boost/random/uniform_int.hpp> 
   44 #include <boost/random/mersenne_twister.hpp> 
   45 #include <boost/random/variate_generator.hpp> 
   65       generator_(), rand_gen_(generator_, boost::uniform_int<>())
 
   67       if (!test_mode_) rand_gen_.engine().seed(time(0)); 
 
   73     typedef boost::bimap<DoubleReal, boost::bimaps::multiset_of<DoubleReal> > 
 
   85         DoubleReal lm = intercept + rt_coef * diff_rt * diff_rt + 
 
   87         return 1.0 / (1.0 + exp(-lm));
 
   99         return (rt - min_rt) / (max_rt - min_rt) * 100;
 
  119     boost::variate_generator<boost::mt19937&, boost::uniform_int<> > 
rand_gen_;
 
  122     void chooseDecoys_();
 
  129                            const String& cv_accession = 
"MS:1000896");
 
  133     void extractIntensities_(
BimapType& intensity_map, 
Size n_transitions,
 
  141                            const std::set<String>& transition_ids = std::set<String>());
 
  144     void scoreFeature_(
Feature& feature);
 
  151       n_decoys_ = n_decoys;
 
  152       n_transitions_ = n_transitions;
 
  153       rt_trafo_ = rt_trafo;
 
  158       glm_.intercept = intercept;
 
  159       glm_.rt_coef = rt_coef;
 
  160       glm_.int_coef = int_coef;
 
  178       Size n_assays = library_.getPeptides().size();
 
  182                                          "There need to be at least 2 assays in the library for ConfidenceScoring.");
 
  185       if (n_assays - 1 < n_decoys_)
 
  187         LOG_WARN << 
"Warning: Parameter 'decoys' (" << n_decoys_ 
 
  188                  << 
") is higher than the number of unrelated assays in the " 
  189                  << 
"library (" << n_assays - 1 << 
"). " 
  190                  << 
"Using all unrelated assays as decoys." << std::endl;
 
  192       if (n_assays - 1 <= n_decoys_) n_decoys_ = 0; 
 
  194       decoy_index_.resize(n_assays);
 
  195       for (
Size i = 0; i < n_assays; ++i) decoy_index_[i] = boost::numeric_cast<Int>(i);
 
  198       LOG_DEBUG << 
"Building transition map..." << std::endl;
 
  199       for (
Size i = 0; i < library_.getTransitions().size(); ++i)
 
  201         const String& ref = library_.getTransitions()[i].getPeptideRef();
 
  202         transition_map_[ref].push_back(boost::numeric_cast<Int>(i));
 
  205       LOG_DEBUG << 
"Determining retention time range..." << std::endl;
 
  206       rt_norm_.min_rt = std::numeric_limits<double>::infinity();
 
  207       rt_norm_.max_rt = -std::numeric_limits<double>::infinity();
 
  208       for (std::vector<TargetedExperiment::Peptide>::const_iterator it = 
 
  209              library_.getPeptides().begin(); it != library_.getPeptides().end();
 
  213         if (current_rt == -1.0) 
continue; 
 
  214         rt_norm_.min_rt = std::min(rt_norm_.min_rt, current_rt);
 
  215         rt_norm_.max_rt = std::max(rt_norm_.max_rt, current_rt);
 
  219       LOG_DEBUG << 
"Scoring features..." << std::endl;
 
  220       startProgress(0, features.size(), 
"scoring features");
 
  223            feat_it != features.end(); ++feat_it)
 
  225         LOG_DEBUG << 
"Feature " << feat_it - features.begin() + 1 
 
  226                   << 
" (ID '" << feat_it->
getUniqueId() << 
"')"<< std::endl;
 
  227         scoreFeature_(*feat_it);
 
  228         setProgress(feat_it - features.begin());
 
  238 #endif // OPENMS_ANALYSIS_OPENSWATH_CONFIDENCESCORING 
DoubleReal rt_coef
Definition: ConfidenceScoring.h:80
A more convenient string class. 
Definition: String.h:56
void initializeGlm(double intercept, double rt_coef, double int_coef)
Definition: ConfidenceScoring.h:156
DoubleReal min_rt
Definition: ConfidenceScoring.h:94
DoubleReal int_coef
Definition: ConfidenceScoring.h:81
void scoreMap(FeatureMap<> &features)
Score a feature map -> make sure the class is properly initialized. 
Definition: ConfidenceScoring.h:175
Map< String, IntList > transition_map_
Definition: ConfidenceScoring.h:109
#define LOG_DEBUG
Macro for general debugging information. 
Definition: LogStream.h:459
#define LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged...
Definition: LogStream.h:451
TargetedExperiment library_
Definition: ConfidenceScoring.h:103
TransformationDescription rt_trafo_
RT transformation to map measured RTs to assay RTs. 
Definition: ConfidenceScoring.h:114
boost::mt19937 generator_
Definition: ConfidenceScoring.h:116
DoubleReal max_rt
Definition: ConfidenceScoring.h:95
A method or algorithm argument contains illegal values. 
Definition: Exception.h:634
ConfidenceScoring(bool test_mode_=false)
Constructor. 
Definition: ConfidenceScoring.h:64
DoubleReal intercept
Definition: ConfidenceScoring.h:79
IntList decoy_index_
Definition: ConfidenceScoring.h:105
An LC-MS feature. 
Definition: Feature.h:66
void initialize(TargetedExperiment library, Size n_decoys, Size n_transitions, TransformationDescription rt_trafo)
Definition: ConfidenceScoring.h:148
Definition: ConfidenceScoring.h:58
size_t Size
Size type e.g. used as variable which can hold result of size() 
Definition: Types.h:144
Size n_decoys_
Definition: ConfidenceScoring.h:107
Size n_transitions_
Definition: ConfidenceScoring.h:111
Base class for all classes that want to report their progess. 
Definition: ProgressLogger.h:56
This class stores an prediction of an SRM/MRM transition. 
Definition: TargetedExperiment.h:53
boost::variate_generator< boost::mt19937 &, boost::uniform_int<> > rand_gen_
Random number generator (must be initialized in init. list of c'tor!) 
Definition: ConfidenceScoring.h:119
Map class based on the STL map (containing serveral convenience functions) 
Definition: Map.h:50
UInt64 getUniqueId() const 
Non-mutable access to unique id - returns the unique id. 
Definition: UniqueIdInterface.h:109
DoubleReal list. 
Definition: DoubleList.h:56
boost::bimap< DoubleReal, boost::bimaps::multiset_of< DoubleReal > > BimapType
Mapping: Q3 m/z <-> transition intensity (maybe not unique!) 
Definition: ConfidenceScoring.h:74
Definition: TargetedExperimentHelper.h:211
Int list. 
Definition: IntList.h:56