1 //
2 //  Copyright (C) 2004-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 Rings.h
12 //! \brief utility functionality for working with ring systems
13 
14 #include <RDGeneral/export.h>
15 #ifndef _RDRINGS_H_
16 #define _RDRINGS_H_
17 
18 #include <vector>
19 #include <map>
20 #include <boost/dynamic_bitset_fwd.hpp>
21 
22 namespace RDKit {
23 class ROMol;
24 };
25 
26 namespace RingUtils {
27 typedef std::vector<int> INT_VECT;
28 typedef std::vector<std::vector<int>> VECT_INT_VECT;
29 typedef std::map<int, std::vector<int>> INT_INT_VECT_MAP;
30 
31 //! Pick a set of rings that are fused together and contain a specified ring
32 /*!
33 
34    \param curr      the ID for the irng that should be in the fused system
35    \param neighMap  adjacency lists for for all rings in the molecule.
36            See documentation for makeNeighMap
37    \param res       used to return the results: a list of rings that are fused
38            with curr in them
39    \param done      a bit vector recording the rings that are already dealt with
40            this also can be used to avoid any rings that should not be included
41    in
42            the fused system
43    \param depth used to track recursion depth
44 
45 */
46 RDKIT_GRAPHMOL_EXPORT void pickFusedRings(int curr,
47                                           const INT_INT_VECT_MAP &neighMap,
48                                           INT_VECT &res,
49                                           boost::dynamic_bitset<> &done,
50                                           int depth = 0);
51 
52 //! \brief For each ring in bring compute and store the ring that are fused
53 //! (share at least one bond with it).
54 /*!
55   Useful both for the keulization stuff and aromaticity perception.
56 
57   \param brings   list of rings - each ring is specified as a list of bond IDs
58   \param neighMap an STL map into which the results are stored. Each entry in
59   the
60               map is indexed by the ring ID and the contents are the list
61               rings (rather their IDs) that are fused with this ring
62   \param maxSize if this is >0, rings that are larger than the threshold
63                  will not be considered as candidates to be neighbors
64   \param maxOverlapSize if this is >0, rings that overlap by more bonds than
65                         this will not be considered to be neighbors
66 
67 */
68 RDKIT_GRAPHMOL_EXPORT void makeRingNeighborMap(const VECT_INT_VECT &brings,
69                                                INT_INT_VECT_MAP &neighMap,
70                                                unsigned int maxSize = 0,
71                                                unsigned int maxOverlapSize = 0);
72 
73 //! converts a list of atom indices into a list of bond indices
74 /*!
75 
76    \param res    list of ring - each ring is a list of atom ids
77    \param brings reference to a list of rings to the write the results to
78                  each ring here is list of bonds ids
79    \param mol    the molecule of interest
80 
81   <b>Assumptions:</b>
82    - each list of atom ids in "res" form a legitimate ring
83    - each of these list of ordered such that a ring can be traversed
84 */
85 RDKIT_GRAPHMOL_EXPORT void convertToBonds(const VECT_INT_VECT &res,
86                                           VECT_INT_VECT &brings,
87                                           const RDKit::ROMol &mol);
88 };  // namespace RingUtils
89 
90 #endif
91