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