RDKit
Open-source cheminformatics and machine learning.
Subgraphs.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2003-2008 Greg Landrum and Rational Discovery LLC
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 /*! \file Subgraphs.h
12 
13  \brief functionality for finding subgraphs and paths in molecules
14 
15  Difference between _subgraphs_ and _paths_ :
16  Subgraphs are potentially branched, whereas paths (in our
17  terminology at least) cannot be. So, the following graph:
18 \verbatim
19  C--0--C--1--C--3--C
20  |
21  2
22  |
23  C
24 \endverbatim
25  has 3 _subgraphs_ of length 3: (0,1,2),(0,1,3),(2,1,3)
26  but only 2 _paths_ of length 3: (0,1,3),(2,1,3)
27 */
28 #include <RDGeneral/export.h>
29 #ifndef _RD_SUBGRAPHS_H_
30 #define _RD_SUBGRAPHS_H_
31 
32 #include <vector>
33 #include <list>
34 #include <map>
35 
36 namespace RDKit {
37 class ROMol;
38 // NOTE: before replacing the defn of PATH_TYPE: be aware that
39 // we do occasionally use reverse iterators on these things, so
40 // replacing with a slist would probably be a bad idea.
41 typedef std::vector<int> PATH_TYPE;
42 typedef std::list<PATH_TYPE> PATH_LIST;
43 typedef PATH_LIST::const_iterator PATH_LIST_CI;
44 
45 typedef std::map<int, PATH_LIST> INT_PATH_LIST_MAP;
46 typedef INT_PATH_LIST_MAP::const_iterator INT_PATH_LIST_MAP_CI;
47 typedef INT_PATH_LIST_MAP::iterator INT_PATH_LIST_MAP_I;
48 
49 // --- --- --- --- --- --- --- --- --- --- --- --- ---
50 //
51 //
52 // --- --- --- --- --- --- --- --- --- --- --- --- ---
53 
54 //! \brief find all bond subgraphs in a range of sizes
55 /*!
56  * \param mol - the molecule to be considered
57  * \param lowerLen - the minimum subgraph size to find
58  * \param upperLen - the maximum subgraph size to find
59  * \param useHs - if set, hydrogens in the graph will be considered
60  * eligible to be in paths. NOTE: this will not add
61  * Hs to the graph.
62  * \param rootedAtAtom - if non-negative, only subgraphs that start at
63  * this atom will be returned.
64  *
65  * The result is a map from subgraph size -> list of paths
66  * (i.e. list of list of bond indices)
67  */
69  const ROMol &mol, unsigned int lowerLen, unsigned int upperLen,
70  bool useHs = false, int rootedAtAtom = -1);
71 
72 //! \brief find all bond subgraphs of a particular size
73 /*!
74  * \param mol - the molecule to be considered
75  * \param targetLen - the length of the subgraphs to be returned
76  * \param useHs - if set, hydrogens in the graph will be considered
77  * eligible to be in paths. NOTE: this will not add
78  * Hs to the graph.
79  * \param rootedAtAtom - if non-negative, only subgraphs that start at
80  * this atom will be returned.
81  *
82  *
83  * The result is a list of paths (i.e. list of list of bond indices)
84  */
86 findAllSubgraphsOfLengthN(const ROMol &mol, unsigned int targetLen,
87  bool useHs = false, int rootedAtAtom = -1);
88 
89 //! \brief find unique bond subgraphs of a particular size
90 /*!
91  * \param mol - the molecule to be considered
92  * \param targetLen - the length of the subgraphs to be returned
93  * \param useHs - if set, hydrogens in the graph will be considered
94  * eligible to be in paths. NOTE: this will not add
95  * Hs to the graph.
96  * \param useBO - if set, bond orders will be considered when uniquifying
97  * the paths
98  * \param rootedAtAtom - if non-negative, only subgraphs that start at
99  * this atom will be returned.
100  *
101  * The result is a list of paths (i.e. list of list of bond indices)
102  */
104  const ROMol &mol, unsigned int targetLen, bool useHs = false,
105  bool useBO = true, int rootedAtAtom = -1);
106 //! \brief find all paths of a particular size
107 /*!
108  * \param mol - the molecule to be considered
109  * \param targetLen - the length of the paths to be returned
110  * \param useBonds - if set, the path indices will be bond indices,
111  * not atom indices
112  * \param useHs - if set, hydrogens in the graph will be considered
113  * eligible to be in paths. NOTE: this will not add
114  * Hs to the graph.
115  * \param rootedAtAtom - if non-negative, only subgraphs that start at
116  * this atom will be returned.
117  *
118  * The result is a list of paths (i.e. list of list of bond indices)
119  */
121  unsigned int targetLen,
122  bool useBonds = true,
123  bool useHs = false,
124  int rootedAtAtom = -1);
126  const ROMol &mol, unsigned int lowerLen, unsigned int upperLen,
127  bool useBonds = true, bool useHs = false, int rootedAtAtom = -1);
128 
129 //! \brief find bond subgraphs of a particular radius around an atom
130 /*!
131  * \param mol - the molecule to be considered
132  * \param radius - the radius of the subgraphs to be considered
133  * \param rootedAtAtom - the atom to consider
134  * \param useHs - if set, hydrogens in the graph will be considered
135  * eligible to be in paths. NOTE: this will not add
136  * Hs to the graph.
137  *
138  * The result is a path (a vector of bond indices)
139  */
141 findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius,
142  unsigned int rootedAtAtom, bool useHs = false);
143 } // namespace RDKit
144 
145 #endif
RDKit::INT_PATH_LIST_MAP_I
INT_PATH_LIST_MAP::iterator INT_PATH_LIST_MAP_I
Definition: Subgraphs.h:47
RDKIT_SUBGRAPHS_EXPORT
#define RDKIT_SUBGRAPHS_EXPORT
Definition: export.h:658
RDKit::findAtomEnvironmentOfRadiusN
RDKIT_SUBGRAPHS_EXPORT PATH_TYPE findAtomEnvironmentOfRadiusN(const ROMol &mol, unsigned int radius, unsigned int rootedAtAtom, bool useHs=false)
find bond subgraphs of a particular radius around an atom
RDKit::findAllPathsOfLengthsMtoN
RDKIT_SUBGRAPHS_EXPORT INT_PATH_LIST_MAP findAllPathsOfLengthsMtoN(const ROMol &mol, unsigned int lowerLen, unsigned int upperLen, bool useBonds=true, bool useHs=false, int rootedAtAtom=-1)
RDKit::findAllPathsOfLengthN
RDKIT_SUBGRAPHS_EXPORT PATH_LIST findAllPathsOfLengthN(const ROMol &mol, unsigned int targetLen, bool useBonds=true, bool useHs=false, int rootedAtAtom=-1)
find all paths of a particular size
RDKit::PATH_LIST_CI
PATH_LIST::const_iterator PATH_LIST_CI
Definition: Subgraphs.h:43
RDKit::ROMol
Definition: ROMol.h:171
RDKit::findUniqueSubgraphsOfLengthN
RDKIT_SUBGRAPHS_EXPORT PATH_LIST findUniqueSubgraphsOfLengthN(const ROMol &mol, unsigned int targetLen, bool useHs=false, bool useBO=true, int rootedAtAtom=-1)
find unique bond subgraphs of a particular size
RDKit::INT_PATH_LIST_MAP_CI
INT_PATH_LIST_MAP::const_iterator INT_PATH_LIST_MAP_CI
Definition: Subgraphs.h:46
RDKit
Std stuff.
Definition: Atom.h:30
RDKit::PATH_LIST
std::list< PATH_TYPE > PATH_LIST
Definition: Subgraphs.h:42
RDKit::findAllSubgraphsOfLengthsMtoN
RDKIT_SUBGRAPHS_EXPORT INT_PATH_LIST_MAP findAllSubgraphsOfLengthsMtoN(const ROMol &mol, unsigned int lowerLen, unsigned int upperLen, bool useHs=false, int rootedAtAtom=-1)
find all bond subgraphs in a range of sizes
RDKit::findAllSubgraphsOfLengthN
RDKIT_SUBGRAPHS_EXPORT PATH_LIST findAllSubgraphsOfLengthN(const ROMol &mol, unsigned int targetLen, bool useHs=false, int rootedAtAtom=-1)
find all bond subgraphs of a particular size
RDKit::PATH_TYPE
std::vector< int > PATH_TYPE
Definition: Subgraphs.h:37
RDKit::INT_PATH_LIST_MAP
std::map< int, PATH_LIST > INT_PATH_LIST_MAP
Definition: Subgraphs.h:45
export.h