OpenMS
Loading...
Searching...
No Matches
ChargePair.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: Chris Bielow $
6// $Authors: $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14#include <OpenMS/OpenMSConfig.h>
15
16#include <functional>
17#include <iosfwd>
18#include <vector>
19
20namespace OpenMS
21{
22
33 class OPENMS_DLLAPI ChargePair
34 {
35
36public:
38
39
41
43 ChargePair(const Size& index0,
44 const Size& index1,
45 const Int& charge0,
46 const Int& charge1,
47 const Compomer& compomer,
48 const double& mass_diff,
49 const bool active);
50
53
56
58 virtual ~ChargePair() = default;
59
61
62 //@name Accessors
64
65 Int getCharge(UInt pairID) const;
66
68 void setCharge(UInt pairID, Int e);
69
71 Size getElementIndex(UInt pairID) const;
72
74 void setElementIndex(UInt pairID, Size e);
75
77 const Compomer& getCompomer() const;
78
80 void setCompomer(const Compomer& compomer);
81
83 double getMassDiff() const;
84
86 void setMassDiff(double mass_diff);
87
89 double getEdgeScore() const;
90
92 void setEdgeScore(double score);
93
95 bool isActive() const;
96
97 void setActive(const bool active);
98
100 Int getMolMultiplier(UInt pairID) const;
101
103 void setMolMultiplier(UInt pairID, Int m);
104
106
108 virtual bool operator==(const ChargePair& i) const;
109
111 virtual bool operator!=(const ChargePair& i) const;
112
113protected:
114
128 double score_;
135 };
136
138 OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const ChargePair& cons);
139
140} // namespace OpenMS
141
142// Hash function specialization for ChargePair
143// Note: Only hash fields used in operator== (feature0_index_, feature1_index_,
144// feature0_charge_, feature1_charge_, compomer_, mass_diff_, is_active_,
145// feature0_mol_multiplier_, feature1_mol_multiplier_)
146// Do NOT hash score_ as it is not compared in operator==
147namespace std
148{
149 template<>
150 struct hash<OpenMS::ChargePair>
151 {
152 std::size_t operator()(const OpenMS::ChargePair& cp) const noexcept
153 {
154 std::size_t seed = OpenMS::hash_int(cp.getElementIndex(0));
155 OpenMS::hash_combine(seed, OpenMS::hash_int(cp.getElementIndex(1)));
156 OpenMS::hash_combine(seed, OpenMS::hash_int(cp.getCharge(0)));
157 OpenMS::hash_combine(seed, OpenMS::hash_int(cp.getCharge(1)));
158 OpenMS::hash_combine(seed, std::hash<OpenMS::Compomer>{}(cp.getCompomer()));
159 OpenMS::hash_combine(seed, OpenMS::hash_float(cp.getMassDiff()));
160 OpenMS::hash_combine(seed, OpenMS::hash_int(static_cast<int>(cp.isActive())));
161 OpenMS::hash_combine(seed, OpenMS::hash_int(cp.getMolMultiplier(0)));
162 OpenMS::hash_combine(seed, OpenMS::hash_int(cp.getMolMultiplier(1)));
163 return seed;
164 }
165 };
166} // namespace std
167
Representation of a (putative) link between two Features, which stem from the same compound but have ...
Definition ChargePair.h:34
double mass_diff_
mass difference (after explanation by compomer)
Definition ChargePair.h:126
virtual bool operator==(const ChargePair &i) const
Equality operator.
Int getCharge(UInt pairID) const
Returns the charge (for element 0 or 1)
bool isActive() const
is this pair realized?
void setCompomer(const Compomer &compomer)
Set the compomer id.
void setMassDiff(double mass_diff)
Sets the mass difference.
double getMassDiff() const
Returns the mass difference.
ChargePair(const ChargePair &rhs)
Copy constructor.
ChargePair()
Default constructor.
virtual ~ChargePair()=default
Destructor.
void setMolMultiplier(UInt pairID, Int m)
Set the molecular multiplier (for element 0 or 1). 1=monomer, 2=dimer, etc.
Size getElementIndex(UInt pairID) const
Returns the element index (for element 0 or 1)
Size feature1_index_
Int of the second element within the FeatureMap.
Definition ChargePair.h:118
bool is_active_
was this pair realized by ILP?
Definition ChargePair.h:130
Size feature0_index_
Int of the first element within the FeatureMap.
Definition ChargePair.h:116
void setActive(const bool active)
ChargePair & operator=(const ChargePair &rhs)
Assignment operator.
Compomer compomer_
Compomer that explains the mass difference.
Definition ChargePair.h:124
ChargePair(const Size &index0, const Size &index1, const Int &charge0, const Int &charge1, const Compomer &compomer, const double &mass_diff, const bool active)
Constructor from map index, element index and Feature.
Int getMolMultiplier(UInt pairID) const
Returns the molecular multiplier (for element 0 or 1). Default is 1 (monomer).
void setCharge(UInt pairID, Int e)
Set the charge (for element 0 or 1)
Int feature0_mol_multiplier_
Molecular multiplier for first feature (1=monomer, 2=dimer, etc.)
Definition ChargePair.h:132
virtual bool operator!=(const ChargePair &i) const
Equality operator.
void setElementIndex(UInt pairID, Size e)
Set the element index (for element 0 or 1)
Int feature0_charge_
Assumed charge of the first feature.
Definition ChargePair.h:120
double getEdgeScore() const
Returns the ILP edge score.
void setEdgeScore(double score)
Sets the ILP edge score.
Int feature1_charge_
Assumed charge of the second feature.
Definition ChargePair.h:122
double score_
Score of this edge used in ILP.
Definition ChargePair.h:128
const Compomer & getCompomer() const
Returns the Id of the compomer that explains the mass difference.
Int feature1_mol_multiplier_
Molecular multiplier for second feature.
Definition ChargePair.h:134
Holds information on an edge connecting two features from a (putative) charge ladder.
Definition Compomer.h:51
int Int
Signed integer type.
Definition Types.h:72
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
std::size_t hash_int(T value) noexcept
Hash for an integer type.
Definition HashUtils.h:107
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
STL namespace.
std::size_t operator()(const OpenMS::ChargePair &cp) const noexcept
Definition ChargePair.h:152