OpenMS  2.7.0
DataQuery.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: Hendrik Weisser $
32 // $Authors: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 
39 #include <boost/optional.hpp>
40 
41 namespace OpenMS
42 {
43  namespace IdentificationDataInternal
44  {
48  {
51 
52  // @TODO: make this non-optional (i.e. required)?
53  boost::optional<InputFileRef> input_file_opt;
54 
55  double rt, mz; // position
56 
57  explicit DataQuery(
58  const String& data_id,
59  boost::optional<InputFileRef> input_file_opt = boost::none,
60  double rt = std::numeric_limits<double>::quiet_NaN(),
61  double mz = std::numeric_limits<double>::quiet_NaN()):
63  {
64  }
65 
66  DataQuery(const DataQuery& other) = default;
67 
68  // ignore RT and m/z for comparisons to avoid issues with rounding:
69  bool operator<(const DataQuery& other) const
70  {
71  // can't compare references directly, so compare addresses:
72  const String* sp = input_file_opt ? &(**input_file_opt) : nullptr;
73  const String* o_sp = other.input_file_opt ? &(**other.input_file_opt) :
74  nullptr;
75  return std::tie(sp, data_id) < std::tie(o_sp, other.data_id);
76  }
77 
78  // ignore RT and m/z for comparisons to avoid issues with rounding:
79  bool operator==(const DataQuery& other) const
80  {
81  return std::tie(input_file_opt, data_id) ==
82  std::tie(other.input_file_opt, other.data_id);
83  }
84 
85  // @TODO: do we need an "experiment label" (used e.g. in pepXML)?
86  // if yes, should it be stored here or together with the input file?
87  };
88 
89  typedef std::set<DataQuery> DataQueries;
91 
92  }
93 }
Interface for classes that can store arbitrary meta information (Type-Name-Value tuples).
Definition: MetaInfoInterface.h:61
A more convenient string class.
Definition: String.h:61
std::set< DataQuery > DataQueries
Definition: DataQuery.h:89
IteratorWrapper< DataQueries::iterator > DataQueryRef
Definition: DataQuery.h:90
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Search query, e.g. spectrum or feature.
Definition: DataQuery.h:48
bool operator==(const DataQuery &other) const
Definition: DataQuery.h:79
boost::optional< InputFileRef > input_file_opt
Definition: DataQuery.h:53
DataQuery(const String &data_id, boost::optional< InputFileRef > input_file_opt=boost::none, double rt=std::numeric_limits< double >::quiet_NaN(), double mz=std::numeric_limits< double >::quiet_NaN())
Definition: DataQuery.h:57
double mz
Definition: DataQuery.h:55
String data_id
spectrum or feature ID (from the file referenced by "input_file_ref"):
Definition: DataQuery.h:50
bool operator<(const DataQuery &other) const
Definition: DataQuery.h:69
DataQuery(const DataQuery &other)=default
double rt
Definition: DataQuery.h:55