RDKit
Open-source cheminformatics and machine learning.
Toggle main menu visibility
Loading...
Searching...
No Matches
XQMol.h
Go to the documentation of this file.
1
//
2
// Copyright (c) 2023, Greg Landrum 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
//
11
#include <
RDGeneral/export.h
>
12
#ifndef XQMOL_H_MAY2023
13
#define XQMOL_H_MAY2023
14
15
#include <variant>
16
#include <memory>
17
#include <string>
18
#include <vector>
19
#include <
RDGeneral/BoostStartInclude.h
>
20
#include <boost/core/noncopyable.hpp>
21
#include <
RDGeneral/BoostEndInclude.h
>
22
23
#include <
GraphMol/RDKitBase.h
>
24
#include <
GraphMol/MolOps.h
>
25
#include <
GraphMol/MolBundle.h
>
26
#include <
GraphMol/TautomerQuery/TautomerQuery.h
>
27
#include <
GraphMol/Substruct/SubstructMatch.h
>
28
29
namespace
RDKit
{
30
namespace
GeneralizedSubstruct
{
31
struct
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
ExtendedQueryMol
{
32
enum
ExtendedQueryMolTypes
:
unsigned
char
{
33
XQM_MOL
= 1,
34
XQM_MOLBUNDLE
= 2,
35
XQM_TAUTOMERQUERY
= 3,
36
XQM_TAUTOMERBUNDLE
= 4
37
};
38
using
RWMol_T
= std::unique_ptr<RWMol>;
39
using
MolBundle_T
= std::unique_ptr<MolBundle>;
40
using
TautomerQuery_T
= std::unique_ptr<TautomerQuery>;
41
using
TautomerBundle_T
=
42
std::unique_ptr<std::vector<std::unique_ptr<TautomerQuery>>>;
43
using
ContainedType
=
44
std::variant<RWMol_T, MolBundle_T, TautomerQuery_T, TautomerBundle_T>;
45
ExtendedQueryMol
(std::unique_ptr<RWMol> mol) :
xqmol
(std::move(mol)) {}
46
ExtendedQueryMol
(std::unique_ptr<MolBundle> bundle)
47
:
xqmol
(std::move(bundle)) {}
48
ExtendedQueryMol
(std::unique_ptr<TautomerQuery> tq) :
xqmol
(std::move(tq)) {}
49
ExtendedQueryMol
(
50
std::unique_ptr<std::vector<std::unique_ptr<TautomerQuery>>> tqs)
51
:
xqmol
(std::move(tqs)) {}
52
ExtendedQueryMol
(
const
ExtendedQueryMol
&other) {
initFromOther
(other); }
53
ExtendedQueryMol
&
operator=
(
const
ExtendedQueryMol
&other) {
54
if
(
this
== &other) {
55
return
*
this
;
56
}
57
initFromOther
(other);
58
return
*
this
;
59
}
60
61
ExtendedQueryMol
(
ExtendedQueryMol
&&o) noexcept :
xqmol
(std::move(o.xqmol)) {}
62
ExtendedQueryMol
(
const
std::string &text,
bool
isJSON =
false
);
63
64
void
initFromBinary
(
const
std::string &pkl);
65
void
initFromJSON
(
const
std::string &text);
66
void
initFromOther
(
const
ExtendedQueryMol
&other);
67
68
ContainedType
xqmol
;
69
std::string
toBinary
()
const
;
70
std::string
toJSON
()
const
;
71
72
// Query fingerprint
73
std::unique_ptr<ExplicitBitVect>
patternFingerprintQuery
(
74
unsigned
int
fpSize = 2048U)
const
;
75
};
76
77
//! Creates an ExtendedQueryMol from the input molecule
78
/*!
79
This takes a query molecule and, conceptually, performs the following steps to
80
produce an ExtendedQueryMol:
81
82
1. Enumerates features like Link Nodes and SRUs
83
2. Converts everything into TautomerQueries
84
3. Runs adjustQueryProperties()
85
86
Each step is optional
87
88
\param mol the molecule to start with
89
\param doEnumeration enumerate features like Link Nodes and SRUs
90
\param doTautomers generate TautomerQueries
91
\param adjustQueryProperties call adjustQueryProperties on each of the
92
results
93
\param params AdjustQueryParameters object controlling the operation of
94
adjustQueryProperties
95
96
\return The new ExtendedQueryMol
97
98
*/
99
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
ExtendedQueryMol
createExtendedQueryMol
(
100
const
RWMol
&mol,
bool
doEnumeration =
true
,
bool
doTautomers =
true
,
101
bool
adjustQueryProperties =
false
,
102
MolOps::AdjustQueryParameters
params = {});
103
104
//! does a substructure search with an ExtendedQueryMol
105
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
std::vector<MatchVectType>
SubstructMatch
(
106
const
ROMol
&mol,
const
ExtendedQueryMol
&query,
107
const
SubstructMatchParameters
¶ms =
SubstructMatchParameters
());
108
109
//! Fingerprints a target molecule
110
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
std::unique_ptr<ExplicitBitVect>
111
patternFingerprintTargetMol
(
const
ROMol
&mol,
unsigned
int
fpSize = 2048U);
112
113
//! checks if a molecule has a match to an ExtendedQueryMol
114
inline
bool
hasSubstructMatch
(
115
const
ROMol
&mol,
const
ExtendedQueryMol
&query,
116
const
SubstructMatchParameters
¶ms =
SubstructMatchParameters
()) {
117
SubstructMatchParameters
lparams = params;
118
lparams.
maxMatches
= 1;
119
return
!
SubstructMatch
(mol, query, lparams).empty();
120
}
121
}
// namespace GeneralizedSubstruct
122
}
// namespace RDKit
123
#endif
BoostEndInclude.h
BoostStartInclude.h
MolBundle.h
Defines a class for managing bundles of molecules.
MolOps.h
RDKitBase.h
pulls in the core RDKit functionality
SubstructMatch.h
TautomerQuery.h
RDKit::ROMol
Definition
ROMol.h:344
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition
RWMol.h:32
export.h
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
#define RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
Definition
export.h:301
RDKit::GeneralizedSubstruct
Definition
XQMol.h:30
RDKit::GeneralizedSubstruct::SubstructMatch
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT std::vector< MatchVectType > SubstructMatch(const ROMol &mol, const ExtendedQueryMol &query, const SubstructMatchParameters ¶ms=SubstructMatchParameters())
does a substructure search with an ExtendedQueryMol
RDKit::GeneralizedSubstruct::createExtendedQueryMol
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT ExtendedQueryMol createExtendedQueryMol(const RWMol &mol, bool doEnumeration=true, bool doTautomers=true, bool adjustQueryProperties=false, MolOps::AdjustQueryParameters params={})
Creates an ExtendedQueryMol from the input molecule.
RDKit::GeneralizedSubstruct::patternFingerprintTargetMol
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT std::unique_ptr< ExplicitBitVect > patternFingerprintTargetMol(const ROMol &mol, unsigned int fpSize=2048U)
Fingerprints a target molecule.
RDKit::GeneralizedSubstruct::hasSubstructMatch
bool hasSubstructMatch(const ROMol &mol, const ExtendedQueryMol &query, const SubstructMatchParameters ¶ms=SubstructMatchParameters())
checks if a molecule has a match to an ExtendedQueryMol
Definition
XQMol.h:114
RDKit
Std stuff.
Definition
Abbreviations.h:19
RDKit::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(std::unique_ptr< RWMol > mol)
Definition
XQMol.h:45
RDKit::GeneralizedSubstruct::ExtendedQueryMol
Definition
XQMol.h:31
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(const ExtendedQueryMol &other)
Definition
XQMol.h:52
RDKit::GeneralizedSubstruct::ExtendedQueryMol::operator=
ExtendedQueryMol & operator=(const ExtendedQueryMol &other)
Definition
XQMol.h:53
RDKit::GeneralizedSubstruct::ExtendedQueryMol::TautomerQuery_T
std::unique_ptr< TautomerQuery > TautomerQuery_T
Definition
XQMol.h:40
RDKit::GeneralizedSubstruct::ExtendedQueryMol::toJSON
std::string toJSON() const
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(std::unique_ptr< std::vector< std::unique_ptr< TautomerQuery > > > tqs)
Definition
XQMol.h:49
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ContainedType
std::variant< RWMol_T, MolBundle_T, TautomerQuery_T, TautomerBundle_T > ContainedType
Definition
XQMol.h:43
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(ExtendedQueryMol &&o) noexcept
Definition
XQMol.h:61
RDKit::GeneralizedSubstruct::ExtendedQueryMol::xqmol
ContainedType xqmol
Definition
XQMol.h:68
RDKit::GeneralizedSubstruct::ExtendedQueryMol::initFromBinary
void initFromBinary(const std::string &pkl)
RDKit::GeneralizedSubstruct::ExtendedQueryMol::patternFingerprintQuery
std::unique_ptr< ExplicitBitVect > patternFingerprintQuery(unsigned int fpSize=2048U) const
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMolTypes
ExtendedQueryMolTypes
Definition
XQMol.h:32
RDKit::GeneralizedSubstruct::ExtendedQueryMol::XQM_TAUTOMERQUERY
@ XQM_TAUTOMERQUERY
Definition
XQMol.h:35
RDKit::GeneralizedSubstruct::ExtendedQueryMol::XQM_MOL
@ XQM_MOL
Definition
XQMol.h:33
RDKit::GeneralizedSubstruct::ExtendedQueryMol::XQM_MOLBUNDLE
@ XQM_MOLBUNDLE
Definition
XQMol.h:34
RDKit::GeneralizedSubstruct::ExtendedQueryMol::XQM_TAUTOMERBUNDLE
@ XQM_TAUTOMERBUNDLE
Definition
XQMol.h:36
RDKit::GeneralizedSubstruct::ExtendedQueryMol::RWMol_T
std::unique_ptr< RWMol > RWMol_T
Definition
XQMol.h:38
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(std::unique_ptr< RWMol > mol)
Definition
XQMol.h:45
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(std::unique_ptr< TautomerQuery > tq)
Definition
XQMol.h:48
RDKit::GeneralizedSubstruct::ExtendedQueryMol::MolBundle_T
std::unique_ptr< MolBundle > MolBundle_T
Definition
XQMol.h:39
RDKit::GeneralizedSubstruct::ExtendedQueryMol::TautomerBundle_T
std::unique_ptr< std::vector< std::unique_ptr< TautomerQuery > > > TautomerBundle_T
Definition
XQMol.h:41
RDKit::GeneralizedSubstruct::ExtendedQueryMol::initFromJSON
void initFromJSON(const std::string &text)
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(std::unique_ptr< MolBundle > bundle)
Definition
XQMol.h:46
RDKit::GeneralizedSubstruct::ExtendedQueryMol::toBinary
std::string toBinary() const
RDKit::GeneralizedSubstruct::ExtendedQueryMol::initFromOther
void initFromOther(const ExtendedQueryMol &other)
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMol
ExtendedQueryMol(const std::string &text, bool isJSON=false)
RDKit::MolOps::AdjustQueryParameters
Parameters controlling the behavior of MolOps::adjustQueryProperties.
Definition
MolOps.h:417
RDKit::SubstructMatchParameters
Definition
SubstructMatch.h:42
RDKit::SubstructMatchParameters::maxMatches
unsigned int maxMatches
maximum number of matches to return
Definition
SubstructMatch.h:55
GraphMol
GeneralizedSubstruct
XQMol.h
Generated on
for RDKit by
1.17.0