OpenMS
QCBase.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: Chris Bielow $
6 // $Authors: Chris Bielow, Tom Waschischeck $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/CONCEPT/Types.h>
14 #include <algorithm>
15 #include <map>
16 
17 namespace OpenMS
18 {
19  class MSExperiment;
20  class ConsensusMap;
21 
28  class OPENMS_DLLAPI QCBase
29  {
30  public:
34  enum class Requires : UInt64 // 64 bit unsigned type for bitwise and/or operations (see below)
35  {
36  NOTHING, //< default, does not require anything
37  RAWMZML, //< mzML file is required
38  POSTFDRFEAT, //< Features with FDR-filtered pepIDs
39  PREFDRFEAT, //< Features with unfiltered pepIDs
40  CONTAMINANTS, //< Contaminant Database
41  TRAFOALIGN, //< transformationXMLs for RT-alignment
42  ID, //< idXML with protein IDs
43  SIZE_OF_REQUIRES
44  };
46  static const std::string names_of_requires[];
47 
48  enum class ToleranceUnit
49  {
50  AUTO,
51  PPM,
52  DA,
53  SIZE_OF_TOLERANCEUNIT
54  };
56  static const std::string names_of_toleranceUnit[];
57 
58 
62  class OPENMS_DLLAPI SpectraMap
63  {
64  public:
66  SpectraMap() = default;
67 
69  explicit SpectraMap(const MSExperiment& exp);
70 
72  ~SpectraMap() = default;
73 
75  void calculateMap(const MSExperiment& exp);
76 
79  UInt64 at(const String& identifier) const;
80 
82  void clear();
83 
85  bool empty() const;
86 
88  Size size() const;
89 
90  private:
91  std::map<String, UInt64> nativeid_to_index_; //< nativeID to index
92  };
93 
95 
96 
100  virtual const String& getName() const = 0;
101 
105  virtual Status requirements() const = 0;
106 
107 
110  bool isRunnable(const Status& s) const;
111 
113  static bool isLabeledExperiment(const ConsensusMap& cm);
114 
116  template<typename MAP>
117  static bool hasPepID(const MAP& fmap)
118  {
119  if (!fmap.getUnassignedPeptideIdentifications().empty())
120  return true;
121 
122  return std::any_of(fmap.cbegin(), fmap.cend(), [](const auto& f) { return !f.getPeptideIdentifications().empty(); });
123  }
124  };
125 } // namespace OpenMS
A container for consensus elements.
Definition: ConsensusMap.h:66
Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64.
Definition: FlagSet.h:28
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
Map to find a spectrum via its NativeID.
Definition: QCBase.h:63
std::map< String, UInt64 > nativeid_to_index_
Definition: QCBase.h:91
bool empty() const
check if empty
SpectraMap(const MSExperiment &exp)
CTor which allows immediate indexing of an MSExperiment.
UInt64 at(const String &identifier) const
void calculateMap(const MSExperiment &exp)
calculate a new map, delete the old one
SpectraMap()=default
Constructor.
void clear()
clear the map
Size size() const
get size of map
~SpectraMap()=default
Destructor.
This class serves as an abstract base class for all QC classes.
Definition: QCBase.h:29
static bool hasPepID(const MAP &fmap)
does the container have a PeptideIdentification in its members or as unassignedPepID ?
Definition: QCBase.h:117
virtual Status requirements() const =0
Returns the input data requirements of the compute(...) function.
static bool isLabeledExperiment(const ConsensusMap &cm)
check if the IsobaricAnalyzer TOPP tool was used to create this ConsensusMap
bool isRunnable(const Status &s) const
Requires
Enum to encode a file type as a bit.
Definition: QCBase.h:35
virtual const String & getName() const =0
Returns the name of the metric.
ToleranceUnit
Definition: QCBase.h:49
A more convenient string class.
Definition: String.h:34
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:51
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22