void ConsensusIDAlgorithm::apply(vector<PeptideIdentification>& ids, Size number_of_runs) { // abort if no IDs present if (ids.empty()) { return; } number_of_runs_ = (number_of_runs != 0) ? number_of_runs : ids.size(); // prepare data here, so that it doesn't have to happen in each algorithm: for (vector<PeptideIdentification>::iterator pep_it = ids.begin(); pep_it != ids.end(); ++pep_it) { pep_it->sort(); if ((considered_hits_ > 0) && (pep_it->getHits().size() > considered_hits_)) { pep_it->getHits().resize(considered_hits_); } } // make sure there are no duplicated hits (by sequence): IDFilter::removeDuplicatePeptideHits(ids, true); SequenceGrouping results; apply_(ids, results); // actual (subclass-specific) processing String score_type = ids[0].getScoreType(); bool higher_better = ids[0].isHigherScoreBetter(); ids.clear(); ids.resize(1); ids[0].setScoreType(score_type); ids[0].setHigherScoreBetter(higher_better); for (SequenceGrouping::iterator res_it = results.begin(); res_it != results.end(); ++res_it) { OPENMS_PRECONDITION(!res_it->second.second.empty(), "Consensus score for peptide required"); PeptideHit hit; if (res_it->second.second.size() == 2) { // filter by "support" value: double support = res_it->second.second[1]; if (support < min_support_) continue; hit.setMetaValue("consensus_support", support); } hit.setSequence(res_it->first); hit.setCharge(res_it->second.first); hit.setScore(res_it->second.second[0]); ids[0].insertHit(hit); #ifdef DEBUG_ID_CONSENSUS LOG_DEBUG << " - Output hit: " << hit.getSequence() << " " << hit.getScore() << endl; #endif } ids[0].assignRanks(); }
void IDDecoyProbability::apply(vector<PeptideIdentification> & ids) { double lower_score_better_default_value_if_zero(static_cast<double>(param_.getValue("lower_score_better_default_value_if_zero"))); double lower_score_better_default_value_if_zero_exp = pow(10.0, -lower_score_better_default_value_if_zero); vector<double> rev_scores, fwd_scores, all_scores; // get the forward scores for (vector<PeptideIdentification>::iterator it = ids.begin(); it != ids.end(); ++it) { String score_type = it->getScoreType(); if (it->getHits().size() > 0) { vector<PeptideHit> hits = it->getHits(); for (vector<PeptideHit>::iterator pit = hits.begin(); pit != hits.end(); ++pit) { double score = pit->getScore(); pit->setMetaValue(score_type + "_Score", score); if (!it->isHigherScoreBetter()) { if (score < lower_score_better_default_value_if_zero_exp) { score = lower_score_better_default_value_if_zero; } else { score = -log10(score); } } String target_decoy = (String)pit->getMetaValue("target_decoy"); if (target_decoy == "target") { fwd_scores.push_back(score); } else if (target_decoy == "decoy") { rev_scores.push_back(score); } all_scores.push_back(score); } it->setHits(hits); } } #ifdef IDDECOYPROBABILITY_DEBUG cerr << ids.size() << " " << rev_scores.size() << " " << fwd_scores.size() << " " << all_scores.size() << endl; #endif apply_(ids, rev_scores, fwd_scores, all_scores); return; }
auto apply(Xs && ... xs) const { constexpr size_t N = function_arity<F>::value - sizeof...(Ts); static_assert(N >= sizeof...(Xs), "Too many argument!"); return apply_(std::integral_constant<size_t, N - sizeof...(Xs)>(), std::make_index_sequence<sizeof...(Xs)>(), std::forward<Xs>(xs)...); }
void IDDecoyProbability::apply(vector<PeptideIdentification> & prob_ids, const vector<PeptideIdentification> & orig_fwd_ids, const vector<PeptideIdentification> & rev_ids) { double lower_score_better_default_value_if_zero((double)param_.getValue("lower_score_better_default_value_if_zero")); double lower_score_better_default_value_if_zero_exp = pow((double)10.0, -lower_score_better_default_value_if_zero); vector<PeptideIdentification> fwd_ids = orig_fwd_ids; vector<double> rev_scores, fwd_scores, all_scores; // get the forward scores for (vector<PeptideIdentification>::iterator it = fwd_ids.begin(); it != fwd_ids.end(); ++it) { String score_type = it->getScoreType(); if (it->getHits().size() > 0) { vector<PeptideHit> hits = it->getHits(); for (vector<PeptideHit>::iterator pit = hits.begin(); pit != hits.end(); ++pit) { double score = pit->getScore(); pit->setMetaValue(score_type + "_Score", score); if (!it->isHigherScoreBetter()) { if (score < lower_score_better_default_value_if_zero_exp) { score = lower_score_better_default_value_if_zero; } else { score = -log10(score); } } fwd_scores.push_back(score); all_scores.push_back(score); } it->setHits(hits); } } // get the reverse scores for (vector<PeptideIdentification>::const_iterator it = rev_ids.begin(); it != rev_ids.end(); ++it) { if (it->getHits().size() > 0) { for (vector<PeptideHit>::const_iterator pit = it->getHits().begin(); pit != it->getHits().end(); ++pit) { double score = pit->getScore(); if (!it->isHigherScoreBetter()) { if (score < lower_score_better_default_value_if_zero_exp) { score = lower_score_better_default_value_if_zero; } else { score = -log10(score); } } rev_scores.push_back(score); all_scores.push_back(score); } } } prob_ids = fwd_ids; apply_(prob_ids, rev_scores, fwd_scores, all_scores); return; }
virtual y_type eval(x_arg_type x, const std::array<double, sizeof...(ARGS)>& p) { return apply_(index_bind<1>(_Fcn, x), p); }