Skip to main content

rdk-amber

Small utilities for bridging AMBER force-field conventions and RDKit:

  1. A mapping between AMBER / GAFF atom types and chemical elements.
  2. A loader that reads an AMBER-style mol2 file (GAFF/AMBER atom types in the type column) into an rdkit.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>BOND section. ar → aromatic, am → single, 1/2/3 → single/double/triple.
  • If sanitization fails (unusual force-field valences), pass sanitize=False to obtain the unsanitized molecule.

Tests

pytest

rdk-amber

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdk_amber-0.1.2.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rdk_amber-0.1.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file rdk_amber-0.1.2.tar.gz.

File metadata

  • Download URL: rdk_amber-0.1.2.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rdk_amber-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9d22a14a7dd2d5b7ef53719f8472f7fe4be716224accbcd1a4e9faa9b77195e5
MD5 9330ec1ba558653d77d13fdec5ad0718
BLAKE2b-256 843a19c334ce0185f41d4a45a8b556b8f1aece891cac4482c6421758f4278d73

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdk_amber-0.1.2.tar.gz:

Publisher: publish.yml on piskuliche/rdk-amber

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdk_amber-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: rdk_amber-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rdk_amber-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe87101f52b901a2f59f2885f3cecf2e317842b3710a129a1e0f870a9f7f7a52
MD5 60788d4eb4d5116188daa78ffd3515cd
BLAKE2b-256 01d86d724ffe2e38ecb9a4f16a38b175880c675ad13ce584c670c26ffeb1c5a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdk_amber-0.1.2-py3-none-any.whl:

Publisher: publish.yml on piskuliche/rdk-amber

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page