RDKit: Fragment.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
Fragment.h
Go to the documentation of this file.
1//
2// Copyright (C) 2018-2021 Susan H. Leung and other RDKit contributors
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10#include <RDGeneral/export.h>
11#ifndef RD_FRAGMENT_REMOVER_H
12#define RD_FRAGMENT_REMOVER_H
13
14#include <Catalogs/Catalog.h>
15#include <GraphMol/MolStandardize/FragmentCatalog/FragmentCatalogEntry.h>
16#include <GraphMol/MolStandardize/FragmentCatalog/FragmentCatalogParams.h>
17#include <GraphMol/MolStandardize/MolStandardize.h>
18
19namespace RDKit {
20class ROMol;
21
22namespace MolStandardize {
23
24 RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
25 defaultCleanupParameters;
26
27typedef RDCatalog::HierarchCatalog<FragmentCatalogEntry, FragmentCatalogParams,
28 int>
29 FragmentCatalog;
30
31 class RDKIT_MOLSTANDARDIZE_EXPORT FragmentRemover {
32 public:
33 FragmentRemover();
34 FragmentRemover(const std::string fragmentFile, bool leave_last,
35 bool skip_if_all_match = false);
36 FragmentRemover(std::istream &fragmentStream, bool leave_last,
37 bool skip_if_all_match = false);
38 FragmentRemover(const std::vector<std::pair<std::string, std::string>> &data,
39 bool leave_last, bool skip_if_all_match = false);
40 ~FragmentRemover();
41
42 //! making FragmentRemover objects non-copyable
43 FragmentRemover(const FragmentRemover &other) = delete;
44 FragmentRemover &operator=(FragmentRemover const &) = delete;
45
46 ROMol *remove(const ROMol &mol);
47 void removeInPlace(RWMol &mol);
48
49 private:
50 // Setting leave_last to True will ensure at least one fragment
51 // is left in the molecule, even if it is matched by a
52 // FragmentPattern
53 bool LEAVE_LAST;
54 // If set, this causes the original molecule to be returned
55 // if every fragment in it matches the salt list
56 bool SKIP_IF_ALL_MATCH;
57 FragmentCatalog *d_fcat;
58
59}; // class FragmentRemover
60
61// caller owns the returned pointer
62 inline FragmentRemover *fragmentRemoverFromParams(
63 const CleanupParameters &params, bool leave_last = true,
64 bool skip_if_all_match = false) {
65 if (params.fragmentData.empty()) {
66 return new FragmentRemover(params.fragmentFile, leave_last,
67 skip_if_all_match);
68 } else {
69 return new FragmentRemover(params.fragmentData, leave_last,
70 skip_if_all_match);
71 }
72}
73
74 class RDKIT_MOLSTANDARDIZE_EXPORT LargestFragmentChooser {
75 public:
76 // LargestFragmentChooser() {}
77 LargestFragmentChooser(bool preferOrganic = false)
78 : preferOrganic(preferOrganic) {}
79 LargestFragmentChooser(const CleanupParameters &params)
80 : preferOrganic(params.preferOrganic),
81 useAtomCount(params.largestFragmentChooserUseAtomCount),
82 countHeavyAtomsOnly(params.largestFragmentChooserCountHeavyAtomsOnly) {}
83 LargestFragmentChooser(const LargestFragmentChooser &other);
84 ~LargestFragmentChooser() = default;
85
86 ROMol *choose(const ROMol &mol) const;
87 void chooseInPlace(RWMol &mol) const;
88 struct Largest {
89 Largest();
90 Largest(std::string &smiles, boost::shared_ptr<ROMol> fragment,
91 unsigned int &numatoms, double &weight, bool &organic);
92 std::string Smiles;
93 boost::shared_ptr<ROMol> Fragment;
94 unsigned int NumAtoms{0};
95 double Weight{0};
96 bool Organic{false};
97 };
98
99 private:
100 bool preferOrganic;
101 bool useAtomCount{true};
102 bool countHeavyAtomsOnly{false};
103}; // class LargestFragmentChooser
104} // namespace MolStandardize
105} // namespace RDKit
106
107#endif
Catalog.h
FragmentCatalogEntry.h
FragmentCatalogParams.h
MolStandardize.h
Defines the CleanupParameters and some convenience functions.
RDCatalog::HierarchCatalog
A Catalog with a hierarchical structure.
Definition Catalog.h:135
RDKit::MolStandardize::FragmentCatalogEntry
Definition FragmentCatalogEntry.h:24
RDKit::MolStandardize::FragmentCatalogParams
Definition FragmentCatalogParams.h:25
RDKit::MolStandardize::FragmentRemover
Definition Fragment.h:31
RDKit::MolStandardize::FragmentRemover::operator=
FragmentRemover & operator=(FragmentRemover const &)=delete
RDKit::MolStandardize::FragmentRemover::FragmentRemover
FragmentRemover(std::istream &fragmentStream, bool leave_last, bool skip_if_all_match=false)
RDKit::MolStandardize::FragmentRemover::removeInPlace
void removeInPlace(RWMol &mol)
RDKit::MolStandardize::FragmentRemover::FragmentRemover
FragmentRemover(const std::string fragmentFile, bool leave_last, bool skip_if_all_match=false)
RDKit::MolStandardize::FragmentRemover::FragmentRemover
FragmentRemover()
RDKit::MolStandardize::FragmentRemover::FragmentRemover
FragmentRemover(const FragmentRemover &other)=delete
making FragmentRemover objects non-copyable
RDKit::MolStandardize::FragmentRemover::FragmentRemover
FragmentRemover(const std::vector< std::pair< std::string, std::string > > &data, bool leave_last, bool skip_if_all_match=false)
RDKit::MolStandardize::FragmentRemover::~FragmentRemover
~FragmentRemover()
RDKit::MolStandardize::FragmentRemover::remove
ROMol * remove(const ROMol &mol)
RDKit::MolStandardize::LargestFragmentChooser::~LargestFragmentChooser
~LargestFragmentChooser()=default
RDKit::MolStandardize::LargestFragmentChooser::LargestFragmentChooser
LargestFragmentChooser(bool preferOrganic=false)
Definition Fragment.h:77
RDKit::MolStandardize::LargestFragmentChooser::LargestFragmentChooser
LargestFragmentChooser(const CleanupParameters &params)
Definition Fragment.h:79
RDKit::MolStandardize::LargestFragmentChooser::LargestFragmentChooser
LargestFragmentChooser(const LargestFragmentChooser &other)
RDKit::MolStandardize::LargestFragmentChooser::choose
ROMol * choose(const ROMol &mol) const
RDKit::MolStandardize::LargestFragmentChooser::chooseInPlace
void chooseInPlace(RWMol &mol) const
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
export.h
RDKIT_MOLSTANDARDIZE_EXPORT
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition export.h:369
RDKit::MolStandardize
Definition AcidBaseCatalogEntry.h:22
RDKit::MolStandardize::fragmentRemoverFromParams
FragmentRemover * fragmentRemoverFromParams(const CleanupParameters &params, bool leave_last=true, bool skip_if_all_match=false)
Definition Fragment.h:62
RDKit::MolStandardize::defaultCleanupParameters
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition Fragment.h:25
RDKit::MolStandardize::FragmentCatalog
RDCatalog::HierarchCatalog< FragmentCatalogEntry, FragmentCatalogParams, int > FragmentCatalog
Definition Fragment.h:29
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::MolStandardize::CleanupParameters
Definition MolStandardize.h:41
RDKit::MolStandardize::CleanupParameters::fragmentFile
std::string fragmentFile
Definition MolStandardize.h:50
RDKit::MolStandardize::CleanupParameters::fragmentData
std::vector< std::pair< std::string, std::string > > fragmentData
Definition MolStandardize.h:81
RDKit::MolStandardize::LargestFragmentChooser::Largest::Largest
Largest()
RDKit::MolStandardize::LargestFragmentChooser::Largest::Largest
Largest(std::string &smiles, boost::shared_ptr< ROMol > fragment, unsigned int &numatoms, double &weight, bool &organic)
RDKit::MolStandardize::LargestFragmentChooser::Largest::Smiles
std::string Smiles
Definition Fragment.h:92
RDKit::MolStandardize::LargestFragmentChooser::Largest::Weight
double Weight
Definition Fragment.h:95
RDKit::MolStandardize::LargestFragmentChooser::Largest::Fragment
boost::shared_ptr< ROMol > Fragment
Definition Fragment.h:93
RDKit::MolStandardize::LargestFragmentChooser::Largest::NumAtoms
unsigned int NumAtoms
Definition Fragment.h:94
RDKit::MolStandardize::LargestFragmentChooser::Largest::Organic
bool Organic
Definition Fragment.h:96