Skip to main content

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:

  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)

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.
  • Partial charges are stored as properties; formal charges are not inferred.

Tests

pytest

rdk-amber

Project details


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.0.tar.gz (12.2 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.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

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

Hashes for rdk_amber-0.1.0.tar.gz
Algorithm Hash digest
SHA256 93868c3aea572425aafef382bd4023ea7187bb15d2f2172da51954edb5816f45
MD5 3a86b5275698a45fbb757f43762e5219
BLAKE2b-256 e66102b242825f5bcc69fa4c165034b10e7d118a7c663234d171346f54fb737c

See more details on using hashes here.

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

Hashes for rdk_amber-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9d2d4c86a5a7f2406c60471a2166daa530ba6926703685a1e4dc53c785125a2
MD5 17e609fda2f5b33e970d33c14cfff74a
BLAKE2b-256 8a9bc076513532bf85d7cf40c8176cd8c543659dd9904cf8e753f4c78a673882

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page