OpenMS
Loading...
Searching...
No Matches
Scores Class Reference

Utility class for score type handling in identification and quantification workflows. More...

#include <OpenMS/ANALYSIS/ID/Scores.h>

Classes

struct  Maps_
 Holds the static score type lookup maps (thread-safe via C++11 function-local static) More...
 

Public Types

enum class  IDType {
  RAW , RAW_EVAL , PP , PEP ,
  FDR , QVAL
}
 Hierarchy of possible score types in MS identification. More...
 

Static Public Member Functions

static bool isScoreType (const String &score_name, IDType type)
 Checks if the given score name corresponds to a specific ID score type.
 
static IDType parseIDType (const String &score_type)
 Converts a string representation of an ID score type to an IDType enum.
 
static bool isHigherBetter (IDType type)
 Determines whether a higher score is better for the given ID score type.
 
static std::vector< StringgetAllIDScoreNames ()
 Gets a vector of all ID score names that are used in OpenMS.
 
static const std::set< String > & getIDNamesForType (IDType type)
 Gets the set of known names for a specific ID score type.
 
static bool findIDTypeByName (const String &name, IDType &type)
 Finds the ID score type for a given score name.
 
static String normalizeScoreName (const String &score_name)
 Normalizes a score name by removing the "_score" suffix if present.
 
static bool isKnownScoreType (const String &score_name)
 Checks if a score name is a known score type (after normalization).
 

Static Private Member Functions

static const Maps_getMaps_ ()
 Returns the singleton Maps_ instance (thread-safe initialization guaranteed by C++11)
 

Detailed Description

Utility class for score type handling in identification and quantification workflows.

This class provides centralized handling of score types used in peptide/protein identification, quantification, and PTM localization. It defines the hierarchy of score types and provides utility methods for score type conversion, comparison, and lookup.

The identification score type hierarchy is:

  • RAW: Raw search engine scores (e.g., XTandem hyperscore, Mascot score)
  • RAW_EVAL: E-value based scores (e.g., expect score)
  • PP: Posterior probability
  • PEP: Posterior error probability
  • FDR: False discovery rate
  • QVAL: Q-value

Class Documentation

◆ OpenMS::Scores::Maps_

struct OpenMS::Scores::Maps_

Holds the static score type lookup maps (thread-safe via C++11 function-local static)

Collaboration diagram for Scores::Maps_:
[legend]
Class Members
map< IDType, bool > type_to_better
map< IDType, set< String > > type_to_str

Member Enumeration Documentation

◆ IDType

enum class IDType
strong

Hierarchy of possible score types in MS identification.

In an ideal case, this should be reimplemented to follow ontology hierarchies as soon as e.g. MS-OBO is complete and we switched the Metavalues to CV terms.

Enumerator
RAW 

Raw score, e.g., search engine specific scores like hyperscore.

RAW_EVAL 

Raw score with E-value, e.g., search engine specific scores like expect score.

PP 

Posterior probability.

PEP 

Posterior error probability.

FDR 

False discovery rate.

QVAL 

Q-value.

Member Function Documentation

◆ findIDTypeByName()

static bool findIDTypeByName ( const String name,
IDType type 
)
static

Finds the ID score type for a given score name.

Searches through all known score names to find a matching type.

Parameters
[in]nameThe score name to look up.
[out]typeOutput parameter for the found score type.
Returns
True if a matching type was found, false otherwise.

◆ getAllIDScoreNames()

static std::vector< String > getAllIDScoreNames ( )
static

Gets a vector of all ID score names that are used in OpenMS.

Returns
A vector of all ID score names (e.g., "q-value", "ln(hyperscore)").

◆ getIDNamesForType()

static const std::set< String > & getIDNamesForType ( IDType  type)
static

Gets the set of known names for a specific ID score type.

Parameters
[in]typeThe ID score type.
Returns
A set of strings representing known names for this score type.

◆ getMaps_()

static const Maps_ & getMaps_ ( )
staticprivate

Returns the singleton Maps_ instance (thread-safe initialization guaranteed by C++11)

◆ isHigherBetter()

static bool isHigherBetter ( IDType  type)
static

Determines whether a higher score is better for the given ID score type.

Parameters
[in]typeThe ID score type to check.
Returns
True if a higher score is better, false otherwise.

◆ isKnownScoreType()

static bool isKnownScoreType ( const String score_name)
static

Checks if a score name is a known score type (after normalization).

This method normalizes the score name and checks if it matches any known score type in the registry. Unlike isScoreType(), this doesn't require specifying which IDType to check - it checks all of them.

Parameters
[in]score_nameThe score name to check.
Returns
True if the normalized name matches any known score type.

◆ isScoreType()

static bool isScoreType ( const String score_name,
IDType  type 
)
static

Checks if the given score name corresponds to a specific ID score type.

This method determines if a given score name, typically derived from an identification object or meta value, matches a specified IDType. It performs a case-insensitive comparison and optionally removes the "_score" suffix if present.

Parameters
[in]score_nameThe name of the score to check.
[in]typeThe IDType to compare against.
Returns
True if the score name matches the given IDType, false otherwise.

◆ normalizeScoreName()

static String normalizeScoreName ( const String score_name)
static

Normalizes a score name by removing the "_score" suffix if present.

This is useful when checking if a score name matches a known score type, as OpenMS conventions allow both "q-value" and "q-value_score" forms.

Parameters
[in]score_nameThe score name to normalize.
Returns
The normalized score name (without "_score" suffix).

◆ parseIDType()

static IDType parseIDType ( const String score_type)
static

Converts a string representation of an ID score type to an IDType enum.

This method attempts to map a given string, representing a score type, to the corresponding IDType enum value. It handles various common representations of score types, including those with or without the "_score" suffix, and ignores case and special characters like '-', '_', and ' '.

Parameters
[in]score_typeThe string representation of the score type.
Returns
The corresponding IDType enum value.
Exceptions
Exception::MissingInformationIf the provided score_type string does not match any known score type.