mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-05 22:04:27 +08:00
* add SKIP_IF_ALL_MATCH argument to FragmentRemover
Refactor FragmentRemover::remove() to make it more efficient
* implement and test SKIP_IF_ALL_MATCH
* expose the extra option to Python
* add info to logger
63 lines
2.0 KiB
C++
63 lines
2.0 KiB
C++
//
|
|
// Copyright (C) 2019 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.
|
|
//
|
|
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do
|
|
// this in one cpp file
|
|
#include "catch.hpp"
|
|
|
|
#include <GraphMol/MolStandardize/FragmentCatalog/FragmentCatalogParams.h>
|
|
#include <GraphMol/MolStandardize/FragmentCatalog/FragmentCatalogUtils.h>
|
|
#include <GraphMol/MolStandardize/Fragment.h>
|
|
#include <RDGeneral/Invariant.h>
|
|
#include <GraphMol/RDKitBase.h>
|
|
#include <GraphMol/ROMol.h>
|
|
#include <GraphMol/SmilesParse/SmilesParse.h>
|
|
#include <GraphMol/SmilesParse/SmilesWrite.h>
|
|
#include <GraphMol/FileParsers/FileParsers.h>
|
|
#include <RDGeneral/FileParseException.h>
|
|
#include <GraphMol/FileParsers/MolSupplier.h>
|
|
#include <GraphMol/MolStandardize/MolStandardize.h>
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
using namespace RDKit;
|
|
|
|
TEST_CASE("SKIP_IF_ALL_MATCH") {
|
|
auto m = "[Na+].[Cl-]"_smiles;
|
|
REQUIRE(m);
|
|
|
|
SECTION("default") {
|
|
MolStandardize::FragmentRemover fragRemover;
|
|
std::unique_ptr<ROMol> outm(fragRemover.remove(*m));
|
|
REQUIRE(outm);
|
|
CHECK(MolToSmiles(*outm) == "[Na+]");
|
|
}
|
|
SECTION("don't remove all") {
|
|
MolStandardize::FragmentRemover fragRemover("", true, true);
|
|
std::unique_ptr<ROMol> outm(fragRemover.remove(*m));
|
|
REQUIRE(outm);
|
|
CHECK(MolToSmiles(*outm) == "[Cl-].[Na+]");
|
|
}
|
|
SECTION("feel free to remove everything") {
|
|
MolStandardize::FragmentRemover fragRemover("", false, false);
|
|
std::unique_ptr<ROMol> outm(fragRemover.remove(*m));
|
|
REQUIRE(outm);
|
|
CHECK(outm->getNumAtoms() == 0);
|
|
}
|
|
SECTION("don't remove all 2") {
|
|
MolStandardize::FragmentRemover fragRemover("", true, true);
|
|
auto m = "[Na+].[Cl-].[Na+].[Cl-]"_smiles;
|
|
REQUIRE(m);
|
|
std::unique_ptr<ROMol> outm(fragRemover.remove(*m));
|
|
REQUIRE(outm);
|
|
CHECK(MolToSmiles(*outm) == "[Cl-].[Cl-].[Na+].[Na+]");
|
|
}
|
|
}
|