Files
rdkit/Code/GraphMol/MolHash/Wrap/rdMolHash.cpp
Greg Landrum 5712176605 Implement the two deprecations that were planned for the 2020.09 release cycle (#3047)
* Deprecation: planned removal of .message() and .getMessage() methods

* Deprecation: planned removal of old MolHash code

* document deprecations

* output the diffs when the psql tests fail

* remove .message() from SWIG wrappers

note that the KeyError doesn't work properly. We should clean up the the exceptions here anyway

* typo
2020-04-01 14:30:07 +02:00

55 lines
2.2 KiB
C++

//
// Copyright (C) 2020 Greg Landrum
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDBoost/python.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/MolHash/MolHash.h>
#include <RDBoost/Wrap.h>
namespace python = boost::python;
using namespace RDKit;
namespace {
std::string MolHashHelper(const ROMol &mol, MolHash::HashFunction func) {
RWMol cpy(mol);
return MolHash::MolHash(&cpy, func);
}
} // namespace
BOOST_PYTHON_MODULE(rdMolHash) {
python::scope().attr("__doc__") =
"Module containing functions to generate hashes for molecules";
python::enum_<MolHash::HashFunction>("HashFunction")
.value("AnonymousGraph", MolHash::HashFunction::AnonymousGraph)
.value("ElementGraph", MolHash::HashFunction::ElementGraph)
.value("CanonicalSmiles", MolHash::HashFunction::CanonicalSmiles)
.value("MurckoScaffold", MolHash::HashFunction::MurckoScaffold)
.value("ExtendedMurcko", MolHash::HashFunction::ExtendedMurcko)
.value("MolFormula", MolHash::HashFunction::MolFormula)
.value("AtomBondCounts", MolHash::HashFunction::AtomBondCounts)
.value("DegreeVector", MolHash::HashFunction::DegreeVector)
.value("Mesomer", MolHash::HashFunction::Mesomer)
.value("HetAtomTautomer", MolHash::HashFunction::HetAtomTautomer)
.value("HetAtomProtomer", MolHash::HashFunction::HetAtomProtomer)
.value("RedoxPair", MolHash::HashFunction::RedoxPair)
.value("Regioisomer", MolHash::HashFunction::Regioisomer)
.value("NetCharge", MolHash::HashFunction::NetCharge)
.value("SmallWorldIndexBR", MolHash::HashFunction::SmallWorldIndexBR)
.value("SmallWorldIndexBRL", MolHash::HashFunction::SmallWorldIndexBRL)
.value("ArthorSubstructureOrder",
MolHash::HashFunction::ArthorSubstructureOrder);
python::def("MolHash", MolHashHelper,
(python::arg("mol"), python::arg("func")),
"Generate a hash for a molecule. The func argument determines "
"which hash is generated.");
}