Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Scine::Molassembler::Hashes Namespace Reference

Classes and methods to compute hashes of atom environments. More...

Data Structures

struct  BondInformation
 Information pertinent to a singular bond hash. More...
 
struct  LookupFunctor
 A functor for getting an atom's hash from a captured list of hashes. More...
 

Typedefs

using WideHashType = boost::multiprecision::uint128_t
 
using HashType = std::uint64_t
 

Functions

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's element type and bonds into an unsigned integer. More...
 
std::vector< BondInformationgatherBonds (const PrivateGraph &inner, const StereopermutatorList &stereopermutators, AtomEnvironmentComponents componentsBitmask, AtomIndex i)
 Collects bond information for hash() input. More...
 
WideHashType atomEnvironment (const PrivateGraph &inner, boost::optional< const StereopermutatorList & > stereopermutators, AtomEnvironmentComponents bitmask, AtomIndex i)
 Calculate the hash for a particular atom index. More...
 
std::vector< WideHashType > generate (const PrivateGraph &inner, boost::optional< const StereopermutatorList & > stereopermutatorsOption, AtomEnvironmentComponents bitmask)
 Generates the hashes for every atom in a molecule's components. More...
 
bool identityCompare (const PrivateGraph &aGraph, const StereopermutatorList &aStereopermutators, const PrivateGraph &bGraph, const StereopermutatorList &bStereopermutators, AtomEnvironmentComponents componentBitmask)
 Compare two molecules with an identity index mapping. More...
 
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. More...
 
std::pair< std::vector
< HashType >, std::vector
< HashType >> 
generate (const PrivateGraph &aGraph, const StereopermutatorList &aStereopermutators, const PrivateGraph &bGraph, const StereopermutatorList &bStereopermutators, AtomEnvironmentComponents bitmask)
 Generates hashes for two molecules' components. More...
 

Detailed Description

Classes and methods to compute hashes of atom environments.

Function Documentation

WideHashType Scine::Molassembler::Hashes::atomEnvironment ( const PrivateGraph &  inner,
boost::optional< const StereopermutatorList & >  stereopermutators,
AtomEnvironmentComponents  bitmask,
AtomIndex  i 
)

Calculate the hash for a particular atom index.

Complexity \(\Theta(1)\)

std::vector<BondInformation> Scine::Molassembler::Hashes::gatherBonds ( const PrivateGraph &  inner,
const StereopermutatorList &  stereopermutators,
AtomEnvironmentComponents  componentsBitmask,
AtomIndex  i 
)

Collects bond information for hash() input.

Complexity \(\Theta(1)\) since the out-degree of atoms is considered a fixed small number because molecules are sparse.

std::vector<WideHashType> Scine::Molassembler::Hashes::generate ( const PrivateGraph &  inner,
boost::optional< const StereopermutatorList & >  stereopermutatorsOption,
AtomEnvironmentComponents  bitmask 
)

Generates the hashes for every atom in a molecule's components.

Complexity \(\Theta(N)\)

std::pair< std::vector<HashType>, std::vector<HashType>> Scine::Molassembler::Hashes::generate ( const PrivateGraph &  aGraph,
const StereopermutatorList &  aStereopermutators,
const PrivateGraph &  bGraph,
const StereopermutatorList &  bStereopermutators,
AtomEnvironmentComponents  bitmask 
)

Generates hashes for two molecules' components.

Generate hashes for two molecules. Basis for comparing vertices in an isomorphism algorithm.

Complexity \(\Theta(N)\)

WideHashType Scine::Molassembler::Hashes::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's element type and bonds into an unsigned integer.

At current, this is a bijective mapping and has zero probability of collisions.

Complexity \(\Theta(1)\)

bool Scine::Molassembler::Hashes::identityCompare ( const PrivateGraph &  aGraph,
const StereopermutatorList &  aStereopermutators,
const PrivateGraph &  bGraph,
const StereopermutatorList &  bStereopermutators,
AtomEnvironmentComponents  componentBitmask 
)

Compare two molecules with an identity index mapping.

Complexity \(O(N)\)

std::tuple< std::vector<HashType>, std::vector<HashType>, HashType> Scine::Molassembler::Hashes::narrow ( const std::vector< WideHashType > &  a,
const std::vector< WideHashType > &  b 
)

Re-enumerates the hashes in two generated hash lists.

Although the hash space requires a wide integer type, the number of different atom environments in molecules will not require a wide integer type. We can therefore remap the wide hashes to an enumerated smaller integer type.

Complexity \(\Theta(N)\)