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 17 namespace RDKit { 18 namespace MolFragmenter { 19 struct RDKIT_CHEMTRANSFORMS_EXPORT FragmenterBondType { 20 unsigned int atom1Label, atom2Label; 21 unsigned int atom1Type, atom2Type; 22 Bond::BondType bondType; 23 ROMOL_SPTR query; 24 }; 25 26 //! \brief Fragments a molecule by breaking a set of bonds 27 //! 28 /*! 29 30 \param mol - the molecule to be modified 31 \param bondIndices - indices of the bonds to be broken 32 33 optional: 34 \param addDummies - toggles addition of dummy atoms to indicate where 35 bonds were broken 36 \param dummyLabels - used to provide the labels to be used for the dummies. 37 the first element in each pair is the label for the dummy 38 that replaces the bond's beginAtom, the second is for the 39 dummy that replaces the bond's endAtom. If not provided, the 40 dummies are labeled with atom indices. 41 \param bondTypes - used to provide the bond type to use between the 42 fragments and the dummy atoms. If not provided, defaults to single. 43 \param nCutsPerAtom - used to return the number of bonds that were 44 cut at each atom. Should be nAtoms long. 45 46 \return a new ROMol with the modifications 47 The client is responsible for deleting this molecule. 48 49 */ 50 RDKIT_CHEMTRANSFORMS_EXPORT ROMol *fragmentOnBonds( 51 const ROMol &mol, const std::vector<unsigned int> &bondIndices, 52 bool addDummies = true, 53 const std::vector<std::pair<unsigned int, unsigned int>> *dummyLabels = 54 nullptr, 55 const std::vector<Bond::BondType> *bondTypes = nullptr, 56 std::vector<unsigned int> *nCutsPerAtom = nullptr); 57 //! \overload 58 RDKIT_CHEMTRANSFORMS_EXPORT ROMol *fragmentOnBonds( 59 const ROMol &mol, const std::vector<FragmenterBondType> &bondPatterns, 60 const std::map<unsigned int, ROMOL_SPTR> *atomEnvirons = nullptr, 61 std::vector<unsigned int> *nCutsPerAtom = nullptr); 62 RDKIT_CHEMTRANSFORMS_EXPORT void fragmentOnSomeBonds( 63 const ROMol &mol, const std::vector<unsigned int> &bondIndices, 64 std::vector<ROMOL_SPTR> &resMols, unsigned int maxToCut = 1, 65 bool addDummies = true, 66 const std::vector<std::pair<unsigned int, unsigned int>> *dummyLabels = 67 nullptr, 68 const std::vector<Bond::BondType> *bondTypes = nullptr, 69 std::vector<std::vector<unsigned int>> *nCutsPerAtom = nullptr); 70 71 //! \brief Fragments a molecule by breaking all BRICS bonds 72 /*! 73 \return a new ROMol with the modifications 74 The client is responsible for deleting this molecule. 75 76 */ 77 RDKIT_CHEMTRANSFORMS_EXPORT ROMol *fragmentOnBRICSBonds(const ROMol &mol); 78 79 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterAtomTypes( 80 std::istream *inStream, std::map<unsigned int, std::string> &defs, 81 const std::string &comment = "//", bool validate = true, 82 std::map<unsigned int, ROMOL_SPTR> *environs = nullptr); 83 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterAtomTypes( 84 const std::string &str, 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 constructBRICSAtomTypes( 88 std::map<unsigned int, std::string> &defs, 89 std::map<unsigned int, ROMOL_SPTR> *environs = nullptr); 90 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterBondTypes( 91 std::istream *inStream, 92 const std::map<unsigned int, std::string> &atomTypes, 93 std::vector<FragmenterBondType> &defs, const std::string &comment = "//", 94 bool validate = true, bool labelByConnector = true); 95 RDKIT_CHEMTRANSFORMS_EXPORT void constructFragmenterBondTypes( 96 const std::string &str, 97 const std::map<unsigned int, std::string> &atomTypes, 98 std::vector<FragmenterBondType> &defs, const std::string &comment = "//", 99 bool validate = true, bool labelByConnector = true); 100 RDKIT_CHEMTRANSFORMS_EXPORT void constructBRICSBondTypes( 101 std::vector<FragmenterBondType> &defs); 102 } // namespace MolFragmenter 103 104 105 enum class RDKIT_CHEMTRANSFORMS_EXPORT MolzipLabel { 106 AtomMapNumber, 107 Isotope, 108 FragmentOnBonds, 109 AtomType }; 110 111 struct RDKIT_CHEMTRANSFORMS_EXPORT MolzipParams { 112 MolzipLabel label = MolzipLabel::AtomMapNumber; 113 std::vector<std::string> atomSymbols; 114 }; 115 116 RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr<ROMol> molzip( 117 const ROMol &a, const ROMol &b, 118 const MolzipParams ¶ms=MolzipParams()); 119 120 RDKIT_CHEMTRANSFORMS_EXPORT std::unique_ptr<ROMol> molzip(const ROMol &a, 121 const MolzipParams ¶ms=MolzipParams()); 122 123 124 } // namespace RDKit 125 #endif 126