neurosnap.algos.pdb2pqr module#

Structure-first PDB2PQR integration for Neurosnap.

neurosnap.algos.pdb2pqr.assign_pqr(structure, *, forcefield='PARSE', ffout=None, neutraln=False, neutralc=False, assign_only=False, debump=True, optimize=True)[source]#

Assign PDB2PQR radii and partial charges to a local Structure.

The returned structure is rebuilt from the PDB2PQR-updated atom table and includes two float annotations:

  • partial_charge

  • radius

Parameters:
  • structure (Structure) – Input single-model structure.

  • forcefield (str) – PDB2PQR forcefield name.

  • ffout (Optional[str]) – Optional alternate output naming scheme.

  • neutraln (bool) – Make the N-terminus neutral. Only supported with PARSE.

  • neutralc (bool) – Make the C-terminus neutral. Only supported with PARSE.

  • assign_only (bool) – Assign parameters without repair, debumping, or hydrogen optimization.

  • debump (bool) – Run the PDB2PQR debumping routines.

  • optimize (bool) – Optimize hydrogens when assign_only is false.

Return type:

Structure

Returns:

A new Structure carrying PDB2PQR geometry updates and annotations.

Example

Basic structure-first PQR assignment and writing:

from neurosnap.io.pdb import parse_pdb
from neurosnap.algos.pdb2pqr import assign_pqr
from neurosnap.io.pqr import save_pqr

structure = parse_pdb(
  "tests/files/1nkp_mycmax_with_hydrogens.pdb",
  return_type="ensemble",
).first()

pqr_structure = assign_pqr(
  structure,
  forcefield="AMBER",
  assign_only=True,
)

print(pqr_structure.atom_annotations.dtype.names)
print(pqr_structure.atom_annotations["partial_charge"][:5])
print(pqr_structure.atom_annotations["radius"][:5])

save_pqr(pqr_structure, "test_output.pqr", include_header=True)

Quick smoke test on a standard PDB file:

from neurosnap.io.pdb import parse_pdb
from neurosnap.algos.pdb2pqr import assign_pqr

s = parse_pdb("tests/files/1BTL.pdb", return_type="ensemble").first()
out = assign_pqr(s, forcefield="AMBER", assign_only=True)
print(
  "partial_charge" in out.atom_annotations.dtype.names,
  "radius" in out.atom_annotations.dtype.names,
)

Inspect any automatic remediations or charge warnings:

from neurosnap.io.pdb import parse_pdb
from neurosnap.algos.pdb2pqr import assign_pqr
from neurosnap.io.pqr import save_pqr

structure = parse_pdb(
  "tests/files/1nkp_mycmax_with_hydrogens.pdb",
  return_type="ensemble",
).first()
pqr_structure = assign_pqr(structure, forcefield="AMBER", assign_only=True)

print(pqr_structure.metadata.get("pdb2pqr_remediations"))
print(pqr_structure.metadata.get("pdb2pqr_charge_warning"))
print("partial_charge" in pqr_structure.atom_annotations.dtype.names)
print("radius" in pqr_structure.atom_annotations.dtype.names)

save_pqr(pqr_structure, "test_output.pqr", include_header=True)