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;
69  HashCodeType NonChiralAtomsHash;
70  HashCodeType NonChiralBondsHash;
71  HashCodeType ChiralAtomsHash;
72  HashCodeType ChiralBondsHash;
73  HashCodeType ChiralityHash;
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_EXPORT void generateMoleculeHashSet(const ROMol &mol, HashSet &res, const std::vector< unsigned > *atomsToUse=0, const std::vector< unsigned > *bondsToUse=0)
RDKIT_MOLHASH_EXPORT std::string MolHash(RWMol *mol, enum HashFunction func)
HashCodeType NonChiralBondsHash
Definition: MolHash.h:70
HashCodeType ChiralBondsHash
Definition: MolHash.h:72
std::uint16_t Version
Definition: MolHash.h:64
std::uint16_t Reserved
Definition: MolHash.h:65
std::uint32_t HashCodeType
Definition: MolHash.h:22
HashCodeType ChiralityHash
Definition: MolHash.h:73
RDKIT_MOLHASH_EXPORT void fillAtomBondCodes(const ROMol &mol, boost::uint64_t flags, std::vector< std::uint32_t > *atomCodes, std::vector< std::uint32_t > *bondCodes)
HashCodeType NonChiralAtomsHash
Definition: MolHash.h:69
RDKIT_MOLHASH_EXPORT std::string encode(const void *bin, size_t size)
std::uint16_t NumBonds
Definition: MolHash.h:67
HashCodeType ChiralAtomsHash
Definition: MolHash.h:71
Std stuff.
Definition: Atom.h:30
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)
std::uint16_t NumAtoms
Definition: MolHash.h:66
std::uint32_t FormulaCRC32
Definition: MolHash.h:68
#define RDKIT_MOLHASH_EXPORT
Definition: export.h:411