RDKit: MolFragmenter.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
MolFragmenter.h
Go to the documentation of this file.
1//
2// Copyright (C) 2013 Greg Landrum
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_MOLFRAGMENTER_H__
12#define _RD_MOLFRAGMENTER_H__
13
14#include <istream>
15#include <GraphMol/ROMol.h>
16#include <RDGeneral/BetterEnums.h>
17
18namespace RDKit {
19 namespace MolFragmenter {
20 struct RDKIT_CHEMTRANSFORMS_EXPORT FragmenterBondType {
21 unsigned int atom1Label, atom2Label;
22 unsigned int atom1Type, atom2Type;
23 Bond::BondType bondType;
24 ROMOL_SPTR query;
25};
26
27//! \brief Fragments a molecule by breaking a set of bonds
28//!
29/*!
30
31 \param mol - the molecule to be modified
32 \param bondIndices - indices of the bonds to be broken
33
34 optional:
35 \param addDummies - toggles addition of dummy atoms to indicate where
36 bonds were broken
37 \param dummyLabels - used to provide the labels to be used for the dummies.
38 the first element in each pair is the label for the dummy
39 that replaces the bond's beginAtom, the second is for the
40 dummy that replaces the bond's endAtom. If not provided, the
41 dummies are labeled with atom indices.
42 \param bondTypes - used to provide the bond type to use between the
43 fragments and the dummy atoms. If not provided, defaults to single.
44 \param nCutsPerAtom - used to return the number of bonds that were
45 cut at each atom. Should be nAtoms long.
46
47 \return a new ROMol with the modifications
48 The client is responsible for deleting this molecule.
49 Unless bondTypes is provided, the bonds to the new dummy atoms will be
50 of the same type as the bond that is broken, and any queries on the
51 broken bonds transferred to the new bonds.
52
53*/
54 RDKIT_CHEMTRANSFORMS_EXPORT ROMol *fragmentOnBonds(
55 const ROMol &mol, const std::vector<unsigned int> &bondIndices,
56 bool addDummies = true,
57 const std::vector<std::pair<unsigned int, unsigned int>> *dummyLabels =
58 nullptr,
59 const std::vector<Bond::BondType> *bondTypes = nullptr,
60 std::vector<unsigned int> *nCutsPerAtom = nullptr);
61//! \overload
62 RDKIT_CHEMTRANSFORMS_EXPORT ROMol *fragmentOnBonds(
63 const ROMol &mol, const std::vector<FragmenterBondType> &bondPatterns,
64 const std::map<unsigned int, ROMOL_SPTR> *atomEnvirons = nullptr,
65 std::vector<unsigned int> *nCutsPerAtom = nullptr);
66 RDKIT_CHEMTRANSFORMS_EXPORT void fragmentOnSomeBonds(
67 const ROMol &mol, const std::vector<unsigned int> &bondIndices,
68 std::vector<ROMOL_SPTR> &resMols, unsigned int maxToCut = 1,
69 bool addDummies = true,
70 const std::vector<std::pair<unsigned int, unsigned int>> *dummyLabels =
71 nullptr,
72 const std::vector<Bond::BondType> *bondTypes = nullptr,
73 std::vector<std::vector<unsigned int>> *nCutsPerAtom = nullptr);
74
75//! \brief Fragments a molecule by breaking all BRICS bonds
76/*!
77 \return a new ROMol with the modifications
78 The client is responsible for deleting this molecule.
79
80*/
81 RDKIT_CHEMTRANSFORMS_EXPORT ROMol *fragmentOnBRICSBonds(const ROMol &mol);
82
83 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterAtomTypes(
84 std::istream *inStream, std::map<unsigned int, std::string> &defs,
85 const std::string &comment = "//", bool validate = true,
86 std::map<unsigned int, ROMOL_SPTR> *environs = nullptr);
87 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterAtomTypes(
88 const std::string &str, std::map<unsigned int, std::string> &defs,
89 const std::string &comment = "//", bool validate = true,
90 std::map<unsigned int, ROMOL_SPTR> *environs = nullptr);
91 RDKIT_CHEMTRANSFORMS_EXPORT void constructBRICSAtomTypes(
92 std::map<unsigned int, std::string> &defs,
93 std::map<unsigned int, ROMOL_SPTR> *environs = nullptr);
94 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterBondTypes(
95 std::istream *inStream,
96 const std::map<unsigned int, std::string> &atomTypes,
97 std::vector<FragmenterBondType> &defs, const std::string &comment = "//",
98 bool validate = true, bool labelByConnector = true);
99 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterBondTypes(
100 const std::string &str,
101 const std::map<unsigned int, std::string> &atomTypes,
102 std::vector<FragmenterBondType> &defs, const std::string &comment = "//",
103 bool validate = true, bool labelByConnector = true);
104 RDKIT_CHEMTRANSFORMS_EXPORT void constructBRICSBondTypes(
105 std::vector<FragmenterBondType> &defs);
106} // namespace MolFragmenter
107
108// n.b. AtomProperty must resolve to an unsigned integer value on an atom
109// property
110// clang-format off
111 BETTER_ENUM_CLASS(MolzipLabel, unsigned int,
112 AtomMapNumber,
113 Isotope,
114 FragmentOnBonds,
115 AtomType,
116 AtomProperty
117);
118// clang-format on
119
120 struct RDKIT_CHEMTRANSFORMS_EXPORT MolzipParams {
121 MolzipLabel label = MolzipLabel::AtomMapNumber;
122 std::vector<std::string> atomSymbols;
123 std::string atomProperty;
124 bool enforceValenceRules = true;
125 bool generateCoordinates =
126 false; ///< if true, 2D coords will be generated for
127 /// the output molecule and assigned to the input fragments as
128 /// well
129 bool alignCoordinates =
130 false; ///< if true and the input fragments have coordinates,
131 /// the fragments will be aligned along connection vectors in the
132 /// output molecule
133};
134
135 RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr<ROMol> molzip(
136 const ROMol &a, const ROMol &b,
137 const MolzipParams &params = MolzipParams());
138
139 RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr<ROMol> molzip(
140 const ROMol &a, const MolzipParams &params = MolzipParams());
141
142//! \brief Creates a molecule from an R group decomposition
143/*!
144 *
145 * @param decomposition - A list of molecules that comprises an R group
146 * decomposition. The core must be the first molecule in the list. If
147 * generateCoordinates is set in the parameters then aligned depiction
148 * coordinates will be set on the returned molecule and the input decomposition
149 *
150 * optional:
151 * @param params - molzip parameters
152 *
153 * @return the zipped molecule
154 */
155 RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr<ROMol> molzip(
156 std::vector<ROMOL_SPTR> &decomposition,
157 const MolzipParams &params = MolzipParams());
158
159//! \brief Molzip an RGroupRow back into the original molecule if possible
160/*! This correctly handles broken cycles that can happend during arbitrary
161 * RGroup Decomposition.
162 *
163 * @param row - rgroup row as returned by the rgroup decompisition
164 *
165 * optional:
166 * @param params - molzip parameters
167 *
168 * @return - the zipped molecule
169 */
170 RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr<ROMol> molzip(
171 const std::map<std::string, ROMOL_SPTR> &row,
172 const MolzipParams &params = MolzipParams());
173
174} // namespace RDKit
175#endif
BetterEnums.h
BETTER_ENUM_CLASS
#define BETTER_ENUM_CLASS(Enum, Underlying,...)
Definition BetterEnums.h:18
ROMol.h
Defines the primary molecule class ROMol as well as associated typedefs.
RDKit::Bond::BondType
BondType
the type of Bond
Definition Bond.h:55
RDKit::ROMol
Definition ROMol.h:199
export.h
RDKIT_CHEMTRANSFORMS_EXPORT
#define RDKIT_CHEMTRANSFORMS_EXPORT
Definition export.h:65
RDKit::MolFragmenter
Definition MolFragmenter.h:19
RDKit::MolFragmenter::fragmentOnSomeBonds
RDKIT_CHEMTRANSFORMS_EXPORT void fragmentOnSomeBonds(const ROMol &mol, const std::vector< unsigned int > &bondIndices, std::vector< ROMOL_SPTR > &resMols, unsigned int maxToCut=1, bool addDummies=true, const std::vector< std::pair< unsigned int, unsigned int > > *dummyLabels=nullptr, const std::vector< Bond::BondType > *bondTypes=nullptr, std::vector< std::vector< unsigned int > > *nCutsPerAtom=nullptr)
RDKit::MolFragmenter::constructBRICSBondTypes
RDKIT_CHEMTRANSFORMS_EXPORT void constructBRICSBondTypes(std::vector< FragmenterBondType > &defs)
RDKit::MolFragmenter::constructFragmenterAtomTypes
RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterAtomTypes(std::istream *inStream, std::map< unsigned int, std::string > &defs, const std::string &comment="//", bool validate=true, std::map< unsigned int, ROMOL_SPTR > *environs=nullptr)
RDKit::MolFragmenter::fragmentOnBonds
RDKIT_CHEMTRANSFORMS_EXPORT ROMol * fragmentOnBonds(const ROMol &mol, const std::vector< unsigned int > &bondIndices, bool addDummies=true, const std::vector< std::pair< unsigned int, unsigned int > > *dummyLabels=nullptr, const std::vector< Bond::BondType > *bondTypes=nullptr, std::vector< unsigned int > *nCutsPerAtom=nullptr)
Fragments a molecule by breaking a set of bonds.
RDKit::MolFragmenter::fragmentOnBRICSBonds
RDKIT_CHEMTRANSFORMS_EXPORT ROMol * fragmentOnBRICSBonds(const ROMol &mol)
Fragments a molecule by breaking all BRICS bonds.
RDKit::MolFragmenter::constructFragmenterBondTypes
RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterBondTypes(std::istream *inStream, const std::map< unsigned int, std::string > &atomTypes, std::vector< FragmenterBondType > &defs, const std::string &comment="//", bool validate=true, bool labelByConnector=true)
RDKit::MolFragmenter::constructBRICSAtomTypes
RDKIT_CHEMTRANSFORMS_EXPORT void constructBRICSAtomTypes(std::map< unsigned int, std::string > &defs, std::map< unsigned int, ROMOL_SPTR > *environs=nullptr)
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::molzip
RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr< ROMol > molzip(const ROMol &a, const ROMol &b, const MolzipParams &params=MolzipParams())
RDKit::ROMOL_SPTR
boost::shared_ptr< ROMol > ROMOL_SPTR
Definition ChemTransforms.h:22
RDKit::MolFragmenter::FragmenterBondType
Definition MolFragmenter.h:20
RDKit::MolFragmenter::FragmenterBondType::bondType
Bond::BondType bondType
Definition MolFragmenter.h:23
RDKit::MolFragmenter::FragmenterBondType::atom2Label
unsigned int atom2Label
Definition MolFragmenter.h:21
RDKit::MolFragmenter::FragmenterBondType::atom2Type
unsigned int atom2Type
Definition MolFragmenter.h:22
RDKit::MolFragmenter::FragmenterBondType::query
ROMOL_SPTR query
Definition MolFragmenter.h:24
RDKit::MolFragmenter::FragmenterBondType::atom1Type
unsigned int atom1Type
Definition MolFragmenter.h:22
RDKit::MolFragmenter::FragmenterBondType::atom1Label
unsigned int atom1Label
Definition MolFragmenter.h:21
RDKit::MolzipParams
Definition MolFragmenter.h:120
RDKit::MolzipParams::atomProperty
std::string atomProperty
Definition MolFragmenter.h:123
RDKit::MolzipParams::alignCoordinates
bool alignCoordinates
Definition MolFragmenter.h:129
RDKit::MolzipParams::enforceValenceRules
bool enforceValenceRules
Definition MolFragmenter.h:124
RDKit::MolzipParams::generateCoordinates
bool generateCoordinates
Definition MolFragmenter.h:125
RDKit::MolzipParams::label
MolzipLabel label
Definition MolFragmenter.h:121
RDKit::MolzipParams::atomSymbols
std::vector< std::string > atomSymbols
Definition MolFragmenter.h:122