Files
rdkit/Code/GraphMol/Subgraphs/catch_tests.cpp
Brian Kelley 553424d6b6 Revert "Create a function to extract some specified atoms from a ROMol as a new ROMol by creating new graph (#8742) (#8743)" (#8814)
This reverts commit 040bdb61c7.

During testing of using this as a replacement for portions of
getTheFrags in getMolFrags, several issues came up regarding
how copies should actually work in practice.  These are being
corrected in a new pr:  https://github.com/rdkit/rdkit/pull/8811

Co-authored-by: Brian Kelley <bkelley@glysade.com>
2025-09-25 10:54:36 +02:00

61 lines
1.8 KiB
C++

//
// Copyright (C) 2023 Greg Landrum
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <catch2/catch_all.hpp>
#include <RDGeneral/test.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/Subgraphs/Subgraphs.h>
#include <GraphMol/Subgraphs/SubgraphUtils.h>
#include <iostream>
#include <algorithm>
using namespace RDKit;
TEST_CASE("shortestPathsOnly") {
SECTION("basics, findAllPathsOfLengthN") {
auto m = "CC1CCC1"_smiles;
REQUIRE(m);
bool useBonds = true;
bool useHs = false;
int rootedAt = -1;
bool onlyShortestPaths = true;
auto ps = findAllPathsOfLengthN(*m, 4);
CHECK(ps.size() == 3);
ps = findAllPathsOfLengthN(*m, 4, useBonds, useHs, rootedAt,
onlyShortestPaths);
CHECK(ps.empty());
ps = findAllPathsOfLengthN(*m, 3);
CHECK(ps.size() == 6);
std::cerr << "---------" << std::endl;
ps = findAllPathsOfLengthN(*m, 3, useBonds, useHs, rootedAt,
onlyShortestPaths);
CHECK(ps.size() == 2);
}
SECTION("basics, findAllPathsOfLengthsMtoN") {
auto m = "CC1CCC1"_smiles;
REQUIRE(m);
bool useBonds = true;
bool useHs = false;
int rootedAt = -1;
bool onlyShortestPaths = true;
auto ps = findAllPathsOfLengthsMtoN(*m, 3, 4);
CHECK(ps.size() == 2);
CHECK(ps[3].size() == 6);
CHECK(ps[4].size() == 3);
ps = findAllPathsOfLengthsMtoN(*m, 3, 4, useBonds, useHs, rootedAt,
onlyShortestPaths);
CHECK(ps.size() == 1);
CHECK(ps[3].size() == 2);
}
}