13#include <boost/lexical_cast.hpp>
14#include <boost/tokenizer.hpp>
15#include <boost/format.hpp>
18typedef boost::tokenizer<boost::char_separator<char>>
tokenizer;
21namespace MolEnumerator {
27 std::vector<std::pair<unsigned int, unsigned int>>
bondAtoms;
32 const ROMol &mol,
bool strict =
true,
33 const std::map<unsigned, Atom *> *
atomIdxMap =
nullptr) {
34 std::vector<LinkNode>
res;
41 boost::char_separator<char>
pipesep(
"|");
42 boost::char_separator<char>
spacesep(
" ");
46 std::vector<unsigned int> data;
48 std::transform(
tokens.begin(),
tokens.end(), std::back_inserter(data),
49 [](
const std::string &
token) ->
unsigned int {
50 return boost::lexical_cast<unsigned int>(token);
52 }
catch (boost::bad_lexical_cast &) {
55 <<
"' to unsigned ints";
65 if (data.size() < 5 || data.size() < 3 + 2 * data[2]) {
76 node.minRep = data[0];
77 node.maxRep = data[1];
88 node.nBonds = data[2];
89 if (
node.nBonds != 2) {
92 "only link nodes with 2 bonds are currently supported");
95 <<
"only link nodes with 2 bonds are currently supported"
101 if (data[3] != data[5]) {
102 std::ostringstream
errout;
103 errout <<
"bonds don't start at the same atom for LINKNODE '"
115 for (
unsigned int i = 3; i <= 6; ++i) {
118 std::ostringstream
errout;
119 errout <<
"atom index " << data[i]
120 <<
" cannot be found in molecule for LINKNODE '"
129 data[i] =
aidx->second->getIdx();
133 for (
unsigned int i = 3; i <= 6; ++i) {
137 node.bondAtoms.push_back(std::make_pair(data[3], data[4]));
138 node.bondAtoms.push_back(std::make_pair(data[5], data[6]));
141 std::ostringstream
errout;
151 res.push_back(std::move(
node));
#define UNDER_CONSTRUCTION(fn)
boost::tokenizer< boost::char_separator< char > > tokenizer
#define BOOST_LOG(__arg__)
RDKIT_RDGENERAL_EXPORT RDLogger rdWarningLog
bool getPropIfPresent(const std::string &key, T &res) const
Bond * getBondBetweenAtoms(unsigned int idx1, unsigned int idx2)
returns a pointer to the bond between two atoms, Null on failure
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
std::vector< LinkNode > getMolLinkNodes(const ROMol &mol, bool strict=true, const std::map< unsigned, Atom * > *atomIdxMap=nullptr)
RDKIT_RDGENERAL_EXPORT const std::string molFileLinkNodes
bool rdvalue_is(const RDValue_cast_t)
std::vector< std::pair< unsigned int, unsigned int > > bondAtoms