Map AMBER/GAFF atom types to elements and load AMBER-style mol2 files into RDKit.
Project description
rdk-amber
Small utilities for bridging AMBER force-field conventions and RDKit:
- A mapping between AMBER / GAFF atom types and chemical elements.
- A loader that reads an AMBER-style
mol2file (GAFF/AMBER atom types in the type column) into anrdkit.Chem.Mol.
RDKit's own MolFromMol2File expects SYBYL atom types (C.3, N.ar, …).
AmberTools (antechamber, tleap) instead writes GAFF/AMBER atom types
(c3, na, …) in that column, which RDKit cannot interpret. This package
parses such files directly.
Install
pip install -e .
Requires rdkit (install via conda/pip).
Usage
Atom type → element
from rdk_amber import element_from_amber_type
element_from_amber_type("c3") # 'C'
element_from_amber_type("ho") # 'H'
element_from_amber_type("Na+") # 'Na'
element_from_amber_type("Xx") # None (unknown)
element_from_amber_type("Xx", strict=True) # raises UnknownAtomTypeError
The full table is exposed as rdk_amber.AMBER_ATOM_TYPE_TO_ELEMENT. Types not
in the table fall back to a prefix heuristic (e.g. c99 → C).
Load an AMBER mol2
from rdk_amber import load_amber_mol2
mol = load_amber_mol2("ligand.mol2") # sanitized RDKit Mol, with 3D coords
mol = load_amber_mol2("ligand.mol2", remove_hs=True)
Or use the class for more control / multi-molecule files:
from rdk_amber import AmberMol2Loader
loader = AmberMol2Loader.from_file("ligand.mol2")
loader.num_molecules # number of @<TRIPOS>MOLECULE records
loader.names # their names
mol = loader.to_rdkit(index=0, sanitize=True)
mols = loader.to_rdkit_all()
Each atom keeps the original AMBER data as properties:
| property | meaning |
|---|---|
_AmberAtomType |
the GAFF/AMBER atom type (c3, ca, …) |
_TriposAtomName |
the atom name column |
_TriposResidueName |
the substructure / residue name |
_TriposPartialCharge |
the mol2 partial charge (double) |
Notes
- Bond orders are read from the
@<TRIPOS>BONDsection.ar→ aromatic,am→ single,1/2/3→ single/double/triple. - If sanitization fails (unusual force-field valences), pass
sanitize=Falseto obtain the unsanitized molecule. - Partial charges are stored as properties; formal charges are not inferred.
Tests
pytest
rdk-amber
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rdk_amber-0.1.0.tar.gz.
File metadata
- Download URL: rdk_amber-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93868c3aea572425aafef382bd4023ea7187bb15d2f2172da51954edb5816f45
|
|
| MD5 |
3a86b5275698a45fbb757f43762e5219
|
|
| BLAKE2b-256 |
e66102b242825f5bcc69fa4c165034b10e7d118a7c663234d171346f54fb737c
|
File details
Details for the file rdk_amber-0.1.0-py3-none-any.whl.
File metadata
- Download URL: rdk_amber-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9d2d4c86a5a7f2406c60471a2166daa530ba6926703685a1e4dc53c785125a2
|
|
| MD5 |
17e609fda2f5b33e970d33c14cfff74a
|
|
| BLAKE2b-256 |
8a9bc076513532bf85d7cf40c8176cd8c543659dd9904cf8e753f4c78a673882
|