OpenMS  2.8.0
QCBase.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow, Tom Waschischeck $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
40 
41 #include <map>
42 
43 namespace OpenMS
44 {
45  class MSExperiment;
46  class ConsensusMap;
47 
54  class OPENMS_DLLAPI QCBase
55  {
56  public:
60  enum class Requires
61  : UInt64 // 64 bit unsigned type for bitwise and/or operations (see below)
62  {
63  NOTHING, //< default, does not require anything
64  RAWMZML, //< mzML file is required
65  POSTFDRFEAT, //< Features with FDR-filtered pepIDs
66  PREFDRFEAT, //< Features with unfiltered pepIDs
67  CONTAMINANTS, //< Contaminant Database
68  TRAFOALIGN, //< transformationXMLs for RT-alignment
69  ID, //< idXML with protein IDs
70  SIZE_OF_REQUIRES
71  };
73  static const std::string names_of_requires[];
74 
75  enum class ToleranceUnit
76  {
77  AUTO,
78  PPM,
79  DA,
80  SIZE_OF_TOLERANCEUNIT
81  };
83  static const std::string names_of_toleranceUnit[];
84 
85 
89  class OPENMS_DLLAPI SpectraMap
90  {
91  public:
93  SpectraMap() = default;
94 
96  explicit SpectraMap(const MSExperiment& exp);
97 
99  ~SpectraMap() = default;
100 
102  void calculateMap(const MSExperiment& exp);
103 
106  UInt64 at(const String& identifier) const;
107 
109  void clear();
110 
112  bool empty() const;
113 
115  Size size() const;
116 
117  private:
118  std::map<String, UInt64> nativeid_to_index_; //< nativeID to index
119  };
120 
122 
123 
127  virtual const String& getName() const = 0;
128 
132  virtual Status requires() const = 0;
133 
134 
137  bool isRunnable(const Status& s) const;
138 
140  static bool isLabeledExperiment(const ConsensusMap& cm);
141 
143  template <typename MAP>
144  static bool hasPepID(const MAP& fmap)
145  {
146  if (!fmap.getUnassignedPeptideIdentifications().empty()) return true;
147 
148  for (const auto& features : fmap)
149  {
150  if (!features.getPeptideIdentifications().empty()) return true;
151  }
152  return false;
153  }
154  };
155 }
A container for consensus elements.
Definition: ConsensusMap.h:90
Stores and handles combinations of enum values, e.g. a set of flags as bits flipped in an UInt64.
Definition: FlagSet.h:54
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:73
Map to find a spectrum via its NativeID.
Definition: QCBase.h:90
std::map< String, UInt64 > nativeid_to_index_
Definition: QCBase.h:118
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:55
static bool hasPepID(const MAP &fmap)
does the container have a PeptideIdentification in its members or as unassignedPepID ?
Definition: QCBase.h:144
virtual Status requires() 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:62
virtual const String & getName() const =0
Returns the name of the metric.
ToleranceUnit
Definition: QCBase.h:76
A more convenient string class.
Definition: String.h:60
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47