RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
SynthonSpaceSearch_details.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_SYNTHONSPACESEARCHDETAILS_H
12#define RDKIT_SYNTHONSPACESEARCHDETAILS_H
13
14#include <vector>
15
16#include <RDGeneral/export.h>
17
18namespace RDKit {
19class ROMol;
20namespace SynthonSpaceSearch::details {
21
22// Find all combinations of M things selected from N.
23RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector<std::vector<unsigned int>>
24combMFromN(unsigned int m, unsigned int n);
25// Find all permutations of M things selected from N.
26RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector<std::vector<unsigned int>>
27permMFromN(unsigned int m, unsigned int n);
29 std::vector<std::unique_ptr<ROMol>> &molFrags);
30
31// Split the molecule into fragments. maxBondSplits gives the maximum number
32// of bonds to be used in each split. There will a vector of vectors of
33// molecules, 1 inner vector for each split i.e. maxBondSplits in total, the
34// first with 1 split, the 2nd with 2 etc. Each inner vector contains the
35// fragments from a split molecule. The maxBondSplits will be constrained to
36// between 1 and 4 inclusive, so if it is supplied outside that range, it will
37// be altered. Also, you can't split a molecule on 3 bonds if it only contains
38// 2.
39RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector<std::vector<std::unique_ptr<ROMol>>>
40splitMolecule(const ROMol &query, unsigned int maxBondSplits);
41// Counts the number of [1*], [2*]...[4*] in the string.
43
44// Return a bitset for each fragment giving the connector patterns
45RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector<boost::dynamic_bitset<>>
46getConnectorPatterns(const std::vector<std::unique_ptr<ROMol>> &fragSet);
47
48// Return a bitset giving the different connector types in this
49// molecule.
51 const std::vector<std::unique_ptr<ROMol>> &fragSet);
52
53// Return copies of the mol fragments will all permutations of the connectors
54// in the reaction onto the connectors in the fragments.
55// E.g. if the reaction has 3 connectors, 1, 2 and 3 and the fragged mol has
56// 2, return all permutations of 2 from 3. It's ok if the fragged mol doesn't
57// have all the connections in the reaction, although this may well result in
58// a lot of hits.
59RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector<std::vector<std::unique_ptr<ROMol>>>
60getConnectorPermutations(const std::vector<std::unique_ptr<ROMol>> &molFrags,
61 const boost::dynamic_bitset<> &fragConns,
62 const boost::dynamic_bitset<> &reactionConns);
63
64// If all bits in one of the bitsets is unset, it means that nothing matched
65// that synthon. If at least one of the bitsets has a set bit, all products
66// incorporating the synthon with no bits set must match the query so
67// should be used because the query matches products that don't incorporate
68// anything from 1 of the synthon lists. For example, if the synthons are
69// [1*]Nc1c([2*])cccc1 and [1*]=CC=C[2*] and the query is c1ccccc1.
71 std::vector<boost::dynamic_bitset<>> &bitSets);
72
73// class to step through all combinations of lists of different sizes.
74// returns (0,0,0), (0,0,1), (0,1,0) etc.
76 explicit Stepper(const std::vector<size_t> &sizes) : d_sizes(sizes) {
77 d_currState = std::vector<size_t>(sizes.size(), 0);
78 }
79 void step() {
80 // Don't do anything if we're at the end, but expect an infinite
81 // loop if the user isn't wise to this.
82 if (d_currState[0] == d_sizes[0]) {
83 return;
84 }
85 std::int64_t i = static_cast<std::int64_t>(d_currState.size()) - 1;
86 while (i >= 0) {
87 ++d_currState[i];
88 if (d_currState[0] == d_sizes[0]) {
89 return;
90 }
91 if (d_currState[i] == d_sizes[i]) {
92 d_currState[i] = 0;
93 } else {
94 break;
95 }
96 --i;
97 }
98 }
99 std::vector<size_t> d_currState;
100 std::vector<size_t> d_sizes;
101};
102
103} // namespace SynthonSpaceSearch::details
104} // namespace RDKit
105
106#endif // RDKIT_SYNTHONSPACESEARCHDETAILS_H
#define RDKIT_SYNTHONSPACESEARCH_EXPORT
Definition export.h:545
RDKIT_SYNTHONSPACESEARCH_EXPORT boost::dynamic_bitset getConnectorPattern(const std::vector< std::unique_ptr< ROMol > > &fragSet)
RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector< std::vector< unsigned int > > permMFromN(unsigned int m, unsigned int n)
RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector< boost::dynamic_bitset<> > getConnectorPatterns(const std::vector< std::unique_ptr< ROMol > > &fragSet)
RDKIT_SYNTHONSPACESEARCH_EXPORT void fixAromaticRingSplits(std::vector< std::unique_ptr< ROMol > > &molFrags)
RDKIT_SYNTHONSPACESEARCH_EXPORT int countConnections(const ROMol &frag)
RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector< std::vector< unsigned int > > combMFromN(unsigned int m, unsigned int n)
RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector< std::vector< std::unique_ptr< ROMol > > > splitMolecule(const ROMol &query, unsigned int maxBondSplits)
RDKIT_SYNTHONSPACESEARCH_EXPORT void expandBitSet(std::vector< boost::dynamic_bitset<> > &bitSets)
RDKIT_SYNTHONSPACESEARCH_EXPORT std::vector< std::vector< std::unique_ptr< ROMol > > > getConnectorPermutations(const std::vector< std::unique_ptr< ROMol > > &molFrags, const boost::dynamic_bitset<> &fragConns, const boost::dynamic_bitset<> &reactionConns)
Std stuff.
bool rdvalue_is(const RDValue_cast_t)