This commit is contained in:
Greg Landrum
2021-03-11 17:15:08 +01:00
committed by GitHub
parent 18afde70b0
commit fa6de7b423
3 changed files with 79 additions and 14 deletions

View File

@@ -675,7 +675,8 @@ bool _atomListQueryHelper(const T query) {
if (query->getNegation()) {
return false;
}
if (query->getDescription() == "AtomAtomicNum") {
if (query->getDescription() == "AtomAtomicNum" ||
query->getDescription() == "AtomType") {
return true;
}
if (query->getDescription() == "AtomOr") {
@@ -717,14 +718,23 @@ void getAtomListQueryVals(const Atom::QUERYATOM_QUERY *q,
boost::make_iterator_range(q->beginChildren(), q->endChildren())) {
auto descr = child->getDescription();
if (child->getNegation() ||
(descr != "AtomOr" && descr != "AtomAtomicNum")) {
throw ValueErrorException("bad query type");
(descr != "AtomOr" && descr != "AtomAtomicNum" &&
descr != "AtomType")) {
throw ValueErrorException("bad query type1");
}
// we don't allow negation of any children of the query:
if (descr == "AtomOr") {
getAtomListQueryVals(child.get(), vals);
} else if (descr == "AtomAtomicNum") {
vals.push_back(static_cast<ATOM_EQUALS_QUERY *>(child.get())->getVal());
} else if (descr == "AtomType") {
auto v = static_cast<ATOM_EQUALS_QUERY *>(child.get())->getVal();
// aromatic AtomType queries subtract 1000 from the atomic number;
// correct for that:
if (v < 0) {
v += 1000;
}
vals.push_back(v);
}
}
}