mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* Create a function to extract some specified atoms from a ROMol as a new ROMol by creating new graph (#8742) This adds a new api, `RDKit::MolOps::ExtractMolFragment`, to allow efficient extractions of mol fragments from large mols. Compared to the approach where we delete "unwanted" atoms/bonds from the input mol, this api is faster for small mols (about 2x faster) and at least 3x faster for big mols (was 10x faster for "CCC"*1000). * clang-format * review comments * cleanup * Consolidate copying subsets of molecules * Readd missing tests * Update comment to restart build * Remove missing test * Remove debugging comment, fix warnings * Fix warnings on gcc11 * Add docs * Make vector<bool> dynamic_bitset<> * Update copyright * Add swig wrappers * Use new designated constructor API * Fix windows builds * Change enum values from unsigned int to integer * Fix unsigned int variable * Update Code/GraphMol/Wrap/test_subset.py Co-authored-by: Greg Landrum <greg.landrum@gmail.com> * Update Code/GraphMol/Subset.cpp Co-authored-by: Greg Landrum <greg.landrum@gmail.com> * Update Code/JavaWrappers/gmwrapper/src-test/org/RDKit/ChemTransformsTests.java Co-authored-by: Greg Landrum <greg.landrum@gmail.com> * Reponse to review * Fix documentation * Remove comments * Remove unnecessary comments * Fix one liners * Change assertion to be clearer (and not one-liners) * Run clang-format --------- Co-authored-by: Your Name <you@example.com> Co-authored-by: Hussein Faara <hussein.faara@schrodinger.com> Co-authored-by: Brian Kelley <bkelley@glysade.com> Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
61 lines
1.7 KiB
C++
61 lines
1.7 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 <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);
|
|
}
|
|
}
|