OpenMS
ScoreType.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hendrik Weisser $
6 // $Authors: Hendrik Weisser $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 
13 namespace OpenMS
14 {
15  namespace IdentificationDataInternal
16  {
20  {
21  CVTerm cv_term; // @TODO: derive from CVTerm instead?
22 
24 
26  higher_better(true)
27  {
28  }
29 
30  explicit ScoreType(const CVTerm& cv_term, bool higher_better):
32  {
33  }
34 
35  explicit ScoreType(const String& name, bool higher_better):
37  {
38  cv_term.setName(name);
39  }
40 
41  ScoreType(const ScoreType& other) = default;
42 
43  // don't include "higher_better" in the comparison:
44  bool operator<(const ScoreType& other) const
45  {
46  // @TODO: implement/use "CVTerm::operator<"?
47  return (std::tie(cv_term.getAccession(), cv_term.getName()) <
48  std::tie(other.cv_term.getAccession(),
49  other.cv_term.getName()));
50  }
51 
52  // don't include "higher_better" in the comparison:
53  bool operator==(const ScoreType& other) const
54  {
55  return cv_term == other.cv_term;
56  }
57 
58  bool isBetterScore(double first, double second) const
59  {
60  if (higher_better) return first > second;
61  return first < second;
62  }
63  };
64 
65  typedef std::set<ScoreType> ScoreTypes;
67  }
68 }
Representation of controlled vocabulary term.
Definition: CVTerm.h:27
void setName(const String &name)
sets the name of the term
const String & getAccession() const
returns the accession string of the term
const String & getName() const
returns the name of the term
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:35
A more convenient string class.
Definition: String.h:34
std::set< ScoreType > ScoreTypes
Definition: ScoreType.h:65
IteratorWrapper< ScoreTypes::iterator > ScoreTypeRef
Definition: ScoreType.h:66
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Wrapper that adds operator< to iterators, so they can be used as (part of) keys in maps/sets or multi...
Definition: MetaData.h:20
Information about a score type.
Definition: ScoreType.h:20
ScoreType(const ScoreType &other)=default
CVTerm cv_term
Definition: ScoreType.h:21
ScoreType(const String &name, bool higher_better)
Definition: ScoreType.h:35
bool operator==(const ScoreType &other) const
Definition: ScoreType.h:53
bool isBetterScore(double first, double second) const
Definition: ScoreType.h:58
ScoreType(const CVTerm &cv_term, bool higher_better)
Definition: ScoreType.h:30
bool higher_better
Definition: ScoreType.h:23
bool operator<(const ScoreType &other) const
Definition: ScoreType.h:44