Skip to content

Commit 3310bba

Browse files
feat: add APBS electrostatic surface demo (#2)
* feat: add APBS electrostatic surface demo Render a vacuum electrostatic potential surface for 2ewn (E. coli biotin repressor) using util.protein_vacuum_esp (protein contact potential mode), mirroring the existing surface demo's structure prep. Adds scripts/demos/ apbs.pml, the rendered assets/demo_apbs.png, and a README section. * feat: render APBS demo with the real APBS solver Replace the vacuum-ESP approximation with a true Poisson-Boltzmann electrostatics pipeline: - scripts/apbs/prepare_apbs.sh: pdb2pqr (AMBER charges/radii) -> apbs (linearised PBE, 0.150 M NaCl) -> potential map (.dx, kT/e) for 2ewn chain A. - scripts/demos/apbs.pml: load the .pqr + .dx and colour the molecular surface by potential over -5..+5 kT/e (ramp_new/surface_color), mirroring the mdpp examples/apbs viz scripts. - CI: install apbs + pdb2pqr and run prepare_apbs.sh before rendering. - gitignore generated APBS artifacts (.pqr/.dx/.in/.pdb) and the apbs solver scratch file io.mc. * feat: match APBS demo camera to the surface demo Replace orient with the explicit set_view matrix copied from scripts/demos/surface.pml so both demos share the same viewpoint (orient on the pqr atom set diverged: added hydrogens, no ligand).
1 parent 7a6620d commit 3310bba

6 files changed

Lines changed: 97 additions & 2 deletions

File tree

‎.github/workflows/render-demos.yml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- "configs/.pymolrc"
88
- "configs/.pymolrc.py"
99
- "scripts/demos/*.pml"
10+
- "scripts/apbs/prepare_apbs.sh"
1011
workflow_dispatch:
1112

1213
jobs:
@@ -32,9 +33,13 @@ jobs:
3233
channels: conda-forge,defaults
3334
use-mamba: true
3435

35-
- name: Install PyMOL
36+
- name: Install PyMOL, APBS and PDB2PQR
3637
run: |
37-
conda install -y pymol-open-source
38+
conda install -y pymol-open-source apbs pdb2pqr
39+
40+
- name: Generate APBS electrostatics
41+
run: |
42+
bash scripts/apbs/prepare_apbs.sh 2ewn A
3843
3944
- name: Render demos
4045
env:

‎.gitignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,12 @@ cython_debug/
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162162
#.idea/
163+
164+
# APBS demo generated artifacts (regenerated by scripts/apbs/prepare_apbs.sh)
165+
scripts/apbs/*.pdb
166+
scripts/apbs/*.pqr
167+
scripts/apbs/*.dx
168+
scripts/apbs/*.in
169+
170+
# APBS solver scratch
171+
io.mc

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ You may also view and edit these rc files in `PyMOL -> File -> Edit pymolrc`.
2222

2323
![Surface Demo](assets/demo_surface.png)
2424

25+
### APBS (Electrostatic Surface)
26+
27+
![APBS Demo](assets/demo_apbs.png)
28+
2529
### Nucleic Acids
2630

2731
![Nucleic Acids Demo](assets/demo_na.png)

‎assets/demo_apbs.png‎

662 KB
Loading

‎scripts/apbs/prepare_apbs.sh‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Generate the APBS electrostatic potential map for the APBS surface demo.
4+
#
5+
# Pipeline (real Poisson-Boltzmann electrostatics):
6+
# 1. download the PDB entry
7+
# 2. isolate a single protein chain
8+
# 3. pdb2pqr -> per-atom charges/radii (.pqr) + a template APBS input (.in)
9+
# 4. apbs -> electrostatic potential map (.dx, units kT/e)
10+
#
11+
# Requires `pdb2pqr30` (or `pdb2pqr`) and `apbs` on PATH.
12+
# Outputs <id>.pqr and <id>.dx next to this script; scripts/demos/apbs.pml
13+
# loads those two files to render assets/demo_apbs.png.
14+
#
15+
# Usage: bash scripts/apbs/prepare_apbs.sh [PDB_ID] [CHAIN]
16+
set -euo pipefail
17+
18+
PDB_ID="${1:-2ewn}"
19+
CHAIN="${2:-A}"
20+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21+
cd "$HERE"
22+
23+
pdb2pqr_bin="$(command -v pdb2pqr30 || command -v pdb2pqr)"
24+
25+
echo "[apbs-prep] downloading ${PDB_ID}..."
26+
curl -sSL -o "${PDB_ID}.pdb" "https://files.rcsb.org/download/${PDB_ID^^}.pdb"
27+
28+
echo "[apbs-prep] isolating chain ${CHAIN} (protein atoms only)..."
29+
awk -v ch="$CHAIN" 'substr($0,1,4)=="ATOM" && substr($0,22,1)==ch' \
30+
"${PDB_ID}.pdb" > "${PDB_ID}_chain.pdb"
31+
32+
echo "[apbs-prep] assigning charges/radii with pdb2pqr (AMBER force field)..."
33+
"$pdb2pqr_bin" --ff=AMBER --whitespace --drop-water \
34+
--apbs-input "${PDB_ID}.in" "${PDB_ID}_chain.pdb" "${PDB_ID}.pqr"
35+
36+
echo "[apbs-prep] configuring APBS input (write potential map, 0.150 M NaCl)..."
37+
# Name the output map after the stem (-> <id>.dx) and add physiological salt.
38+
sed -i "s#write pot dx ${PDB_ID}.pqr#write pot dx ${PDB_ID}#" "${PDB_ID}.in"
39+
sed -i "s#^ lpbe# ion charge +1 conc 0.150 radius 2.0\n ion charge -1 conc 0.150 radius 2.0\n lpbe#" \
40+
"${PDB_ID}.in"
41+
42+
echo "[apbs-prep] running APBS (linearised Poisson-Boltzmann)..."
43+
apbs "${PDB_ID}.in"
44+
45+
# APBS appends a -PE0 processor tag for mg-auto runs; normalise the name.
46+
if [[ -f "${PDB_ID}-PE0.dx" ]]; then
47+
mv -f "${PDB_ID}-PE0.dx" "${PDB_ID}.dx"
48+
fi
49+
50+
echo "[apbs-prep] done -> ${HERE}/${PDB_ID}.pqr , ${HERE}/${PDB_ID}.dx"

‎scripts/demos/apbs.pml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Real APBS electrostatics demo.
2+
# Inputs are produced by scripts/apbs/prepare_apbs.sh (pdb2pqr + apbs):
3+
# scripts/apbs/2ewn.pqr per-atom charges/radii
4+
# scripts/apbs/2ewn.dx Poisson-Boltzmann potential map (kT/e)
5+
6+
# load the APBS-derived structure and potential map
7+
load scripts/apbs/2ewn.pqr, 2ewn
8+
load scripts/apbs/2ewn.dx, 2ewn_potential
9+
10+
# molecular surface coloured by electrostatic potential (-5 .. +5 kT/e)
11+
show surface, 2ewn
12+
ramp_new 2ewn_esp, 2ewn_potential, [-5, 0, 5], [red, white, blue]
13+
set surface_color, 2ewn_esp, 2ewn
14+
15+
# set the view (same camera as scripts/demos/surface.pml)
16+
set_view (\
17+
-0.278456718, 0.878569365, 0.388043523,\
18+
-0.570280433, 0.173850223, -0.802842677,\
19+
-0.772814512, -0.444850624, 0.452621192,\
20+
-0.000000000, 0.000000000, -208.479782104,\
21+
3.418830872, 47.872474670, -38.216609955,\
22+
164.367050171, 252.592514038, 20.000000000 )
23+
24+
# render & save
25+
ray 1920, 1080
26+
png assets/demo_apbs.png
27+
quit

0 commit comments

Comments
 (0)