 |
OpenMS
3.0.0
|
|
Go to the documentation of this file.
44 #include <unordered_set>
45 #include <unordered_map>
56 :
public std::vector<ScoreToTgtDecLabelPair>
58 typedef std::vector<ScoreToTgtDecLabelPair>
Base;
74 std::is_same<T, PeptideIdentification>::value || std::is_same<T, ProteinIdentification>::value;
80 static bool const value = std::is_same<T, PeptideHit>::value || std::is_same<T, ProteinHit>::value;
93 std::unordered_map<String, ScoreToTgtDecLabelPair>& picked_scores,
95 const String& decoy_string,
107 const std::unordered_map<String, ScoreToTgtDecLabelPair>& picked_scores,
109 const std::vector<ProteinIdentification::ProteinGroup>& grps,
110 const String& decoy_string,
130 const std::vector<ProteinIdentification::ProteinGroup> &grps,
131 const std::unordered_set<std::string> &decoy_accs);
134 template<
class ...Args>
137 const std::vector<PeptideIdentification> &ids,
142 getScores_(scores_labels,
id, std::forward<Args>(args)...);
150 scores_labels.reserve(scores_labels.size() +
id.getHits().size());
151 std::transform(
id.getHits().begin(),
id.getHits().end(),
152 std::back_inserter(scores_labels),
161 template<
class ...Args>
173 getScores_(scores_labels, hit, std::forward<Args>(args)...);
181 getScores_(scores_labels, hit, std::forward<Args>(args)...);
185 template<
typename IDPredicate,
class ...Args>
200 getScores_(scores_labels, hit, std::forward<Args>(args)...);
208 getScores_(scores_labels, hit, std::forward<Args>(args)...);
213 template<
typename HitPredicate>
225 template<typename HitType, typename std::enable_if<IsHitType<HitType>::value>::type * =
nullptr>
231 scores_labels.emplace_back(hit.getScore(),
getTDLabel_(hit));
241 template<
class ...Args>
244 const ConsensusMap &cmap,
bool include_unassigned_peptides,
Args &&... args)
248 {
getScores_(scores_labels,
id, std::forward<Args>(args)...); };
259 return std::string(idOrHit.
getMetaValue(
"target_decoy"))[0] ==
't';
273 template<
typename IDType,
class ...Args>
274 static void setScores_(
const std::map<double, double> &scores_to_FDR,
275 std::vector<IDType> &ids,
276 const std::string &score_type,
282 setScores_(scores_to_FDR,
id, score_type, higher_better, std::forward<Args>(args)...);
286 template<
typename IDType>
290 String old_score_type =
id.getScoreType() +
"_score";
291 id.setScoreType(score_type);
292 id.setHigherScoreBetter(higher_better);
293 return old_score_type;
296 template<
typename IDType>
297 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
298 bool higher_better,
bool keep_decoy)
300 bool old_higher_better =
id.isHigherScoreBetter();
305 if (old_higher_better)
307 setScores_(scores_to_FDR,
id, old_score_type);
316 if (old_higher_better)
327 template<
typename IDType>
328 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
329 const String &old_score_type)
331 std::vector<typename IDType::HitType> &hits =
id.getHits();
332 for (
auto &hit : hits)
334 setScore_(scores_to_FDR, hit, old_score_type);
338 template<
typename IDType>
340 const String &old_score_type)
342 std::vector<typename IDType::HitType> &hits =
id.getHits();
343 for (
auto &hit : hits)
349 template<
typename IDType,
class ...Args>
351 const String &old_score_type,
Args&& ... args)
353 std::vector<typename IDType::HitType> &hits =
id.getHits();
354 std::vector<typename IDType::HitType> new_hits;
355 new_hits.reserve(hits.size());
356 for (
auto &hit : hits)
363 template<
typename IDType,
class ...Args>
365 const String &old_score_type,
Args&& ... args)
367 std::vector<typename IDType::HitType> &hits =
id.getHits();
368 std::vector<typename IDType::HitType> new_hits;
369 new_hits.reserve(hits.size());
370 for (
auto &hit : hits)
377 template<
typename HitType>
378 static void setScore_(
const std::map<double, double> &scores_to_FDR, HitType &hit,
const std::string &old_score_type)
380 hit.setMetaValue(old_score_type, hit.getScore());
381 hit.setScore(scores_to_FDR.lower_bound(hit.getScore())->second);
384 template<
typename HitType>
385 static void setScoreHigherWorse_(
const std::map<double, double> &scores_to_FDR, HitType &hit,
const std::string &old_score_type)
387 hit.setMetaValue(old_score_type, hit.getScore());
388 auto ub = scores_to_FDR.upper_bound(hit.getScore());
389 if (ub != scores_to_FDR.begin()) ub--;
390 hit.setScore(ub->second);
402 static void setScores_(
const std::map<double, double> &scores_to_FDR,
404 const std::string &score_type,
412 setScores_(scores_to_FDR,
id, old_score_type, higher_better, charge);
416 setScoresAndRemoveDecoys_<PeptideIdentification>(scores_to_FDR,
id, old_score_type, charge);
420 static void setScores_(
const std::map<double, double> &scores_to_FDR,
422 const std::string &score_type,
428 if (
id.getIdentifier() == identifier)
430 setScores_(scores_to_FDR,
id, score_type, higher_better, keep_decoy, charge);
434 template<
typename IDType>
435 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
436 bool higher_better,
bool keep_decoy,
const String &identifier)
438 if (
id.getIdentifier() == identifier)
440 setScores_(scores_to_FDR,
id, score_type, higher_better, keep_decoy);
444 static void setScores_(
const std::map<double, double> &scores_to_FDR,
446 const std::string &score_type,
451 if (
id.getIdentifier() == identifier)
453 setScores_(scores_to_FDR,
id, score_type, higher_better, charge);
457 template<
typename IDType>
458 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
459 bool higher_better,
const String &identifier)
461 if (
id.getIdentifier() == identifier)
463 setScores_(scores_to_FDR,
id, score_type, higher_better);
467 template<
typename IDType>
468 static void setScores_(
const std::map<double, double> &scores_to_FDR, IDType &
id,
const std::string &score_type,
469 bool higher_better,
int charge)
471 for (
auto& hit :
id.getHits())
473 if (hit.getCharge() == charge)
477 setScore_(scores_to_FDR, hit, score_type);
489 const std::map<double, double> &scores_to_FDR,
490 std::vector<ProteinIdentification::ProteinGroup> &grps,
491 const std::string &score_type,
504 template<
typename HitType>
507 const std::string &old_score_type,
508 std::vector<HitType> &new_hits)
510 const String &target_decoy(hit.getMetaValue(
"target_decoy"));
511 if (target_decoy[0] ==
't')
513 hit.setMetaValue(old_score_type, hit.getScore());
514 hit.setScore(scores_to_FDR.lower_bound(hit.getScore())->second);
515 new_hits.push_back(std::move(hit));
519 template<
typename HitType>
522 const std::string &old_score_type,
523 std::vector<HitType> &new_hits)
525 const String &target_decoy(hit.getMetaValue(
"target_decoy"));
526 if (target_decoy[0] ==
't')
528 hit.setMetaValue(old_score_type, hit.getScore());
529 auto ub = scores_to_FDR.upper_bound(hit.getScore());
530 if (ub != scores_to_FDR.begin()) ub--;
531 hit.setScore(ub->second);
532 new_hits.push_back(std::move(hit));
547 const std::string &old_score_type,
548 std::vector<PeptideHit> &new_hits,
554 if (target_decoy[0] ==
't')
558 new_hits.push_back(std::move(hit));
563 new_hits.push_back(std::move(hit));
577 template<
class ...Args>
580 bool include_unassigned_peptides,
581 const std::string &score_type,
590 higher_better, keep_decoy, std::forward<Args>(args)...); };
605 OPENMS_PRETTY_FUNCTION,
606 "Meta value 'target_decoy' does not exist in all ProteinHits! Reindex the idXML file with 'PeptideIndexer'");
static void setScoresHigherWorse_(const std::map< double, double > &scores_to_FDR, IDType &id, const String &old_score_type)
Definition: IDScoreGetterSetter.h:339
Int getCharge() const
returns the charge of the peptide
Base class for TOPP applications.
Definition: TOPPBase.h:147
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:444
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const HitType &hit)
Definition: IDScoreGetterSetter.h:226
void store(const String &filename, const std::vector< ProteinIdentification > &protein_ids, const std::vector< PeptideIdentification > &peptide_ids, const String &document_id="")
Stores the data in an idXML file.
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const std::vector< PeptideIdentification > &ids, Args &&... args)
Definition: IDScoreGetterSetter.h:135
static void getPickedProteinScores_(std::unordered_map< String, ScoreToTgtDecLabelPair > &picked_scores, const ProteinIdentification &id, const String &decoy_string, bool decoy_prefix)
Fills the scores_labels vector from an ProteinIdentification id for picked protein FDR....
static void getPickedProteinGroupScores_(const std::unordered_map< String, ScoreToTgtDecLabelPair > &picked_scores, ScoreToTgtDecLabelPairs &scores_labels, const std::vector< ProteinIdentification::ProteinGroup > &grps, const String &decoy_string, bool decoy_prefix)
Fills the scores_labels vector from a vector of ProteinGroups grps for picked protein group FDR.
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideHit &hit, HitPredicate &&fun)
Definition: IDScoreGetterSetter.h:214
A more convenient string class.
Definition: String.h:58
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:545
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:505
static const bool value
Definition: IDScoreGetterSetter.h:73
Representation of a protein hit.
Definition: ProteinHit.h:58
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, IDPredicate &&fun, bool all_hits, Args &&... args)
Definition: IDScoreGetterSetter.h:186
Representation of a protein identification run.
Definition: ProteinIdentification.h:70
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, Args &&... args)
Helper for applying set Scores on ConsensusMaps.
Definition: IDScoreGetterSetter.h:578
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:297
void load(const String &filename, std::vector< ProteinIdentification > &protein_ids, std::vector< PeptideIdentification > &peptide_ids)
Loads the identifications of an idXML file without identifier.
static void setScoreHigherWorseAndMoveIfTarget_(const std::map< double, double > &scores_to_FDR, HitType &hit, const std::string &old_score_type, std::vector< HitType > &new_hits)
Definition: IDScoreGetterSetter.h:520
static void setScoresHigherWorseAndRemoveDecoys_(const std::map< double, double > &scores_to_FDR, IDType &id, const String &old_score_type, Args &&... args)
Definition: IDScoreGetterSetter.h:364
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
A class for extracting and reinserting IDScores from Peptide/ProteinIdentifications and from Consensu...
Definition: IDScoreGetterSetter.h:65
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const ProteinIdentification &id)
Definition: IDScoreGetterSetter.h:146
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:420
void applyFunctionOnPeptideIDs(T &&f, bool include_unassigned=true)
applies a function on all PeptideIDs or only assigned ones
Definition: MapUtilities.h:68
static void setScoresAndRemoveDecoys_(const std::map< double, double > &scores_to_FDR, IDType &id, const String &old_score_type, Args &&... args)
Definition: IDScoreGetterSetter.h:350
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const PeptideIdentification &id, bool all_hits, Args &&... args)
Definition: IDScoreGetterSetter.h:162
A container for consensus elements.
Definition: ConsensusMap.h:82
static void getPeptideScoresFromMap_(ScoreToTgtDecLabelPairs &scores_labels, const ConsensusMap &cmap, bool include_unassigned_peptides, Args &&... args)
Helper for getting scores in ConsensusMaps.
Definition: IDScoreGetterSetter.h:242
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const String &old_score_type)
Definition: IDScoreGetterSetter.h:328
static void setScores_(const std::map< double, double > &scores_to_FDR, IDType &id, const std::string &score_type, bool higher_better, int charge)
Definition: IDScoreGetterSetter.h:468
static const bool value
Definition: IDScoreGetterSetter.h:80
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
Definition: IDScoreGetterSetter.h:71
std::vector< ScoreToTgtDecLabelPair > Base
Definition: IDScoreGetterSetter.h:58
static String setScoreType_(IDType &id, const std::string &score_type, bool higher_better)
Definition: IDScoreGetterSetter.h:287
std::pair< double, double > ScoreToTgtDecLabelPair
Definition: IDScoreGetterSetter.h:53
#define OPENMS_LOG_ERROR
Macro to be used if non-fatal error are reported (processing continues)
Definition: LogStream.h:455
Represents the peptide hits for a spectrum.
Definition: PeptideIdentification.h:63
Definition: IDScoreGetterSetter.h:78
double getScore() const
returns the PSM score
static void getScores_(ScoreToTgtDecLabelPairs &scores_labels, const std::vector< ProteinIdentification::ProteinGroup > &grps, const std::unordered_set< std::string > &decoy_accs)
Definition: IDScoreGetterSetter.h:55
static void setScoreHigherWorse_(const std::map< double, double > &scores_to_FDR, HitType &hit, const std::string &old_score_type)
Definition: IDScoreGetterSetter.h:385
static std::pair< bool, String > removeDecoyStringIfPresent_(const String &acc, const String &decoy_string, bool decoy_prefix)
removes the decoy_string from acc if present. Returns if string was removed and the new string.
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:435
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:274
static void setScore_(const std::map< double, double > &scores_to_FDR, HitType &hit, const std::string &old_score_type)
Definition: IDScoreGetterSetter.h:378
double getScore() const
returns the score of the protein hit
custom arguments to allow for looping calls
Definition: WizardHelper.h:72
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:458
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:402
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:257
static void checkTDAnnotation_(const MetaInfoInterface &id_or_hit)
To check the metavalues before we do anything.
Definition: IDScoreGetterSetter.h:599
Used to load and store idXML files.
Definition: IdXMLFile.h:68
void setScore(double score)
sets the PSM score
Representation of a peptide hit.
Definition: PeptideHit.h:55