RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
Rings.h
Go to the documentation of this file.
1//
2// Copyright (C) 2004-2026 Greg Landrum and other RDKit contributors
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
22struct RDL_cycle;
23
24namespace RDKit {
25class ROMol;
26};
27
28namespace RingUtils {
29typedef std::vector<int> INT_VECT;
30typedef std::vector<std::vector<int>> VECT_INT_VECT;
31typedef std::map<int, std::vector<int>> INT_INT_VECT_MAP;
32
33//! Pick a set of rings that are fused together and contain a specified ring
34/*!
35
36 \param curr the ID for the ring that should be in the fused system
37 \param neighMap adjacency lists for for all rings in the molecule.
38 See documentation for makeNeighMap
39 \param res used to return the results: a list of rings that are fused
40 with curr in them
41 \param done a bit vector recording the rings that are already dealt with
42 this also can be used to avoid any rings that should not be included
43 in the fused system
44 \param depth retained for API compatibility; no longer used
45
46*/
48 const INT_INT_VECT_MAP &neighMap,
49 INT_VECT &res,
50 boost::dynamic_bitset<> &done,
51 int depth = 0);
52
53//! \brief For each ring in bring compute and store the ring that are fused
54//! (share at least one bond with it).
55/*!
56 Useful both for the kekulization stuff and aromaticity perception.
57
58 \param brings list of rings - each ring is specified as a list of bond IDs
59 \param neighMap an STL map into which the results are stored. Each entry in
60 the
61 map is indexed by the ring ID and the contents are the list
62 rings (rather their IDs) that are fused with this ring
63 \param maxSize if this is >0, rings that are larger than the threshold
64 will not be considered as candidates to be neighbors
65 \param maxOverlapSize if this is >0, rings that overlap by more bonds than
66 this will not be considered to be neighbors
67
68*/
70 INT_INT_VECT_MAP &neighMap,
71 unsigned int maxSize = 0,
72 unsigned int maxOverlapSize = 0);
73
74//! converts a list of atom indices into a list of bond indices
75/*!
76
77 \param res list of ring - each ring is a list of atom ids
78 \param brings reference to a list of rings to the write the results to
79 each ring here is list of bonds ids
80 \param mol the molecule of interest
81
82 <b>Assumptions:</b>
83 - each list of atom ids in "res" form a legitimate ring
84 - each of these list of ordered such that a ring can be traversed
85*/
87 VECT_INT_VECT &brings,
88 const RDKit::ROMol &mol);
89
90// normalizes a ring by rotating/reversing it so that the first atom
91// is the one with the smallest index, and the second atom is the neighbor
92// to the first one that again has the smallest index.
93// This change should have a small performance footprint while it helps
94// keeping test results consistent when making changes to ring detection.
95void normalizeRing(std::vector<int> &ring);
96std::vector<int> rdlCycleToAtomRing(RDL_cycle *cycle);
97
98} // namespace RingUtils
99
100#endif
#define RDKIT_GRAPHMOL_EXPORT
Definition export.h:321
Std stuff.
std::vector< int > INT_VECT
Definition Rings.h:29
RDKIT_GRAPHMOL_EXPORT void makeRingNeighborMap(const VECT_INT_VECT &brings, INT_INT_VECT_MAP &neighMap, unsigned int maxSize=0, unsigned int maxOverlapSize=0)
For each ring in bring compute and store the ring that are fused (share at least one bond with it).
void normalizeRing(std::vector< int > &ring)
RDKIT_GRAPHMOL_EXPORT void convertToBonds(const VECT_INT_VECT &res, VECT_INT_VECT &brings, const RDKit::ROMol &mol)
converts a list of atom indices into a list of bond indices
RDKIT_GRAPHMOL_EXPORT void pickFusedRings(int curr, const INT_INT_VECT_MAP &neighMap, INT_VECT &res, boost::dynamic_bitset<> &done, int depth=0)
Pick a set of rings that are fused together and contain a specified ring.
std::vector< int > rdlCycleToAtomRing(RDL_cycle *cycle)
std::vector< std::vector< int > > VECT_INT_VECT
Definition Rings.h:30
std::map< int, std::vector< int > > INT_INT_VECT_MAP
Definition Rings.h:31