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) |
and the molecule records the charge state that was reconstructed:
| property | meaning |
|---|---|
_AmberNetCharge |
total formal charge actually placed on the atoms |
_AmberNetChargeFromPartial |
net charge the partial charges asked for |
Formal charges
The Tripos mol2 format has no formal-charge column, so a protonated amine and a
neutral one have identical connection tables. Left alone, RDKit rejects the
cation (Explicit valence for atom # N, 4, is greater than permitted) and — the
quieter problem — reads a carboxylate back as the neutral acid, because a
singly-bonded O is a perfectly legal hydroxyl that it fills with an implicit H.
What the format does record is a partial charge per atom, and for a force-field-ready structure those sum to the net charge. That sum is the authority for how much charge to place; the sites come from RDKit's own valence model (over-valent atoms) and from the terminal O/S of the usual acidic groups. Sums are taken per connected fragment, so a salt charges each component separately, and over-valent atoms are charged before anions are balanced against the net, so zwitterions come out with both signs.
mol = load_amber_mol2("ammonium.mol2")
mol.GetIntProp("_AmberNetCharge") # +1
Pass assign_charges=False for the previous behaviour. If a file's bond orders
and partial charges disagree about the protonation state, the molecule is still
built, an AmberChargeWarning is raised, and the two net-charge properties
differ — compare them to reject such a structure without catching warnings.
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.
Tests
pytest
rdk-amber
Metadata
Release files for rdk-amber 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rdk_amber-0.1.2.tar.gz | 18.9 kB | With provenance | Details for rdk_amber-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rdk_amber-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for rdk_amber-0.1.2-py3-none-any.whl |
Total release size: 33.5 kB
Release files / rdk_amber-0.1.2.tar.gz
| Download URL | rdk_amber-0.1.2.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d22a14a7dd2d5b7ef53719f8472f7fe4be716224accbcd1a4e9faa9b77195e5
|
|
BLAKE2b-256 checksum How to use checksums |
843a19c334ce0185f41d4a45a8b556b8f1aece891cac4482c6421758f4278d73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency logRelease files / rdk_amber-0.1.2-py3-none-any.whl
| Download URL | rdk_amber-0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe87101f52b901a2f59f2885f3cecf2e317842b3710a129a1e0f870a9f7f7a52
|
|
BLAKE2b-256 checksum How to use checksums |
01d86d724ffe2e38ecb9a4f16a38b175880c675ad13ce584c670c26ffeb1c5a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency logSecurity for rdk-amber 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for rdk_amber-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.