RDKit: Synthon.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
Synthon.h
Go to the documentation of this file.
1//
2// Copyright (C) David Cosgrove 2024.
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#ifndef RDKIT_REAGENT_H
12#define RDKIT_REAGENT_H
13
14#include <string>
15
16#include <RDGeneral/export.h>
17
18namespace RDKit {
19class Atom;
20class ROMol;
21class RWMol;
22
23namespace SynthonSpaceSearch {
24
25// These are the numbers of bits used in the internal fingerprints.
26// The user is not restricted to these numbers for the search.
27 inline constexpr unsigned int PATT_FP_NUM_BITS = 1024;
28
29// This class holds a Synthon that will be part of a SynthonSet.
30 class RDKIT_SYNTHONSPACESEARCH_EXPORT Synthon {
31 public:
32 Synthon() = default;
33 Synthon(const std::string &smi);
34 Synthon(const Synthon &other);
35 Synthon(Synthon &&other) = default;
36 Synthon &operator=(const Synthon &other);
37 Synthon &operator=(Synthon &&other) = default;
38
39 const std::string &getSmiles() const { return d_smiles; }
40 const std::unique_ptr<ROMol> &getOrigMol() const;
41 const std::unique_ptr<ROMol> &getSearchMol() const;
42 const std::unique_ptr<ExplicitBitVect> &getPattFP() const;
43 const std::unique_ptr<ExplicitBitVect> &getFP() const;
44 const std::vector<std::shared_ptr<ROMol>> &getConnRegions() const;
45 void setSearchMol(std::unique_ptr<ROMol> mol);
46 void setFP(std::unique_ptr<ExplicitBitVect> fp);
47 unsigned int getNumDummies() const { return d_numDummies; }
48 unsigned int getNumHeavyAtoms() const { return d_numHeavyAtoms; }
49 unsigned int getNumChiralAtoms() const { return d_numChiralAtoms; }
50 unsigned int getNumChiralAtomsExcDummies() const {
51 return d_numChiralAtomsExcDummies;
52 }
53 double getMolWt() const { return d_molWt; }
54
55 // Writes to/reads from a binary stream.
56 void writeToDBStream(std::ostream &os) const;
57 void readFromDBStream(std::istream &is, std::uint32_t version);
58
59 private:
60 std::string d_smiles;
61
62 // Keep 2 copies of the molecule. The first is as passed in, which
63 // will be used for building products. The second will have its
64 // atoms and bonds fiddled with to make them match the product (the
65 // aliphatic precursor to aromatic product issue). The search mol
66 // doesn't always work with product building.
67 std::unique_ptr<ROMol> dp_origMol{nullptr};
68 std::unique_ptr<ROMol> dp_searchMol{nullptr};
69 // The pattern fingerprint, used for substructure search screening.
70 std::unique_ptr<ExplicitBitVect> dp_pattFP{nullptr};
71 // The fingerprint of the dp_searchMol, used in fingerprint similarity
72 // searching. Its type is known by the SynthonSpace that holds the
73 // Synthon.
74 std::unique_ptr<ExplicitBitVect> dp_FP{nullptr};
75 // SMILES strings of any connector regions. Normally there will only
76 // be 1 or 2. These are derived from the search mol.
77 std::vector<std::shared_ptr<ROMol>> d_connRegions;
78
79 unsigned int d_numDummies{0};
80 unsigned int d_numHeavyAtoms{0};
81 // As calculated by details::countChiralAtoms().
82 unsigned int d_numChiralAtoms{0};
83 // This is the number of chiral atoms excluding those that have 2 or
84 // more dummies attached.
85 unsigned int d_numChiralAtomsExcDummies{0};
86 double d_molWt{0.0};
87
88 // Once the search molecule has been added, get the connector regions,
89 // connector fingerprint etc.
90 void finishInitialization();
91 // Calculate the number of dummy atoms etc.
92 void calcProperties();
93};
94
95} // namespace SynthonSpaceSearch
96} // namespace RDKit
97
98#endif // RDKIT_REAGENT_H
RDKit::Atom
The class for representing atoms.
Definition Atom.h:74
RDKit::ROMol
Definition ROMol.h:199
RDKit::RWMol
RWMol is a molecule class that is intended to be edited.
Definition RWMol.h:32
RDKit::SynthonSpaceSearch::Synthon::writeToDBStream
void writeToDBStream(std::ostream &os) const
RDKit::SynthonSpaceSearch::Synthon::operator=
Synthon & operator=(const Synthon &other)
RDKit::SynthonSpaceSearch::Synthon::getPattFP
const std::unique_ptr< ExplicitBitVect > & getPattFP() const
RDKit::SynthonSpaceSearch::Synthon::getMolWt
double getMolWt() const
Definition Synthon.h:53
RDKit::SynthonSpaceSearch::Synthon::Synthon
Synthon(const Synthon &other)
RDKit::SynthonSpaceSearch::Synthon::getFP
const std::unique_ptr< ExplicitBitVect > & getFP() const
RDKit::SynthonSpaceSearch::Synthon::getNumHeavyAtoms
unsigned int getNumHeavyAtoms() const
Definition Synthon.h:48
RDKit::SynthonSpaceSearch::Synthon::getSearchMol
const std::unique_ptr< ROMol > & getSearchMol() const
RDKit::SynthonSpaceSearch::Synthon::readFromDBStream
void readFromDBStream(std::istream &is, std::uint32_t version)
RDKit::SynthonSpaceSearch::Synthon::Synthon
Synthon(const std::string &smi)
RDKit::SynthonSpaceSearch::Synthon::getNumChiralAtomsExcDummies
unsigned int getNumChiralAtomsExcDummies() const
Definition Synthon.h:50
RDKit::SynthonSpaceSearch::Synthon::getNumDummies
unsigned int getNumDummies() const
Definition Synthon.h:47
RDKit::SynthonSpaceSearch::Synthon::getOrigMol
const std::unique_ptr< ROMol > & getOrigMol() const
RDKit::SynthonSpaceSearch::Synthon::getNumChiralAtoms
unsigned int getNumChiralAtoms() const
Definition Synthon.h:49
RDKit::SynthonSpaceSearch::Synthon::setFP
void setFP(std::unique_ptr< ExplicitBitVect > fp)
RDKit::SynthonSpaceSearch::Synthon::setSearchMol
void setSearchMol(std::unique_ptr< ROMol > mol)
RDKit::SynthonSpaceSearch::Synthon::operator=
Synthon & operator=(Synthon &&other)=default
RDKit::SynthonSpaceSearch::Synthon::Synthon
Synthon(Synthon &&other)=default
RDKit::SynthonSpaceSearch::Synthon::getSmiles
const std::string & getSmiles() const
Definition Synthon.h:39
RDKit::SynthonSpaceSearch::Synthon::getConnRegions
const std::vector< std::shared_ptr< ROMol > > & getConnRegions() const
RDKit::SynthonSpaceSearch::Synthon::Synthon
Synthon()=default
export.h
RDKIT_SYNTHONSPACESEARCH_EXPORT
#define RDKIT_SYNTHONSPACESEARCH_EXPORT
Definition export.h:577
RDKit::SynthonSpaceSearch
Definition MemoryMappedFileReader.h:19
RDKit::SynthonSpaceSearch::PATT_FP_NUM_BITS
constexpr unsigned int PATT_FP_NUM_BITS
Definition Synthon.h:27
RDKit
Std stuff.
Definition Abbreviations.h:19