RDKit
Open-source cheminformatics and machine learning.
TautomerQuery.h
Go to the documentation of this file.
1//
2// Created by Gareth Jones on 5/7/2020.
3//
4// Copyright 2020 Schrodinger, Inc
5// @@ All Rights Reserved @@
6// This file is part of the RDKit.
7// The contents are covered by the terms of the BSD license
8// which is included in the file license.txt, found at the root
9// of the RDKit source tree.
10
11#include <RDGeneral/export.h>
12
13#ifndef RDKIT_TAUTOMERQUERY_H
14#define RDKIT_TAUTOMERQUERY_H
15
16#include <GraphMol/ROMol.h>
17#include <vector>
20
21namespace RDKit {
22
23class RWMol;
24
26 private:
27 // Tautomers of the query
28 std::vector<ROMOL_SPTR> d_tautomers;
29 // Template query for substructure search
30 std::unique_ptr<const ROMol> d_templateMolecule;
31 // Tautomeric bonds and atoms
32 const std::vector<size_t> d_modifiedAtoms;
33 const std::vector<size_t> d_modifiedBonds;
34
35 // tests if a match to the template matches a specific tautomer
36 bool matchTautomer(const ROMol &mol, const ROMol &tautomer,
37 const std::vector<unsigned int> &match,
38 const SubstructMatchParameters &params) const;
39
40 public:
41 TautomerQuery(std::vector<ROMOL_SPTR> tautomers,
42 const ROMol *const templateMolecule,
43 std::vector<size_t> modifiedAtoms,
44 std::vector<size_t> modifiedBonds);
45
46 //! Copy constructor performs a deep copy
48 : d_templateMolecule(other.d_templateMolecule
49 ? new ROMol(*other.d_templateMolecule)
50 : nullptr),
51 d_modifiedAtoms(other.d_modifiedAtoms),
52 d_modifiedBonds(other.d_modifiedBonds) {
53 PRECONDITION(other.d_templateMolecule != nullptr, "Null template");
54 for (auto taut : other.d_tautomers) {
55 PRECONDITION(taut.get() != nullptr, "Null tautomer");
56 d_tautomers.push_back(boost::make_shared<ROMol>(*taut));
57 }
58 }
59
60 // Factory to build TautomerQuery
61 // Caller owns the memory
63 const ROMol &molecule,
64 const std::string &tautomerTransformFile = std::string());
65
66 // Substructure search
67 std::vector<MatchVectType> substructOf(
68 const ROMol &mol,
70 std::vector<ROMOL_SPTR> *matchingTautomers = nullptr) const;
71
72 // SubstructureMatch
73 bool isSubstructOf(const ROMol &mol, const SubstructMatchParameters &params =
75
76 // Query fingerprint
78 unsigned int fpSize = 2048U) const;
79 // Static method to Fingerprint a target
81 unsigned int fpSize = 2048U);
82
83 // accessors
84
85 // pointer is owned by TautomerQuery
86 const ROMol &getTemplateMolecule() const { return *d_templateMolecule; }
87
88 const std::vector<ROMOL_SPTR> getTautomers() const { return d_tautomers; }
89
90 const std::vector<size_t> getModifiedAtoms() const { return d_modifiedAtoms; }
91
92 const std::vector<size_t> getModifiedBonds() const { return d_modifiedBonds; }
93
94 friend class TautomerQueryMatcher;
95};
96
97// so we can use the templates in Code/GraphMol/Substruct/SubstructMatch.h
98RDKIT_TAUTOMERQUERY_EXPORT std::vector<MatchVectType> SubstructMatch(
99 const ROMol &mol, const TautomerQuery &query,
100 const SubstructMatchParameters &params);
101
102} // namespace RDKit
103
104#endif // RDKIT_TAUTOMERQUERY_H
#define PRECONDITION(expr, mess)
Definition: Invariant.h:109
Defines the primary molecule class ROMol as well as associated typedefs.
a class for bit vectors that are densely occupied
ExplicitBitVect * patternFingerprintTemplate(unsigned int fpSize=2048U) const
TautomerQuery(const TautomerQuery &other)
Copy constructor performs a deep copy.
Definition: TautomerQuery.h:47
const std::vector< size_t > getModifiedAtoms() const
Definition: TautomerQuery.h:90
const ROMol & getTemplateMolecule() const
Definition: TautomerQuery.h:86
const std::vector< size_t > getModifiedBonds() const
Definition: TautomerQuery.h:92
bool isSubstructOf(const ROMol &mol, const SubstructMatchParameters &params=SubstructMatchParameters())
const std::vector< ROMOL_SPTR > getTautomers() const
Definition: TautomerQuery.h:88
TautomerQuery(std::vector< ROMOL_SPTR > tautomers, const ROMol *const templateMolecule, std::vector< size_t > modifiedAtoms, std::vector< size_t > modifiedBonds)
static ExplicitBitVect * patternFingerprintTarget(const ROMol &target, unsigned int fpSize=2048U)
static TautomerQuery * fromMol(const ROMol &molecule, const std::string &tautomerTransformFile=std::string())
std::vector< MatchVectType > substructOf(const ROMol &mol, const SubstructMatchParameters &params=SubstructMatchParameters(), std::vector< ROMOL_SPTR > *matchingTautomers=nullptr) const
#define RDKIT_TAUTOMERQUERY_EXPORT
Definition: export.h:489
Std stuff.
Definition: Abbreviations.h:18
RDKIT_SUBSTRUCTMATCH_EXPORT std::vector< MatchVectType > SubstructMatch(const ROMol &mol, const ROMol &query, const SubstructMatchParameters &params=SubstructMatchParameters())
Find a substructure match for a query in a molecule.