RDKit
Open-source cheminformatics and machine learning.
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>
20#include <boost/core/noncopyable.hpp>
22
23#include <GraphMol/RDKitBase.h>
24#include <GraphMol/MolOps.h>
25#include <GraphMol/MolBundle.h>
28
29namespace RDKit {
30namespace GeneralizedSubstruct {
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>;
42 std::unique_ptr<std::vector<std::unique_ptr<TautomerQuery>>>;
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)) {}
50 std::unique_ptr<std::vector<std::unique_ptr<TautomerQuery>>> tqs)
51 : xqmol(std::move(tqs)) {}
52 ExtendedQueryMol(const ExtendedQueryMol &other) { initFromOther(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
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*/
100 const RWMol &mol, bool doEnumeration = true, bool doTautomers = true,
101 bool adjustQueryProperties = false,
103
104//! does a substructure search with an ExtendedQueryMol
106 const ROMol &mol, const ExtendedQueryMol &query,
108
109//! Fingerprints a target molecule
110RDKIT_GENERALIZEDSUBSTRUCT_EXPORT std::unique_ptr<ExplicitBitVect>
111patternFingerprintTargetMol(const ROMol &mol, unsigned int fpSize = 2048U);
112
113//! checks if a molecule has a match to an ExtendedQueryMol
115 const ROMol &mol, const ExtendedQueryMol &query,
119 return !SubstructMatch(mol, query, lparams).empty();
120}
121} // namespace GeneralizedSubstruct
122} // namespace RDKit
123#endif
Defines a class for managing bundles of molecules.
pulls in the core RDKit functionality
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
#define RDKIT_GENERALIZEDSUBSTRUCT_EXPORT
Definition export.h:217
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT std::vector< MatchVectType > SubstructMatch(const ROMol &mol, const ExtendedQueryMol &query, const SubstructMatchParameters &params=SubstructMatchParameters())
does a substructure search with an ExtendedQueryMol
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_EXPORT std::unique_ptr< ExplicitBitVect > patternFingerprintTargetMol(const ROMol &mol, unsigned int fpSize=2048U)
Fingerprints a target molecule.
bool hasSubstructMatch(const ROMol &mol, const ExtendedQueryMol &query, const SubstructMatchParameters &params=SubstructMatchParameters())
checks if a molecule has a match to an ExtendedQueryMol
Definition XQMol.h:114
Std stuff.
bool rdvalue_is(const RDValue_cast_t)
ExtendedQueryMol(const ExtendedQueryMol &other)
Definition XQMol.h:52
ExtendedQueryMol & operator=(const ExtendedQueryMol &other)
Definition XQMol.h:53
std::unique_ptr< TautomerQuery > TautomerQuery_T
Definition XQMol.h:40
ExtendedQueryMol(std::unique_ptr< std::vector< std::unique_ptr< TautomerQuery > > > tqs)
Definition XQMol.h:49
ExtendedQueryMol(ExtendedQueryMol &&o) noexcept
Definition XQMol.h:61
void initFromBinary(const std::string &pkl)
std::unique_ptr< ExplicitBitVect > patternFingerprintQuery(unsigned int fpSize=2048U) const
std::unique_ptr< RWMol > RWMol_T
Definition XQMol.h:38
ExtendedQueryMol(std::unique_ptr< RWMol > mol)
Definition XQMol.h:45
std::unique_ptr< std::vector< std::unique_ptr< TautomerQuery > > > TautomerBundle_T
Definition XQMol.h:41
ExtendedQueryMol(std::unique_ptr< TautomerQuery > tq)
Definition XQMol.h:48
std::unique_ptr< MolBundle > MolBundle_T
Definition XQMol.h:39
void initFromJSON(const std::string &text)
ExtendedQueryMol(std::unique_ptr< MolBundle > bundle)
Definition XQMol.h:46
void initFromOther(const ExtendedQueryMol &other)
std::variant< RWMol_T, MolBundle_T, TautomerQuery_T, TautomerBundle_T > ContainedType
Definition XQMol.h:43
ExtendedQueryMol(const std::string &text, bool isJSON=false)
Parameters controlling the behavior of MolOps::adjustQueryProperties.
Definition MolOps.h:344
unsigned int maxMatches
maximum number of matches to return