36 const ROMol &mol,
bool strict =
true,
37 const std::map<unsigned, Atom *> *atomIdxMap =
nullptr) {
38 std::vector<LinkNode> res;
43 std::vector<int> mapping;
45 boost::char_separator<char> pipesep(
"|");
46 boost::char_separator<char> spacesep(
" ");
47 for (
auto linknodetext :
tokenizer(pval, pipesep)) {
50 std::vector<unsigned int> data;
52 std::transform(tokens.begin(), tokens.end(), std::back_inserter(data),
53 [](
const std::string &token) ->
unsigned int {
54 return boost::lexical_cast<unsigned int>(token);
56 }
catch (boost::bad_lexical_cast &) {
57 std::ostringstream errout;
58 errout <<
"Cannot convert values in LINKNODE '" << linknodetext
59 <<
"' to unsigned ints";
69 if (data.size() < 5 || data.size() < 3 + 2 * data[2]) {
70 std::ostringstream errout;
71 errout <<
"not enough values in LINKNODE '" << linknodetext <<
"'";
83 std::ostringstream errout;
84 errout <<
"bad counts in LINKNODE '" << linknodetext <<
"'";
96 "only link nodes with 2 bonds are currently supported");
99 <<
"only link nodes with 2 bonds are currently supported"
105 if (data[3] != data[5]) {
106 std::ostringstream errout;
107 errout <<
"bonds don't start at the same atom for LINKNODE '"
108 << linknodetext <<
"'";
119 for (
unsigned int i = 3; i <= 6; ++i) {
120 const auto aidx = atomIdxMap->find(data[i] - 1);
121 if (aidx == atomIdxMap->end()) {
122 std::ostringstream errout;
123 errout <<
"atom index " << data[i]
124 <<
" cannot be found in molecule for LINKNODE '"
125 << linknodetext <<
"'";
133 data[i] = aidx->second->getIdx();
137 for (
unsigned int i = 3; i <= 6; ++i) {
141 node.
bondAtoms.push_back(std::make_pair(data[3], data[4]));
142 node.
bondAtoms.push_back(std::make_pair(data[5], data[6]));
145 std::ostringstream errout;
146 errout <<
"bond not found between atoms in LINKNODE '" << linknodetext
155 res.push_back(std::move(node));