stereochemistry
Stereochemistry detection and encoding.
Implements CIP (Cahn-Ingold-Prelog) rules for: - R/S configuration at tetrahedral stereocenters - E/Z configuration at double bonds
DoubleBondStereo
dataclass
Represents E/Z stereochemistry at a double bond.
substituents1 / substituents2 list the high-priority neighbour
first for each end of the bond. configuration is "E", "Z",
or None if undetermined.
Source code in chmpy/graph/stereochemistry.py
StereoCenter
dataclass
Represents a tetrahedral stereocenter.
neighbors is in priority order (high to low). configuration is
"R", "S", or None if undetermined.
Source code in chmpy/graph/stereochemistry.py
assign_stereochemistry(graph)
Detect and assign stereochemistry for a molecular graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph with 3D coordinates. |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[StereoCenter], list[DoubleBondStereo]]
|
Tuple of (stereocenters, double_bond_stereo) lists. |
Source code in chmpy/graph/stereochemistry.py
count_stereocenters(graph)
Count the number of stereocenters in the molecule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of tetrahedral stereocenters. |
Source code in chmpy/graph/stereochemistry.py
find_double_bond_stereo(graph)
Find double bonds that can exhibit E/Z stereochemistry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
Returns:
| Type | Description |
|---|---|
list[DoubleBondStereo]
|
List of DoubleBondStereo objects (without configuration assigned). |
Source code in chmpy/graph/stereochemistry.py
find_stereocenters(graph)
Find potential tetrahedral stereocenters in the graph.
A stereocenter is an sp3 atom with 4 different substituents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
Returns:
| Type | Description |
|---|---|
list[StereoCenter]
|
List of StereoCenter objects (without configuration assigned). |
Source code in chmpy/graph/stereochemistry.py
get_double_bond_config(graph, atom1, atom2)
Get the E/Z configuration of a double bond.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
atom1
|
int
|
First atom of the double bond. |
required |
atom2
|
int
|
Second atom of the double bond. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
"E", "Z", or None if not a stereogenic double bond. |
Source code in chmpy/graph/stereochemistry.py
get_stereocenter_config(graph, atom_idx)
Get the R/S configuration of a single atom if it's a stereocenter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
atom_idx
|
int
|
Index of the atom to check. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
"R", "S", or None if not a stereocenter. |
Source code in chmpy/graph/stereochemistry.py
is_chiral(graph)
Check if the molecule has any stereocenters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the molecule has at least one stereocenter. |