RDKit
Open-source cheminformatics and machine learning.
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>
18
19namespace RDKit {
20class ROMol;
21
22namespace MolStandardize {
23
24RDKIT_MOLSTANDARDIZE_EXPORT extern const CleanupParameters
26
28 int>
30
32 public:
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);
41
42 //! making FragmentRemover objects non-copyable
43 FragmentRemover(const FragmentRemover &other) = delete;
45
46 ROMol *remove(const ROMol &mol);
47
48 private:
49 // Setting leave_last to True will ensure at least one fragment
50 // is left in the molecule, even if it is matched by a
51 // FragmentPattern
52 bool LEAVE_LAST;
53 // If set, this causes the original molecule to be returned
54 // if every fragment in it matches the salt list
55 bool SKIP_IF_ALL_MATCH;
56 FragmentCatalog *d_fcat;
57
58}; // class FragmentRemover
59
60// caller owns the returned pointer
62 const CleanupParameters &params, bool leave_last = true,
63 bool skip_if_all_match = false) {
64 if (params.fragmentData.empty()) {
65 return new FragmentRemover(params.fragmentFile, leave_last,
66 skip_if_all_match);
67 } else {
68 return new FragmentRemover(params.fragmentData, leave_last,
69 skip_if_all_match);
70 }
71}
72
74 public:
75 // LargestFragmentChooser() {}
76 LargestFragmentChooser(bool preferOrganic = false)
77 : preferOrganic(preferOrganic) {}
79 : preferOrganic(params.preferOrganic),
80 useAtomCount(params.largestFragmentChooserUseAtomCount),
81 countHeavyAtomsOnly(params.largestFragmentChooserCountHeavyAtomsOnly) {}
84
85 ROMol *choose(const ROMol &mol);
86 struct Largest {
88 Largest(std::string &smiles, boost::shared_ptr<ROMol> fragment,
89 unsigned int &numatoms, double &weight, bool &organic);
90 std::string Smiles;
91 boost::shared_ptr<ROMol> Fragment;
92 unsigned int NumAtoms{0};
93 double Weight{0};
94 bool Organic{false};
95 };
96
97 private:
98 bool preferOrganic;
99 bool useAtomCount{true};
100 bool countHeavyAtomsOnly{false};
101}; // class LargestFragmentChooser
102} // namespace MolStandardize
103} // namespace RDKit
104
105#endif
A Catalog with a hierarchical structure.
Definition: Catalog.h:135
FragmentRemover & operator=(FragmentRemover const &)=delete
FragmentRemover(std::istream &fragmentStream, bool leave_last, bool skip_if_all_match=false)
FragmentRemover(const std::string fragmentFile, bool leave_last, bool skip_if_all_match=false)
FragmentRemover(const FragmentRemover &other)=delete
making FragmentRemover objects non-copyable
FragmentRemover(const std::vector< std::pair< std::string, std::string > > &data, bool leave_last, bool skip_if_all_match=false)
ROMol * remove(const ROMol &mol)
LargestFragmentChooser(bool preferOrganic=false)
Definition: Fragment.h:76
LargestFragmentChooser(const CleanupParameters &params)
Definition: Fragment.h:78
LargestFragmentChooser(const LargestFragmentChooser &other)
#define RDKIT_MOLSTANDARDIZE_EXPORT
Definition: export.h:313
FragmentRemover * fragmentRemoverFromParams(const CleanupParameters &params, bool leave_last=true, bool skip_if_all_match=false)
Definition: Fragment.h:61
RDKIT_MOLSTANDARDIZE_EXPORT const CleanupParameters defaultCleanupParameters
Definition: Fragment.h:25
RDCatalog::HierarchCatalog< FragmentCatalogEntry, FragmentCatalogParams, int > FragmentCatalog
Definition: Fragment.h:29
Std stuff.
Definition: Abbreviations.h:18
std::vector< std::pair< std::string, std::string > > fragmentData
Largest(std::string &smiles, boost::shared_ptr< ROMol > fragment, unsigned int &numatoms, double &weight, bool &organic)