Molassembler  3.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"
15 #include "Molassembler/Types.h"
16 #include <vector>
17 
18 namespace Scine {
19 namespace Molassembler {
20 
21 // Forward-declarations
22 class StereopermutatorList;
23 class PrivateGraph;
24 
28 namespace Hashes {
29 
30 using WideHashType = boost::multiprecision::uint128_t;
31 using HashType = std::uint64_t;
32 
37  static constexpr unsigned bondTypeBits = 3;
38  static constexpr unsigned assignmentBits = 3;
39  /* - 3 bits for bondtype + none
40  * - 3 bits for the assignment (none, unassigned, values)
41  */
42  static constexpr unsigned hashWidth = 6;
43 
44  BondType bondType;
45  bool stereopermutatorOnBond;
46  boost::optional<unsigned> assignmentOptional;
47 
49  BondType passBondType,
50  bool passStereopermutatorOnBond,
51  boost::optional<unsigned> passAssignmentOptional
52  );
53 
54  WideHashType hash() const;
55 
56  bool operator < (const BondInformation& other) const;
57  bool operator == (const BondInformation& other) const;
58 };
59 
70 WideHashType hash(
72  Utils::ElementType elementType,
73  const std::vector<BondInformation>& sortedBonds,
74  const boost::optional<Shapes::Shape>& shapeOptional,
75  const boost::optional<unsigned>& assignedOptional
76 );
77 
83 std::vector<BondInformation> gatherBonds(
84  const PrivateGraph& inner,
85  const StereopermutatorList& stereopermutators,
86  AtomEnvironmentComponents componentsBitmask,
87  AtomIndex i
88 );
89 
94 WideHashType atomEnvironment(
95  const PrivateGraph& inner,
96  boost::optional<const StereopermutatorList&> stereopermutators,
98  AtomIndex i
99 );
100 
105 std::vector<WideHashType> generate(
106  const PrivateGraph& inner,
107  boost::optional<const StereopermutatorList&> stereopermutatorsOption,
109 );
110 
115 bool identityCompare(
116  const PrivateGraph& aGraph,
117  const StereopermutatorList& aStereopermutators,
118  const PrivateGraph& bGraph,
119  const StereopermutatorList& bStereopermutators,
120  AtomEnvironmentComponents componentBitmask
121 );
122 
131 std::tuple<
132  std::vector<HashType>,
133  std::vector<HashType>,
134  HashType
135 > narrow(
136  const std::vector<WideHashType>& a,
137  const std::vector<WideHashType>& b
138 );
139 
147 std::pair<
148  std::vector<HashType>,
149  std::vector<HashType>
150 > generate(
151  const PrivateGraph& aGraph,
152  const StereopermutatorList& aStereopermutators,
153  const PrivateGraph& bGraph,
154  const StereopermutatorList& bStereopermutators,
156 );
157 
164  const std::vector<HashType>* const hashesPtr;
165 
166  using argument_type = AtomIndex;
167  using result_type = HashType;
168 
169  inline LookupFunctor(const std::vector<HashType>& hashes) : hashesPtr(&hashes) {}
170 
171  inline HashType operator() (const AtomIndex i) const {
172  return hashesPtr->at(i);
173  }
174 };
175 
176 } // namespace Hashes
177 } // namespace Molassembler
178 } // namespace Scine
179 
180 #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:36
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:163
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:26
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.