Loading...
Searching...
No Matches
XQMol.h
Go to the documentation of this file.
//
// Copyright (c) 2023, Greg Landrum and other RDKit contributors
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
//
#include <RDGeneral/export.h>
#ifndef XQMOL_H_MAY2023
#define XQMOL_H_MAY2023
#include <variant>
#include <memory>
#include <string>
#include <vector>
#include <RDGeneral/BoostStartInclude.h>
#include <boost/core/noncopyable.hpp>
#include <RDGeneral/BoostEndInclude.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/MolOps.h>
#include <GraphMol/MolBundle.h>
#include <GraphMol/TautomerQuery/TautomerQuery.h>
#include <GraphMol/Substruct/SubstructMatch.h>
namespace RDKit {
namespace GeneralizedSubstruct {
struct RDKIT_GENERALIZEDSUBSTRUCT_EXPORT ExtendedQueryMol {
enum ExtendedQueryMolTypes : unsigned char {
XQM_MOL = 1,
XQM_MOLBUNDLE = 2,
XQM_TAUTOMERQUERY = 3,
XQM_TAUTOMERBUNDLE = 4
};
using RWMol_T = std::unique_ptr<RWMol>;
using MolBundle_T = std::unique_ptr<MolBundle>;
using TautomerQuery_T = std::unique_ptr<TautomerQuery>;
using TautomerBundle_T =
std::unique_ptr<std::vector<std::unique_ptr<TautomerQuery>>>;
using ContainedType =
std::variant<RWMol_T, MolBundle_T, TautomerQuery_T, TautomerBundle_T>;
ExtendedQueryMol(std::unique_ptr<RWMol> mol) : xqmol(std::move(mol)) {}
ExtendedQueryMol(std::unique_ptr<MolBundle> bundle)
: xqmol(std::move(bundle)) {}
ExtendedQueryMol(std::unique_ptr<TautomerQuery> tq) : xqmol(std::move(tq)) {}
ExtendedQueryMol(
std::unique_ptr<std::vector<std::unique_ptr<TautomerQuery>>> tqs)
: xqmol(std::move(tqs)) {}
ExtendedQueryMol(const ExtendedQueryMol &other) { initFromOther(other); }
ExtendedQueryMol &operator=(const ExtendedQueryMol &other) {
if (this == &other) {
return *this;
}
initFromOther(other);
return *this;
}
ExtendedQueryMol(ExtendedQueryMol &&o) noexcept : xqmol(std::move(o.xqmol)) {}
ExtendedQueryMol(const std::string &text, bool isJSON = false);
void initFromBinary(const std::string &pkl);
void initFromJSON(const std::string &text);
void initFromOther(const ExtendedQueryMol &other);
ContainedType xqmol;
std::string toBinary() const;
std::string toJSON() const;
// Query fingerprint
std::unique_ptr<ExplicitBitVect> patternFingerprintQuery(
unsigned int fpSize = 2048U) const;
};
//! Creates an ExtendedQueryMol from the input molecule
/*!
This takes a query molecule and, conceptually, performs the following steps to
produce an ExtendedQueryMol:
1. Enumerates features like Link Nodes and SRUs
2. Converts everything into TautomerQueries
3. Runs adjustQueryProperties()
Each step is optional
\param mol the molecule to start with
\param doEnumeration enumerate features like Link Nodes and SRUs
\param doTautomers generate TautomerQueries
\param adjustQueryProperties call adjustQueryProperties on each of the
results
\param params AdjustQueryParameters object controlling the operation of
adjustQueryProperties
\return The new ExtendedQueryMol
*/
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT ExtendedQueryMol createExtendedQueryMol(
const RWMol &mol, bool doEnumeration = true, bool doTautomers = true,
bool adjustQueryProperties = false,
MolOps::AdjustQueryParameters params = {});
//! does a substructure search with an ExtendedQueryMol
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT std::vector<MatchVectType> SubstructMatch(
const ROMol &mol, const ExtendedQueryMol &query,
const SubstructMatchParameters &params = SubstructMatchParameters());
//! Fingerprints a target molecule
RDKIT_GENERALIZEDSUBSTRUCT_EXPORT std::unique_ptr<ExplicitBitVect>
patternFingerprintTargetMol(const ROMol &mol, unsigned int fpSize = 2048U);
//! checks if a molecule has a match to an ExtendedQueryMol
inline bool hasSubstructMatch(
const ROMol &mol, const ExtendedQueryMol &query,
const SubstructMatchParameters &params = SubstructMatchParameters()) {
SubstructMatchParameters lparams = params;
lparams.maxMatches = 1;
return !SubstructMatch(mol, query, lparams).empty();
}
} // namespace GeneralizedSubstruct
} // namespace RDKit
#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:199
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:217
RDKit::GeneralizedSubstruct::SubstructMatch
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::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 &params=SubstructMatchParameters())
checks if a molecule has a match to an ExtendedQueryMol
Definition XQMol.h:114
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::rdvalue_is
bool rdvalue_is(const RDValue_cast_t)
Definition RDValue-doublemagic.h:372
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::ExtendedQueryMol
ExtendedQueryMol(ExtendedQueryMol &&o) noexcept
Definition XQMol.h:61
RDKit::GeneralizedSubstruct::ExtendedQueryMol::TautomerBundle_T
std::unique_ptr< std::vector< std::unique_ptr< TautomerQuery > > > TautomerBundle_T
Definition XQMol.h:42
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::ContainedType
std::variant< RWMol_T, MolBundle_T, TautomerQuery_T, TautomerBundle_T > ContainedType
Definition XQMol.h:44
RDKit::GeneralizedSubstruct::ExtendedQueryMol::ExtendedQueryMolTypes
ExtendedQueryMolTypes
Definition XQMol.h:32
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::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:392
RDKit::SubstructMatchParameters
Definition SubstructMatch.h:41
RDKit::SubstructMatchParameters::maxMatches
unsigned int maxMatches
maximum number of matches to return
Definition SubstructMatch.h:54