mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
@@ -482,7 +482,9 @@ std::vector<MatchVectType> SubstructMatch(
|
||||
const ROMol &mol, const ROMol &query,
|
||||
const SubstructMatchParameters ¶ms) {
|
||||
std::vector<MatchVectType> matches;
|
||||
if (!mol.getNumAtoms() || !query.getNumAtoms()) {
|
||||
const auto &mNumAtoms = mol.getNumAtoms();
|
||||
const auto &qNumAtoms = query.getNumAtoms();
|
||||
if (!mNumAtoms || !qNumAtoms || qNumAtoms > mNumAtoms) {
|
||||
return matches;
|
||||
}
|
||||
|
||||
|
||||
@@ -1104,4 +1104,22 @@ TEST_CASE("extra atom and bond queries") {
|
||||
CHECK(matches[0][1].second == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
TEST_CASE("quick return when the query has more atoms than the molecule") {
|
||||
SECTION("basics") {
|
||||
SubstructMatchParameters ps;
|
||||
bool touched = false;
|
||||
auto atomQuery = [&touched](const Atom &, const Atom &) -> bool {
|
||||
touched = true;
|
||||
return true;
|
||||
};
|
||||
ps.extraAtomCheck = atomQuery;
|
||||
auto mol = "CC"_smiles;
|
||||
REQUIRE(mol);
|
||||
auto qry = "CCC"_smarts;
|
||||
REQUIRE(qry);
|
||||
auto matches = SubstructMatch(*mol, *qry, ps);
|
||||
CHECK(matches.empty());
|
||||
CHECK(!touched);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user