OpenMS
Loading...
Searching...
No Matches
ScoreType.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
14
15#include <set>
16#include <string>
17#include <tuple>
18
19namespace OpenMS
20{
21 namespace IdentificationDataInternal
22 {
26 {
27 CVTerm cv_term; // @TODO: derive from CVTerm instead?
28
30
32 higher_better(true)
33 {
34 }
35
40
41 explicit ScoreType(const std::string& name, bool higher_better):
43 {
44 cv_term.setName(name);
45 }
46
47 ScoreType(const ScoreType& other) = default;
48
49 // don't include "higher_better" in the comparison:
50 bool operator<(const ScoreType& other) const
51 {
52 // @TODO: implement/use "CVTerm::operator<"?
53 return (std::tie(cv_term.getAccession(), cv_term.getName()) <
54 std::tie(other.cv_term.getAccession(),
55 other.cv_term.getName()));
56 }
57
58 // don't include "higher_better" in the comparison:
59 bool operator==(const ScoreType& other) const
60 {
61 return cv_term == other.cv_term;
62 }
63
64 bool isBetterScore(double first, double second) const
65 {
66 if (higher_better) return first > second;
67 return first < second;
68 }
69 };
70
71 typedef std::set<ScoreType> ScoreTypes;
73 }
74}
Representation of controlled vocabulary term.
Definition CVTerm.h:28
const std::string & getName() const
returns the name of the term
void setName(const std::string &name)
sets the name of the term
const std::string & getAccession() const
returns the accession string of the term
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition MetaInfoInterface.h:35
OpenMS looks in the< code > OPENMS_THERMO_MANAGED_DIR</code > environment variable first
Definition common-cmake-parameters.doxygen:179
std::set< ScoreType > ScoreTypes
Definition ScoreType.h:71
IteratorWrapper< ScoreTypes::iterator > ScoreTypeRef
Definition ScoreType.h:72
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
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:26
ScoreType(const ScoreType &other)=default
CVTerm cv_term
Definition ScoreType.h:27
bool operator==(const ScoreType &other) const
Definition ScoreType.h:59
bool isBetterScore(double first, double second) const
Definition ScoreType.h:64
ScoreType(const CVTerm &cv_term, bool higher_better)
Definition ScoreType.h:36
bool higher_better
Definition ScoreType.h:29
bool operator<(const ScoreType &other) const
Definition ScoreType.h:50
ScoreType(const std::string &name, bool higher_better)
Definition ScoreType.h:41