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