Colour a molecular surface by an electrostatic potential from APBS.
APBS solves the Poisson-Boltzmann equation for a molecule in solvent and writes the electrostatic potential on a grid, usually as a .dx file. Its values are in kT/e: thermal energy per elementary charge, about 25.7 mV at 25 °C.
This example uses the potential of one barnase-barstar pair from 1BRS (barnase chain A, barstar chain D), made with pdb2pqr and APBS by docs/dev/apbs_1brs.py. Barnase is positively charged and barstar negatively charged.
import molecularnodes as mnfrom molecularnodes.nodes import geometry as mgcanvas = mn.Canvas()
/home/brady/actions-runner/_work/MolecularNodes/MolecularNodes/molecularnodes/nodes/_utils.py:4: FutureWarning: `databpy.nodes` is deprecated and will be removed in databpy 0.14.0. Node groups are handled by nodebpy (https://pypi.org/project/nodebpy/).
from databpy.nodes import append_from_blend, get_output, swap_tree
Load the potential
Load the grid as a density and show it with Density Style ISO Surface, which meshes the potential at +1 kT/e (blue) and -1 kT/e (red).
Passing the density as color samples the potential at every vertex of the surface, from -5 kT/e (red) to 5 kT/e (blue). The density’s Import Volume node keeps the grid in the bundle of its output, and density styles pass it on to the mesh they make, so it can be sampled while the density shows its own style. The coordinates of 1BRS line up with the grid because pdb2pqr keeps the input coordinates.
mol = mn.Molecule.fetch("1BRS")mol.add_style("surface", selection="chainID A D", color=esp)
<Molecule, `universe`: <Universe with 5151 atoms>, `object`: <bpy_struct, Object("1BRS") at 0x1ccf8168>