32 const ROMol &mol,
bool strict =
true,
33 const std::map<unsigned, Atom *> *atomIdxMap =
nullptr) {
34 std::vector<LinkNode> res;
39 std::vector<int> mapping;
41 boost::char_separator<char> pipesep(
"|");
42 boost::char_separator<char> spacesep(
" ");
43 for (
auto linknodetext :
tokenizer(pval, pipesep)) {
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 &) {
53 std::ostringstream errout;
54 errout <<
"Cannot convert values in LINKNODE '" << linknodetext
55 <<
"' to unsigned ints";
65 if (data.size() < 5 || data.size() < 3 + 2 * data[2]) {
66 std::ostringstream errout;
67 errout <<
"not enough values in LINKNODE '" << linknodetext <<
"'";
79 std::ostringstream errout;
80 errout <<
"bad counts in LINKNODE '" << linknodetext <<
"'";
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 '"
104 << linknodetext <<
"'";
115 for (
unsigned int i = 3; i <= 6; ++i) {
116 const auto aidx = atomIdxMap->find(data[i] - 1);
117 if (aidx == atomIdxMap->end()) {
118 std::ostringstream errout;
119 errout <<
"atom index " << data[i]
120 <<
" cannot be found in molecule for LINKNODE '"
121 << linknodetext <<
"'";
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;
142 errout <<
"bond not found between atoms in LINKNODE '" << linknodetext
151 res.push_back(std::move(node));