or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-chemistry.mddescriptors.mdfeatures.mdindex.mdstructure-3d.mdvisualization.md

index.mddocs/

0

# RDKit

1

2

RDKit is a comprehensive cheminformatics and machine-learning library written in C++ with Python bindings. This package provides platform-specific wheels for easy installation across Linux, macOS, and Windows, containing compiled dynamic libraries and Python interfaces for molecular manipulation, chemical analysis, and machine learning applications in computational chemistry and drug discovery.

3

4

## Package Information

5

6

- **Package Name**: rdkit

7

- **Language**: Python (C++ implementation)

8

- **Installation**: `pip install rdkit`

9

- **Dependencies**: numpy, Pillow (automatically installed)

10

- **Platforms**: Linux (x86_64, aarch64), macOS (x86_64, arm64), Windows (x86_64)

11

- **Python Versions**: 3.9-3.13

12

13

## Core Imports

14

15

```python

16

import rdkit

17

```

18

19

Core chemistry functionality:

20

21

```python

22

from rdkit import Chem

23

```

24

25

Common specific imports:

26

27

```python

28

from rdkit.Chem import AllChem, Descriptors, Descriptors3D

29

from rdkit.Chem import ChemicalFeatures, Draw

30

from rdkit import RDConfig

31

```

32

33

## Basic Usage

34

35

```python

36

from rdkit import Chem

37

from rdkit.Chem import Descriptors, AllChem, Draw

38

39

# Create a molecule from SMILES

40

smiles = "CCO" # Ethanol

41

mol = Chem.MolFromSmiles(smiles)

42

43

# Calculate molecular descriptors

44

mw = Descriptors.MolWt(mol)

45

logp = Descriptors.MolLogP(mol)

46

print(f"Molecular Weight: {mw:.2f}")

47

print(f"LogP: {logp:.2f}")

48

49

# Generate 2D coordinates and create an image

50

AllChem.Compute2DCoords(mol)

51

img = Draw.MolToImage(mol, size=(300, 300))

52

img.save("molecule.png")

53

54

# Convert to MOL block format

55

mol_block = Chem.MolToMolBlock(mol)

56

print(mol_block)

57

```

58

59

## Architecture

60

61

RDKit's architecture centers around the **Mol** object, which represents molecular structures and serves as the foundation for all cheminformatics operations:

62

63

- **Mol Objects**: Core molecular representations with atoms, bonds, and properties

64

- **I/O Systems**: Format converters for SMILES, SDF, MOL, PDB, and other chemical formats

65

- **Descriptor Calculators**: 217+ molecular descriptors for characterizing chemical properties

66

- **3D Generation**: Conformer generation and 3D coordinate assignment algorithms

67

- **Drawing System**: 2D molecular structure visualization with customizable rendering

68

- **Feature Systems**: Pharmacophore and chemical feature detection frameworks

69

- **Data Resources**: Built-in chemical databases, atom typing, and feature definitions

70

71

This design enables RDKit to serve as the foundational cheminformatics library for Python, providing essential molecular manipulation capabilities for computational chemistry, drug discovery, and chemical data analysis applications.

72

73

## Capabilities

74

75

### Core Chemistry

76

77

Fundamental molecular representation, manipulation, and I/O operations. Includes molecule creation from various formats, basic property access, and format conversions.

78

79

```python { .api }

80

def MolFromSmiles(smiles: str, sanitize: bool = True) -> Mol: ...

81

def MolToSmiles(mol: Mol, **kwargs) -> str: ...

82

def MolFromMolBlock(molblock: str, **kwargs) -> Mol: ...

83

def MolToMolBlock(mol: Mol, **kwargs) -> str: ...

84

```

85

86

[Core Chemistry](./core-chemistry.md)

87

88

### Molecular Descriptors

89

90

Calculation of 2D molecular descriptors for characterizing chemical properties. Includes 217+ descriptors covering molecular weight, logP, topological indices, and structural features.

91

92

```python { .api }

93

def MolWt(mol: Mol) -> float: ...

94

def MolLogP(mol: Mol) -> float: ...

95

def NumHDonors(mol: Mol) -> int: ...

96

def NumHAcceptors(mol: Mol) -> int: ...

97

def CalcMolDescriptors(mol: Mol) -> dict: ...

98

```

99

100

[Molecular Descriptors](./descriptors.md)

101

102

### 3D Structure Generation

103

104

3D conformer generation, molecular embedding, and 3D descriptor calculations for spatial molecular analysis.

105

106

```python { .api }

107

def EmbedMolecule(mol: Mol, **kwargs) -> int: ...

108

def Compute2DCoords(mol: Mol) -> None: ...

109

def CalcMolDescriptors3D(mol: Mol) -> dict: ...

110

```

111

112

[3D Structure Generation](./structure-3d.md)

113

114

### Molecular Visualization

115

116

2D molecular structure rendering and image generation with customizable display options for creating publication-quality molecular graphics.

117

118

```python { .api }

119

def MolToImage(mol: Mol, size: tuple = (300, 300), **kwargs): ...

120

def ReactionToImage(reaction, **kwargs): ...

121

```

122

123

[Molecular Visualization](./visualization.md)

124

125

### Chemical Features

126

127

Pharmacophore and chemical feature detection for identifying functional groups, binding sites, and molecular patterns.

128

129

```python { .api }

130

def BuildFeatureFactory(fdefName: str): ...

131

```

132

133

[Chemical Features](./features.md)

134

135

## Configuration

136

137

### Data Directory Access

138

139

```python { .api }

140

RDDataDir: str # Path to RDKit data directory containing databases and definitions

141

```

142

143

RDKit includes extensive chemical data resources accessed through the RDDataDir configuration:

144

145

- **BaseFeatures.fdef**: Chemical feature definitions for pharmacophore detection

146

- **Crippen.txt**: Atom contribution data for logP calculations

147

- **Descriptors**: Reference data for molecular descriptor calculations

148

- **FragmentDescriptors**: Substructure-based descriptor definitions

149

- **AtomTypes**: Atom typing schemes for various applications

150

151

## Types

152

153

```python { .api }

154

class Mol:

155

"""Core molecular representation object"""

156

def GetNumAtoms() -> int: ...

157

def GetNumBonds() -> int: ...

158

def GetAtoms() -> list: ...

159

def GetBonds() -> list: ...

160

def GetPropsAsDict() -> dict: ...

161

162

class Atom:

163

"""Individual atom representation"""

164

def GetAtomicNum() -> int: ...

165

def GetSymbol() -> str: ...

166

def GetIdx() -> int: ...

167

168

class Bond:

169

"""Chemical bond representation"""

170

def GetBondType() -> BondType: ...

171

def GetBeginAtomIdx() -> int: ...

172

def GetEndAtomIdx() -> int: ...

173

174

class BondType:

175

"""Enumeration of chemical bond types"""

176

SINGLE: int = 1

177

DOUBLE: int = 2

178

TRIPLE: int = 3

179

AROMATIC: int = 4

180

```