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
73//! Creates an ExtendedQueryMol from the input molecule
74/*!
75 This takes a query molecule and, conceptually, performs the following steps to
76 produce an ExtendedQueryMol:
77
78 1. Enumerates features like Link Nodes and SRUs
79 2. Converts everything into TautomerQueries
80 3. Runs adjustQueryProperties()
81
82 Each step is optional
83
84 \param mol the molecule to start with
85 \param doEnumeration enumerate features like Link Nodes and SRUs
86 \param doTautomers generate TautomerQueries
87 \param adjustQueryProperties call adjustQueryProperties on each of the
88 results
89 \param params AdjustQueryParameters object controlling the operation of
90 adjustQueryProperties
91
92 \return The new ExtendedQueryMol
93
94*/
96 const RWMol &mol, bool doEnumeration = true, bool doTautomers = true,
97 bool adjustQueryProperties = false,
99
100//! does a substructure search with an ExtendedQueryMol
102 const ROMol &mol, const ExtendedQueryMol &query,
104
105//! checks if a molecule has a match to an ExtendedQueryMol
107 const ROMol &mol, const ExtendedQueryMol &query,
111 return !SubstructMatch(mol, query, lparams).empty();
112}
113} // namespace GeneralizedSubstruct
114} // namespace RDKit
115#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.
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:106
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
std::unique_ptr< std::vector< std::unique_ptr< TautomerQuery > > > TautomerBundle_T
Definition XQMol.h:42
void initFromBinary(const std::string &pkl)
std::variant< RWMol_T, MolBundle_T, TautomerQuery_T, TautomerBundle_T > ContainedType
Definition XQMol.h:44
std::unique_ptr< RWMol > RWMol_T
Definition XQMol.h:38
ExtendedQueryMol(std::unique_ptr< RWMol > mol)
Definition XQMol.h:45
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)
ExtendedQueryMol(const std::string &text, bool isJSON=false)
Parameters controlling the behavior of MolOps::adjustQueryProperties.
Definition MolOps.h:343
unsigned int maxMatches
maximum number of matches to return