bond_orders
Bond order perception from molecular geometry.
Assigns bond orders (single, double, triple, aromatic) based on: 1. Bond length heuristics 2. Valence constraints 3. Aromaticity information
get_bond_order(graph, atom_i, atom_j)
Get the perceived bond order between two atoms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
atom_i
|
int
|
First atom index. |
required |
atom_j
|
int
|
Second atom index. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Bond order (1, 1.5, 2, or 3), or 0 if no bond. |
Source code in chmpy/graph/bond_orders.py
hydrogen_count(graph, atom_idx)
Count explicit hydrogens bonded to an atom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
atom_idx
|
int
|
Index of the atom. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of hydrogen atoms bonded to this atom. |
Source code in chmpy/graph/bond_orders.py
implicit_hydrogen_count(graph, atom_idx)
Calculate implicit hydrogen count for an atom.
Based on standard valence minus current bond order sum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
atom_idx
|
int
|
Index of the atom. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of implicit hydrogens. |
Source code in chmpy/graph/bond_orders.py
is_double_bond(graph, atom_i, atom_j)
is_single_bond(graph, atom_i, atom_j)
is_triple_bond(graph, atom_i, atom_j)
perceive_bond_orders(graph)
Perceive bond orders from molecular geometry.
Uses a multi-step approach: 1. Initial assignment from bond lengths 2. Aromatic ring detection and assignment 3. Valence constraint propagation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph with bond distance information. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Sparse matrix of bond orders (N, N). |
Source code in chmpy/graph/bond_orders.py
total_bond_order(graph, atom_idx)
Calculate the total bond order (valence) for an atom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
MolecularGraph
|
A MolecularGraph. |
required |
atom_idx
|
int
|
Index of the atom. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Sum of bond orders for all bonds to this atom. |