43 #include <boost/unordered_map.hpp>
46 #include <unordered_set>
54 :
public std::vector<std::pair<double, double>>
56 typedef std::vector<std::pair<double, double>>
Base;
72 std::is_same<T, PeptideIdentification>::value || std::is_same<T, ProteinIdentification>::value;
78 static bool const value = std::is_same<T, PeptideHit>::value || std::is_same<T, ProteinHit>::value;
98 const std::vector<ProteinIdentification::ProteinGroup> &grps,
99 const std::unordered_set<std::string> &decoy_accs);
106 scores_labels.reserve(scores_labels.size() +
id.getHits().size());
107 std::transform(
id.getHits().begin(),
id.getHits().end(),
108 std::back_inserter(scores_labels),
122 if (
id.getIdentifier() == identifier)
124 getScores_(scores_labels,
id, all_hits, charge);
133 if (
id.getIdentifier() == identifier)
143 if (
id.getIdentifier() == identifier)
149 template<typename IDType, typename std::enable_if<IsIDType<IDType>::value>::type * =
nullptr>
152 const IDType &
id,
const String &identifier)
154 if (
id.getIdentifier() == identifier)
160 template<
class ...Args>
171 getScores_(scores_labels, hit, std::forward<Args>(args)...);
179 getScores_(scores_labels, hit, std::forward<Args>(args)...);
206 template<typename HitType, typename std::enable_if<IsHitType<HitType>::value>::type * =
nullptr>
212 scores_labels.emplace_back(hit.getScore(),
getTDLabel_(hit));
215 template<typename IDType, typename std::enable_if<IsIDType<IDType>::value>::type * =
nullptr>
220 for (
const typename IDType::HitType &hit :
id.getHits())
226 template<
class ...Args>
229 const std::vector<PeptideIdentification> &ids,
232 for (
const auto &
id : ids)
234 getScores_(scores_labels,
id, std::forward<Args>(args)...);
247 const ConsensusMap &cmap,
bool include_unassigned_peptides)
256 const ConsensusMap &cmap,
bool include_unassigned_peptides,
int charge)
269 {
getScores_(scores_labels,
id, identifier); };
274 const ConsensusMap &cmap,
bool include_unassigned_peptides,
int charge,
const String &identifier)
278 {
getScores_(scores_labels,
id, charge, identifier); };
283 const ConsensusMap &cmap,
bool include_unassigned_peptides,
bool all_hits)
292 const ConsensusMap &cmap,
bool include_unassigned_peptides,
bool all_hits,
int charge)
296 {
getScores_(scores_labels,
id, all_hits, charge); };
301 const ConsensusMap &cmap,
bool include_unassigned_peptides,
bool all_hits,
const String &identifier)
305 {
getScores_(scores_labels,
id, all_hits, identifier); };
310 const ConsensusMap &cmap,
bool include_unassigned_peptides,
bool all_hits,
int charge,
const String &identifier)
314 {
getScores_(scores_labels,
id, all_hits, charge, identifier); };
325 return std::string(idOrHit.
getMetaValue(
"target_decoy"))[0] ==
't';
339 template<
typename IDType,
class ...Args>
340 static void setScores_(
const std::map<double, double> &scores_to_FDR,
341 std::vector<IDType> &ids,
342 const std::string &score_type,
348 setScores_(scores_to_FDR,
id, score_type, higher_better, &args...);
352 template<
typename IDType>
356 String old_score_type =
id.getScoreType() +
"_score";
357 id.setScoreType(score_type);
358 id.setHigherScoreBetter(higher_better);
359 return old_score_type;
362 template<
typename IDType>
363 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
364 bool higher_better,
bool keep_decoy)
370 setScores_(scores_to_FDR,
id, old_score_type);
378 template<
typename IDType>
379 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
380 const String &old_score_type)
382 std::vector<typename IDType::HitType> &hits =
id.getHits();
383 for (
auto &hit : hits)
385 setScore_(scores_to_FDR, hit, old_score_type);
389 template<
typename IDType,
class ...Args>
391 const String &old_score_type, Args ... args)
393 std::vector<typename IDType::HitType> &hits =
id.getHits();
394 std::vector<typename IDType::HitType> new_hits;
395 new_hits.reserve(hits.size());
396 for (
auto &hit : hits)
403 template<
typename HitType>
404 static void setScore_(
const std::map<double, double> &scores_to_FDR, HitType &hit,
const std::string &old_score_type)
406 hit.setMetaValue(old_score_type, hit.getScore());
407 hit.setScore(scores_to_FDR.lower_bound(hit.getScore())->second);
410 template<
typename IDType>
411 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
415 setScores_(scores_to_FDR,
id, old_score_type);
418 static void setScores_(
const std::map<double, double> &scores_to_FDR,
420 const std::string &score_type,
428 setScores_(scores_to_FDR,
id, old_score_type, charge);
432 setScoresAndRemoveDecoys_<PeptideIdentification>(scores_to_FDR,
id, old_score_type, charge);
436 static void setScores_(
const std::map<double, double> &scores_to_FDR,
438 const std::string &score_type,
444 if (
id.getIdentifier() == identifier)
446 setScores_(scores_to_FDR,
id, score_type, higher_better, keep_decoy, charge);
450 template<
typename IDType>
451 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
452 bool higher_better,
bool keep_decoy,
const String &identifier)
454 if (
id.getIdentifier() == identifier)
456 setScores_(scores_to_FDR,
id, score_type, higher_better, keep_decoy);
460 static void setScores_(
const std::map<double, double> &scores_to_FDR,
462 const std::string &score_type,
467 if (
id.getIdentifier() == identifier)
469 setScores_(scores_to_FDR,
id, score_type, higher_better, charge);
473 template<
typename IDType>
474 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
475 bool higher_better,
const String &identifier)
477 if (
id.getIdentifier() == identifier)
479 setScores_(scores_to_FDR,
id, score_type, higher_better);
485 const std::map<double, double> &scores_to_FDR,
486 std::vector<ProteinIdentification::ProteinGroup> &grps,
487 const std::string &score_type,
500 template<
typename HitType>
503 const std::string &old_score_type,
504 std::vector<HitType> &new_hits)
506 const String &target_decoy(hit.getMetaValue(
"target_decoy"));
507 if (target_decoy[0] ==
't')
509 hit.setMetaValue(old_score_type, hit.getScore());
510 hit.setScore(scores_to_FDR.lower_bound(hit.getScore())->second);
511 new_hits.push_back(std::move(hit));
525 const std::string &old_score_type,
526 std::vector<PeptideHit> &new_hits,
532 if (target_decoy[0] ==
't')
536 new_hits.push_back(std::move(hit));
541 new_hits.push_back(std::move(hit));
559 bool include_unassigned_peptides,
560 const std::string &score_type,
568 higher_better, keep_decoy); };
573 bool include_unassigned_peptides,
574 const std::string &score_type,
583 higher_better, keep_decoy, charge); };
588 bool include_unassigned_peptides,
589 const std::string &score_type,
592 const String& run_identifier)
598 higher_better, keep_decoy, run_identifier); };
603 bool include_unassigned_peptides,
604 const std::string &score_type,
608 const String& run_identifier)
614 higher_better, keep_decoy, charge, run_identifier); };
629 OPENMS_PRETTY_FUNCTION,
630 "Meta value 'target_decoy' does not exist in all ProteinHits! Reindex the idXML file with 'PeptideIndexer'");
A container for consensus elements.
Definition: ConsensusMap.h:88
A class for extracting and reinserting IDScores from Peptide/ProteinIdentifications and from Consensu...
Definition: IDScoreGetterSetter.h:64
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, int charge)
Definition: IDScoreGetterSetter.h:254
static void setPeptideScoresForMap_(const std::map< double, double > &scores_to_FDR, ConsensusMap &cmap, bool include_unassigned_peptides, const std::string &score_type, bool higher_better, bool keep_decoy, int charge)
Definition: IDScoreGetterSetter.h:571
static void setPeptideScoresForMap_(const std::map< double, double > &scores_to_FDR, ConsensusMap &cmap, bool include_unassigned_peptides, const std::string &score_type, bool higher_better, bool keep_decoy, int charge, const String &run_identifier)
Definition: IDScoreGetterSetter.h:601
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, bool all_hits, int charge, const String &identifier)
Definition: IDScoreGetterSetter.h:308
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides)
Helper for getting scores in ConsensusMaps.
Definition: IDScoreGetterSetter.h:245
static void setScoreAndMoveIfTarget_(const std::map< double, double > &scores_to_FDR, HitType &hit, const std::string &old_score_type, std::vector< HitType > &new_hits)
Used when keep_decoy_peptides or proteins is false.
Definition: IDScoreGetterSetter.h:501
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, const String &identifier)
Definition: IDScoreGetterSetter.h:263
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, bool all_hits)
Definition: IDScoreGetterSetter.h:281
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, int charge, const String &identifier)
Definition: IDScoreGetterSetter.h:272
static bool getTDLabel_(const MetaInfoInterface &idOrHit)
For peptide hits, a hit is considered target also if it maps to both a target and a decoy protein (i....
Definition: IDScoreGetterSetter.h:323
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, bool all_hits, int charge)
Definition: IDScoreGetterSetter.h:290
static void checkTDAnnotation_(const MetaInfoInterface &id_or_hit)
To check the metavalues before we do anything.
Definition: IDScoreGetterSetter.h:623
static void setPeptideScoresForMap_(const std::map< double, double > &scores_to_FDR, ConsensusMap &cmap, bool include_unassigned_peptides, const std::string &score_type, bool higher_better, bool keep_decoy)
Helper for applying set Scores on ConsensusMaps.
Definition: IDScoreGetterSetter.h:557
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, bool all_hits, const String &identifier)
Definition: IDScoreGetterSetter.h:299
static void setPeptideScoresForMap_(const std::map< double, double > &scores_to_FDR, ConsensusMap &cmap, bool include_unassigned_peptides, const std::string &score_type, bool higher_better, bool keep_decoy, const String &run_identifier)
Definition: IDScoreGetterSetter.h:586
static void setScoreAndMoveIfTarget_(const std::map< double, double > &scores_to_FDR, PeptideHit &hit, const std::string &old_score_type, std::vector< PeptideHit > &new_hits, int charge)
Used when keep_decoy_peptides is false and charge states are considered.
Definition: IDScoreGetterSetter.h:523
void applyFunctionOnPeptideIDs(T &&f, bool include_unassigned=true)
applies a function on all PeptideIDs or only assigned ones
Definition: MapUtilities.h:68
Representation of a peptide hit.
Definition: PeptideHit.h:57
double getScore() const
returns the PSM score
Int getCharge() const
returns the charge of the peptide
void setScore(double score)
sets the PSM score
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:65
Representation of a protein hit.
Definition: ProteinHit.h:60
double getScore() const
returns the score of the protein hit
Representation of a protein identification run.
Definition: ProteinIdentification.h:72
A more convenient string class.
Definition: String.h:61
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const IDType &id, const String &identifier)
Definition: IDScoreGetterSetter.h:150
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, int charge)
Definition: IDScoreGetterSetter.h:195
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, int charge, const String &identifier)
Definition: IDScoreGetterSetter.h:139
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const IDType &id)
Definition: IDScoreGetterSetter.h:216
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideHit &hit, int charge)
Definition: IDScoreGetterSetter.h:183
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const std::vector< PeptideIdentification > &ids, Args &&... args)
Definition: IDScoreGetterSetter.h:227
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const HitType &hit)
Definition: IDScoreGetterSetter.h:207
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, bool all_hits, const String &identifier)
Definition: IDScoreGetterSetter.h:129
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const std::vector< ProteinIdentification::ProteinGroup > &grps, const std::unordered_set< std::string > &decoy_accs)
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const ProteinIdentification &id)
Definition: IDScoreGetterSetter.h:101
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, bool all_hits, int charge, const String &identifier)
Definition: IDScoreGetterSetter.h:118
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, bool all_hits, Args &&... args)
Definition: IDScoreGetterSetter.h:161
static void setScoresAndRemoveDecoys_(const std::map< double, double > &scores_to_FDR, IDType &id, const String &old_score_type, Args ... args)
Definition: IDScoreGetterSetter.h:390
static void setScores_(const std::map< double, double > &scores_to_FDR, std::vector< ProteinIdentification::ProteinGroup > &grps, const std::string &score_type, bool higher_better)
static String setScoreType_(IDType &id, const std::string &score_type, bool higher_better)
Definition: IDScoreGetterSetter.h:353
static void setScores_(const std::map< double, double > &scores_to_FDR, PeptideIdentification &id, const std::string &score_type, bool higher_better, bool keep_decoy, int charge, const String &identifier)
Definition: IDScoreGetterSetter.h:436
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const std::string &score_type, bool higher_better, bool keep_decoy, const String &identifier)
Definition: IDScoreGetterSetter.h:451
static void setScores_(const std::map< double, double > &scores_to_FDR, PeptideIdentification &id, const std::string &score_type, bool higher_better, bool keep_decoy, int charge)
Definition: IDScoreGetterSetter.h:418
static void setScores_(const std::map< double, double > &scores_to_FDR, std::vector< IDType > &ids, const std::string &score_type, bool higher_better, Args &... args)
Definition: IDScoreGetterSetter.h:340
static void setScore_(const std::map< double, double > &scores_to_FDR, HitType &hit, const std::string &old_score_type)
Definition: IDScoreGetterSetter.h:404
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const std::string &score_type, bool higher_better)
Definition: IDScoreGetterSetter.h:411
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const std::string &score_type, bool higher_better, bool keep_decoy)
Definition: IDScoreGetterSetter.h:363
static void setScores_(const std::map< double, double > &scores_to_FDR, PeptideIdentification &id, const std::string &score_type, bool higher_better, int charge, const String &identifier)
Definition: IDScoreGetterSetter.h:460
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const String &old_score_type)
Definition: IDScoreGetterSetter.h:379
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const std::string &score_type, bool higher_better, const String &identifier)
Definition: IDScoreGetterSetter.h:474
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Definition: IDScoreGetterSetter.h:77
static bool const value
Definition: IDScoreGetterSetter.h:78
Definition: IDScoreGetterSetter.h:70
static bool const value
Definition: IDScoreGetterSetter.h:71
Definition: IDScoreGetterSetter.h:55
std::vector< std::pair< double, double > > Base
Definition: IDScoreGetterSetter.h:56