Coverage Report

Created: 2026-03-31 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rdkit/Code/GraphMol/CIPLabeler/CIPLabeler.h
Line
Count
Source
1
//
2
//
3
//  Copyright (C) 2020 Schrödinger, LLC
4
//
5
//   @@ All Rights Reserved @@
6
//  This file is part of the RDKit.
7
//  The contents are covered by the terms of the BSD license
8
//  which is included in the file license.txt, found at the root
9
//  of the RDKit source tree.
10
//
11
#pragma once
12
13
#include <RDGeneral/BoostStartInclude.h>
14
#include <boost/dynamic_bitset.hpp>
15
#include <RDGeneral/BoostEndInclude.h>
16
17
#include <RDGeneral/export.h>
18
19
namespace RDKit {
20
21
class ROMol;
22
23
namespace CIPLabeler_detail {
24
RDKIT_CIPLABELER_EXPORT bool decrementRemainingCallCountAndCheck();
25
}
26
27
namespace CIPLabeler {
28
29
/*
30
  Some very symmetrical mols can cause pseudo infinite processing
31
  (e.g. dodecahedrane)
32
  To avoid this a maxinum number of iterations can be set by the caller as a
33
  parameter to assignCIPLabels.
34
  If that maximum value is exceeded, the following error is thrown
35
*/
36
37
class RDKIT_CIPLABELER_EXPORT MaxIterationsExceeded
38
    : public std::runtime_error {
39
 public:
40
  explicit MaxIterationsExceeded()
41
0
      : std::runtime_error("Max Iterations Exceeded in CIP label calculation") {
42
0
        };
43
};
44
45
/**
46
 * Calculate Stereochemical labels based on an accurate implementation
47
 * of the CIP rules.
48
 *
49
 * This is a C++ port of https://github.com/SiMolecule/centres, which was
50
 * originally written by John Mayfield in Java. The original algorithm was
51
 * described in:
52
 *
53
 * Hanson, R. M., Musacchio, S., Mayfield, J. W., Vainio, M. J., Yerin, A.,
54
 * Redkin, D. Algorithmic Analysis of Cahn--Ingold--Prelog Rules of
55
 * Stereochemistry: Proposals for Revised Rules and a Guide for Machine
56
 * Implementation. J. Chem. Inf. Model. 2018, 58, 1755-1765.
57
 *
58
 *   \param mol - the molecule to be labelled.
59
 *
60
 *   \note only atoms with chiral tags and double bonds with proper
61
 *          bond directions will be labelled.
62
 *   \note Labels will be stored under the common_properties::_CIPCode
63
 *          property of the relevant atoms/bonds.
64
 */
65
RDKIT_CIPLABELER_EXPORT void assignCIPLabels(
66
    ROMol &mol, unsigned int maxRecursiveIterations = 0);
67
68
/**
69
 * Overload that allows selecting which atoms and/or bonds will be labeled.
70
 *
71
 *   \param mol - the molecule to be labelled.
72
 *
73
 *   \param atoms - bitset with the atom indexes to be labeled.
74
 *
75
 *   \param bonds - bitset with the bond indexes to be labeled.
76
 *
77
 *   \param maxRecursiveIterations - maximum number of iterations
78
 *      A value of 1,250,000 take about 1 second.  Most structures requires
79
 *      less than 10,000 iterations. A peptide with MW~3000 took about
80
 *      100 iterations, and a 20,000 mw protein took about 600 iterations.
81
 *
82
 */
83
RDKIT_CIPLABELER_EXPORT void assignCIPLabels(
84
    ROMol &mol, const boost::dynamic_bitset<> &atoms,
85
    const boost::dynamic_bitset<> &bonds,
86
    unsigned int maxRecursiveIterations = 0);
87
88
}  // namespace CIPLabeler
89
}  // namespace RDKit