34 const ROMol &mol,
bool strict =
true,
35 const std::map<unsigned, Atom *> *atomIdxMap =
nullptr) {
36 std::vector<LinkNode> res;
41 std::vector<int> mapping;
43 boost::char_separator<char> pipesep(
"|");
44 boost::char_separator<char> spacesep(
" ");
45 for (
auto linknodetext :
tokenizer(pval, pipesep)) {
48 std::vector<unsigned int> data;
50 std::transform(tokens.begin(), tokens.end(), std::back_inserter(data),
51 [](
const std::string &token) ->
unsigned int {
52 return boost::lexical_cast<unsigned int>(token);
54 }
catch (boost::bad_lexical_cast &) {
55 std::ostringstream errout;
56 errout <<
"Cannot convert values in LINKNODE '" << linknodetext
57 <<
"' to unsigned ints";
67 if (data.size() < 5 || data.size() < 3 + 2 * data[2]) {
68 std::ostringstream errout;
69 errout <<
"not enough values in LINKNODE '" << linknodetext <<
"'";
81 std::ostringstream errout;
82 errout <<
"bad counts in LINKNODE '" << linknodetext <<
"'";
94 "only link nodes with 2 bonds are currently supported");
97 <<
"only link nodes with 2 bonds are currently supported"
103 if (data[3] != data[5]) {
104 std::ostringstream errout;
105 errout <<
"bonds don't start at the same atom for LINKNODE '"
106 << linknodetext <<
"'";
117 for (
unsigned int i = 3; i <= 6; ++i) {
118 const auto aidx = atomIdxMap->find(data[i] - 1);
119 if (aidx == atomIdxMap->end()) {
120 std::ostringstream errout;
121 errout <<
"atom index " << data[i]
122 <<
" cannot be found in molecule for LINKNODE '"
123 << linknodetext <<
"'";
131 data[i] = aidx->second->getIdx();
135 for (
unsigned int i = 3; i <= 6; ++i) {
139 node.
bondAtoms.push_back(std::make_pair(data[3], data[4]));
140 node.
bondAtoms.push_back(std::make_pair(data[5], data[6]));
143 std::ostringstream errout;
144 errout <<
"bond not found between atoms in LINKNODE '" << linknodetext
153 res.push_back(std::move(node));