Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AtomEnvironmentHash.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_ATOM_ENVIRONMENT_HASH_H
9 #define INCLUDE_MOLASSEMBLER_ATOM_ENVIRONMENT_HASH_H
10 
11 #include "boost/multiprecision/cpp_int.hpp"
12 #include "boost/optional.hpp"
14 
16 
17 #include "Molassembler/Types.h"
18 
19 #include <vector>
20 
21 namespace Scine {
22 namespace Molassembler {
23 
24 // Forward-declarations
25 class StereopermutatorList;
26 class PrivateGraph;
27 
31 namespace Hashes {
32 
33 using WideHashType = boost::multiprecision::uint128_t;
34 using HashType = std::uint64_t;
35 
40  static constexpr unsigned bondTypeBits = 3;
41  static constexpr unsigned assignmentBits = 3;
42  /* - 3 bits for bondtype + none
43  * - 3 bits for the assignment (none, unassigned, values)
44  */
45  static constexpr unsigned hashWidth = 6;
46 
47  BondType bondType;
48  bool stereopermutatorOnBond;
49  boost::optional<unsigned> assignmentOptional;
50 
52  BondType passBondType,
53  bool passStereopermutatorOnBond,
54  boost::optional<unsigned> passAssignmentOptional
55  );
56 
57  WideHashType hash() const;
58 
59  bool operator < (const BondInformation& other) const;
60  bool operator == (const BondInformation& other) const;
61 };
62 
73 WideHashType hash(
75  Utils::ElementType elementType,
76  const std::vector<BondInformation>& sortedBonds,
77  const boost::optional<Shapes::Shape>& shapeOptional,
78  const boost::optional<unsigned>& assignedOptional
79 );
80 
86 std::vector<BondInformation> gatherBonds(
87  const PrivateGraph& inner,
88  const StereopermutatorList& stereopermutators,
89  AtomEnvironmentComponents componentsBitmask,
90  AtomIndex i
91 );
92 
97 WideHashType atomEnvironment(
98  const PrivateGraph& inner,
99  boost::optional<const StereopermutatorList&> stereopermutators,
101  AtomIndex i
102 );
103 
108 std::vector<WideHashType> generate(
109  const PrivateGraph& inner,
110  boost::optional<const StereopermutatorList&> stereopermutatorsOption,
112 );
113 
118 bool identityCompare(
119  const PrivateGraph& aGraph,
120  const StereopermutatorList& aStereopermutators,
121  const PrivateGraph& bGraph,
122  const StereopermutatorList& bStereopermutators,
123  AtomEnvironmentComponents componentBitmask
124 );
125 
134 std::tuple<
135  std::vector<HashType>,
136  std::vector<HashType>,
137  HashType
138 > narrow(
139  const std::vector<WideHashType>& a,
140  const std::vector<WideHashType>& b
141 );
142 
150 std::pair<
151  std::vector<HashType>,
152  std::vector<HashType>
153 > generate(
154  const PrivateGraph& aGraph,
155  const StereopermutatorList& aStereopermutators,
156  const PrivateGraph& bGraph,
157  const StereopermutatorList& bStereopermutators,
159 );
160 
167  const std::vector<HashType>* const hashesPtr;
168 
169  using argument_type = AtomIndex;
170  using result_type = HashType;
171 
172  inline LookupFunctor(const std::vector<HashType>& hashes) : hashesPtr(&hashes) {}
173 
174  inline HashType operator() (const AtomIndex i) const {
175  return hashesPtr->at(i);
176  }
177 };
178 
179 } // namespace Hashes
180 } // namespace Molassembler
181 } // namespace Scine
182 
183 #endif
Defines basic types widely shared across the project.
std::tuple< std::vector< HashType >, std::vector< HashType >, HashType > narrow(const std::vector< WideHashType > &a, const std::vector< WideHashType > &b)
Re-enumerates the hashes in two generated hash lists.
std::vector< BondInformation > gatherBonds(const PrivateGraph &inner, const StereopermutatorList &stereopermutators, AtomEnvironmentComponents componentsBitmask, AtomIndex i)
Collects bond information for hash() input.
Information pertinent to a singular bond hash.
Definition: AtomEnvironmentHash.h:39
std::vector< WideHashType > generate(const PrivateGraph &inner, boost::optional< const StereopermutatorList & > stereopermutatorsOption, AtomEnvironmentComponents bitmask)
Generates the hashes for every atom in a molecule&#39;s components.
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
A functor for getting an atom&#39;s hash from a captured list of hashes.
Definition: AtomEnvironmentHash.h:166
Manages all stereopermutators that are part of a Molecule.
Definition: StereopermutatorList.h:30
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
Library internal graph class wrapping BGL types.
Definition: PrivateGraph.h:24
BondType
Discrete bond type numeration.
Definition: Types.h:26
WideHashType hash(AtomEnvironmentComponents bitmask, Utils::ElementType elementType, const std::vector< BondInformation > &sortedBonds, const boost::optional< Shapes::Shape > &shapeOptional, const boost::optional< unsigned > &assignedOptional)
Convolutes the atom&#39;s element type and bonds into an unsigned integer.
Defines symmetry names and total count.
bool identityCompare(const PrivateGraph &aGraph, const StereopermutatorList &aStereopermutators, const PrivateGraph &bGraph, const StereopermutatorList &bStereopermutators, AtomEnvironmentComponents componentBitmask)
Compare two molecules with an identity index mapping.
WideHashType atomEnvironment(const PrivateGraph &inner, boost::optional< const StereopermutatorList & > stereopermutators, AtomEnvironmentComponents bitmask, AtomIndex i)
Calculate the hash for a particular atom index.