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.
27inline constexpr unsigned int PATT_FP_NUM_BITS = 1024;
28
29// This class holds a Synthon that will be part of a SynthonSet.
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
void writeToDBStream(std::ostream &os) const
Synthon & operator=(const Synthon &other)
const std::unique_ptr< ExplicitBitVect > & getPattFP() const
Synthon(const Synthon &other)
const std::unique_ptr< ExplicitBitVect > & getFP() const
unsigned int getNumHeavyAtoms() const
Definition Synthon.h:48
const std::unique_ptr< ROMol > & getSearchMol() const
void readFromDBStream(std::istream &is, std::uint32_t version)
Synthon(const std::string &smi)
unsigned int getNumChiralAtomsExcDummies() const
Definition Synthon.h:50
unsigned int getNumDummies() const
Definition Synthon.h:47
const std::unique_ptr< ROMol > & getOrigMol() const
unsigned int getNumChiralAtoms() const
Definition Synthon.h:49
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:39
const std::vector< std::shared_ptr< ROMol > > & getConnRegions() const
#define RDKIT_SYNTHONSPACESEARCH_EXPORT
Definition export.h:545
constexpr unsigned int PATT_FP_NUM_BITS
Definition Synthon.h:27
Std stuff.