A fragment-based molecular assembly toolkit for python.
Project description
BuildAMol is a molecular building suite designed to facilitate the generation and alteration of atomic models for large and small chemical structures.
It allows for an easy modeling process inside a Jupyter Notebook or can be integrated into automated pipelines. BuildAMol offers direct integrations to PubChem, and the PDBE component library as well as the CHARMM project to provide pre-defined template structures and linkages to use out-of-the-box. Quick-conversions to popular libraries such as RDKit allow for a smooth workflow, going from modeling to analysis.
BuildAMol allows users to:
- build any larger molecular structure they like with full control
- automate molecular modeling tasks (e.g. see the Ligand Design Pipeline or Molecular Derivatives examples)
- improve the conformation of an existing structure
- create highly customizable 2D and 3D visualizations of structures
- quickly obtain molecular structures for chemical compounds
- convert data formats
BuildAMol cannot:
- model real-life chemical reaction mechanisms in detail
- perform molecular dynamics or quantum chemistry computations
- generate molecules for the user out of the blue - the user needs to to have some idea of what to build or how to build it...
Installing BuildAMol
BuildAMol can be installed via pip using:
pip install buildamol
Getting Started
BuildAMol has a comprehensive documentation on ReadTheDocs. There you can find also also a number of tutorials to get you started on the API covering both basic operations as well as more complex and applied workflows such as building materials, preparing molecules for molecular dynamics, or designing protein ligands.
Example 1 - Building A Dendrimer From Scratch
This code will model a polyphenylene dendrimer as it was originally described by Bauer et al. (2002) using only the most barebone functionalities of the BuildAMol library with 100% control over which atoms form bonds and how.
import buildamol as bam
bam.load_small_molecules()
benzene = bam.molecule("benzene")
# set up the linkage instructions
# always shifting the carbon at which to attach
periphery = benzene.copy()
link = bam.linkage(None, "C1")
for carbon in range(1, 6):
link.atom1 = f"C{carbon}"
periphery.attach(benzene, link, at_residue=1)
# assemble the dendrimer starting with the central benzene
mol = benzene.copy()
link2 = bam.linkage(None, "C4")
# and attach the periphery to the core
for carbon in mol.get_atoms("C", by="element"):
link2.atom1 = carbon
mol.attach(periphery, link2, at_residue=1, other_residue=2)
# optimize the conformation
mol.optimize()
mol.to_pdb("polyphenylene.pdb")
mol.show3d()
Example 2 - Making a Glycan-Aspirin Conjugate
There are also a number of already available extensions to make life easier when constructing certain kinds of molecules. For example, we can build Glycans directly from commonly used IUPAC notation. We can also exploit BuildAMol's various inference-level tools to determine how to connect molecular fragments together. In the example below we create a glycan-drug conjugate, automatically searching for the right atoms to use for connecting the molecules.
import buildamol as bam
from buildamol.extensions.bio import glycans
from buildamol.structural import constraints_v2 as constraints
from buildamol.structural.reactivity import Carboxyl
# construct a small glycan
glycan = glycans.glycan("Neu5Ac(a2-3)Gal(b1-4)GlcNAc")
# and now create a conjugate with a drug-like molecule
# e.g. aspirin
aspirin = bam.molecule("aspirin")
# find the right atoms to define a linkage
# (here: connect the Nitrogen atom of the last sugar residue
# to the carbonyl Carbon of the carboxyl group of aspirin, while splitting of an acetonic acid)
N = glycan.get_atom("N", by="element", residue=-1)
C_next_to_N = N.get_neighbors(filter=constraints.has_double_bond_with("O")).pop()
# find the reactive carboxyl atoms in the aspirin with help of the Carboxyl reactivity class
carboxyl = Carboxyl()
C_of_COOH, OH_of_COOH = carboxyl.find_atoms(aspirin, role="electrophile", serves_target=False)
# define the linkage between glycan and aspirin
link = bam.linkage(
N, C_of_COOH,
delete_in_target=[C_next_to_N],
delete_in_source=[OH_of_COOH],
)
# now create the conjugate
conjugate = bam.connect(glycan, aspirin, link)
conjugate.draw2d().highlight_residues(-1, color="yellow").draw()
Example 3 - Letting Molecules "react" via Functional Groups
BuildAMol does not limit itself to "chemically" plausible connections of Molecules. However, it provides ways to conveniently connect Molecules based on reactivity patterns of functional groups. For example we can hydroxylate a carbon polymer and then let the hydroxyl groups react with the amide groups of a second molecule like so:
import buildamol as bam
from buildamol.structural.reactivity import Hydroxyl, Amide
from buildamol.extensions.polymers.polycarbons import cyclic_alkane
# create two cyclic alkanes
# (one larger that we hydroxylate at several positions,
# the other smaller that we amidate at one position)
A = cyclic_alkane(65)
sites = A.get_atoms(list(range(1, 65, 5)))
A = bam.hydroxylate(A, sites, [A.get_equatorial_hydrogen(s) for s in sites])
B = cyclic_alkane(6)
B = bam.amidate(B, 1, B.get_equatorial_hydrogen(1))
# now we let them react via the hydroxyl and amide groups
# attaching the amides and splitting off water
reaction = bam.Reaction.from_reactivities(
nucleophile=Amide(),
electrophile=Hydroxyl(),
)
out = reaction(A, B)
out.draw2d().draw(width=800, height=800)
Example 4 - Multi-Molecule Systems
BuildAMol allows allows the free arrangement and orientation of molecules in 3D space. We can for instance create a dual ring system using the cyclic alkane from Example 3.
# out from Example 3
dual_rings = out.copy()
# copy the ring, move it and rotate it
ring2 = out.copy().move([12, 0, 2]).rotate(90, "x")
# merge the two rings as one system
dual_rings.merge(ring2)
dual_rings.show3d()
BuildAMol Paper
To learn more about the benchmarking we did and further details on the software, please check out the BuildAMol paper. If you were using BuildAMol for your project, cite the paper as follows:
@article{buildamol,
author = {Kleinschmidt, Noah and Lemmin, Thomas},
journal = {Journal of Cheminformatics},
number = {1},
pages = {104},
title = {BuildAMol: a versatile Python toolkit for fragment-based molecular design},
volume = {16},
year = {2024}}
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
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 buildamol-1.2.11.tar.gz.
File metadata
- Download URL: buildamol-1.2.11.tar.gz
- Upload date:
- Size: 17.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2a2f91ba2364671f91d9c3f92f886098efa1d6fe34e2d1880835ba23f423af3
|
|
| MD5 |
9ff1a970fd43f5bea820be72562f75dd
|
|
| BLAKE2b-256 |
3ccad6b030e36bf82d223a305da2109569501dbb5117858502a2450b14ede9f9
|
File details
Details for the file buildamol-1.2.11-py3-none-any.whl.
File metadata
- Download URL: buildamol-1.2.11-py3-none-any.whl
- Upload date:
- Size: 18.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1266479cf34b57606456bfe6b5fa8dbe4f55eabf325ffc88b4fb5f2d19bb5a6
|
|
| MD5 |
376026412a1e904219a50c46c55cc873
|
|
| BLAKE2b-256 |
8ce2604f6d159d98a621e62e5446484541a2b21f358bb0541a3a967fae7e0785
|