RDKit
Open-source cheminformatics and machine learning.
MolHash.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2014 Novartis Institutes for BioMedical Research
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #include <RDGeneral/export.h>
11 #pragma once
12 #include <map>
13 #include <vector>
14 #include <string>
15 #include <stdexcept>
16 #include <cstdint>
17 #include "../RDKitBase.h"
18 #include "nmmolhash.h"
19 
20 namespace RDKit {
21 namespace MolHash {
22 typedef std::uint32_t HashCodeType;
23 
24 // \deprecated This function will go away in a future release.
25 // please use the MolHash() function instead
27  const ROMol &mol, const std::vector<unsigned> *atomsToUse = 0,
28  const std::vector<unsigned> *bondsToUse =
29  0, // ?? listed bonds between/to/from excluded atom(s) ??
30  const std::vector<std::uint32_t> *atomCodes = 0,
31  const std::vector<std::uint32_t> *bondCodes = 0);
32 
33 enum CodeFlags // bitwise flags to combine and compute atom/bond codes
34 { CF_NO_LABELS = 0x0000,
35  CF_ELEMENT = 0x0001,
36  CF_CHARGE = 0x0002,
37  CF_VALENCE = 0x0004,
38  CF_ISOTOPE = 0x0008,
40  CF_ATOM_AROMATIC = 0x0020,
41  CF_ATOM_ALL = 0x00FF,
43  0x0100, // ignore AROMATIZATION if corresponding flag is not specified
46  CF_BOND_ORDER | CF_BOND_AROMATIZATION, // exact type value with aromatic
48  0x0400, // include bond chirality information into bond code
49  CF_BOND_IN_RING = 0x0800,
50  CF_BOND_ALL = 0xFF00,
51  CF_ALL = 0xFFFF,
52 };
53 
54 // \deprecated This function will go away in a future release.
56  const ROMol &mol, boost::uint64_t flags // CodeFlags constants combination
57  ,
58  std::vector<std::uint32_t> *atomCodes // NULL is allowed
59  ,
60  std::vector<std::uint32_t> *bondCodes); // NULL is allowed
61 
62 #pragma pack(push, 1)
64  std::uint16_t Version;
65  std::uint16_t Reserved;
66  std::uint16_t NumAtoms;
67  std::uint16_t NumBonds;
68  std::uint32_t FormulaCRC32;
74 
75  public:
76  HashSet() { memset(this, 0, sizeof(*this)); }
77 };
78 #pragma pack(pop)
79 
80 // \deprecated This function will go away in a future release.
82  const ROMol &mol, HashSet &res, const std::vector<unsigned> *atomsToUse = 0,
83  const std::vector<unsigned> *bondsToUse = 0);
84 
85 // \deprecated This function will go away in a future release.
87  const ROMol &mol, const std::vector<unsigned> *atomsToUse = 0,
88  const std::vector<unsigned> *bondsToUse = 0);
89 
90 // \deprecated This function will go away in a future release.
91 RDKIT_MOLHASH_EXPORT std::string encode(
92  const void *bin,
93  size_t size); // binary data to Base64 encoded string
94 } // namespace MolHash
95 } // namespace RDKit
RDKit::MolHash::HashSet::HashSet
HashSet()
Definition: MolHash.h:76
nmmolhash.h
RDKit::MolHash::HashSet::NonChiralBondsHash
HashCodeType NonChiralBondsHash
Definition: MolHash.h:70
RDKit::MolHash::encode
RDKIT_MOLHASH_EXPORT std::string encode(const void *bin, size_t size)
RDKIT_MOLHASH_EXPORT
#define RDKIT_MOLHASH_EXPORT
Definition: export.h:411
RDKit::MolHash::CF_VALENCE
@ CF_VALENCE
Definition: MolHash.h:37
RDKit::MolHash::CF_BOND_IN_RING
@ CF_BOND_IN_RING
Definition: MolHash.h:49
RDKit::MolHash::CF_ATOM_AROMATIC
@ CF_ATOM_AROMATIC
Definition: MolHash.h:40
RDKit::MolHash::HashSet::NonChiralAtomsHash
HashCodeType NonChiralAtomsHash
Definition: MolHash.h:69
RDKit::MolHash::HashSet::Version
std::uint16_t Version
Definition: MolHash.h:64
RDKit::MolHash::CF_BOND_ALL
@ CF_BOND_ALL
Definition: MolHash.h:50
RDKit::ROMol
Definition: ROMol.h:171
RDKit::MolHash::generateMoleculeHashCode
RDKIT_MOLHASH_EXPORT HashCodeType generateMoleculeHashCode(const ROMol &mol, const std::vector< unsigned > *atomsToUse=0, const std::vector< unsigned > *bondsToUse=0, const std::vector< std::uint32_t > *atomCodes=0, const std::vector< std::uint32_t > *bondCodes=0)
RDKit::MolHash::HashCodeType
std::uint32_t HashCodeType
Definition: MolHash.h:22
RDKit::MolHash::HashSet
Definition: MolHash.h:63
RDKit::MolHash::HashSet::Reserved
std::uint16_t Reserved
Definition: MolHash.h:65
RDKit::MolHash::CF_NO_LABELS
@ CF_NO_LABELS
Definition: MolHash.h:34
RDKit::MolHash::HashSet::ChiralityHash
HashCodeType ChiralityHash
Definition: MolHash.h:73
RDKit::MolHash::CF_ISOTOPE
@ CF_ISOTOPE
Definition: MolHash.h:38
RDKit::MolHash::CF_CHARGE
@ CF_CHARGE
Definition: MolHash.h:36
RDKit::MolHash::CF_BOND_AROMATIZATION
@ CF_BOND_AROMATIZATION
Definition: MolHash.h:44
RDKit::MolHash::CF_BOND_TYPE_EXACT
@ CF_BOND_TYPE_EXACT
Definition: MolHash.h:45
RDKit::MolHash::HashSet::NumAtoms
std::uint16_t NumAtoms
Definition: MolHash.h:66
RDKit::MolHash::CF_BOND_CHIRALITY
@ CF_BOND_CHIRALITY
Definition: MolHash.h:47
RDKit::MolHash::CF_BOND_ORDER
@ CF_BOND_ORDER
Definition: MolHash.h:42
RDKit::MolHash::CF_ATOM_ALL
@ CF_ATOM_ALL
Definition: MolHash.h:41
RDKit::MolHash::CodeFlags
CodeFlags
Definition: MolHash.h:33
RDKit::MolHash::CF_ALL
@ CF_ALL
Definition: MolHash.h:51
RDKit::MolHash::HashSet::FormulaCRC32
std::uint32_t FormulaCRC32
Definition: MolHash.h:68
RDKit
Std stuff.
Definition: Atom.h:30
RDKit::MolHash::HashSet::ChiralBondsHash
HashCodeType ChiralBondsHash
Definition: MolHash.h:72
RDKit::MolHash::fillAtomBondCodes
RDKIT_MOLHASH_EXPORT void fillAtomBondCodes(const ROMol &mol, boost::uint64_t flags, std::vector< std::uint32_t > *atomCodes, std::vector< std::uint32_t > *bondCodes)
RDKit::MolHash::CF_ELEMENT
@ CF_ELEMENT
Definition: MolHash.h:35
RDKit::MolHash::HashSet::NumBonds
std::uint16_t NumBonds
Definition: MolHash.h:67
RDKit::MolHash::generateMoleculeHashSet
RDKIT_MOLHASH_EXPORT void generateMoleculeHashSet(const ROMol &mol, HashSet &res, const std::vector< unsigned > *atomsToUse=0, const std::vector< unsigned > *bondsToUse=0)
RDKit::MolHash::HashSet::ChiralAtomsHash
HashCodeType ChiralAtomsHash
Definition: MolHash.h:71
RDKit::MolHash::CF_ATOM_CHIRALITY
@ CF_ATOM_CHIRALITY
Definition: MolHash.h:39
RDKit::MolHash::MolHash
RDKIT_MOLHASH_EXPORT std::string MolHash(RWMol *mol, enum HashFunction func)
export.h