PDB2PQR

3.7.1 · active · verified Tue Apr 14

PDB2PQR is a Python software package designed to automate the preparation of biomolecular structures for continuum solvation calculations and various other modeling, analysis, and simulation tasks. It processes PDB files, adding missing heavy atoms and hydrogens, optimizing hydrogen bonding, estimating titration states, and assigning atomic charges and radii from various force fields to generate PQR files. The current version is 3.7.1, and the project maintains an active release cadence with updates typically on an annual or semi-annual basis.

Warnings

Install

Quickstart

PDB2PQR is primarily used as a command-line tool. This quickstart demonstrates how to execute it from Python using the `subprocess` module to convert a PDB file to PQR format. It creates a simple dummy PDB file, runs the `pdb2pqr` command, and then prints the output PQR file content. For real-world usage, the command-line arguments would be expanded to include options for force fields, pH calculation, hydrogen bonding optimization, etc.

import subprocess
import os

# Create a dummy PDB file for demonstration
pdb_content = """
HETATM    1  N   UNL A   1      -0.003  -0.003   0.000  1.00  0.00           N
HETATM    2  C   UNL A   1       1.400   0.001   0.000  1.00  0.00           C
HETATM    3  O   UNL A   1       2.000  -0.800   0.000  1.00  0.00           O
END
"""
with open("dummy.pdb", "w") as f:
    f.write(pdb_content)

input_pdb = "dummy.pdb"
output_pqr = "dummy.pqr"

try:
    # Run pdb2pqr as a command-line tool via subprocess
    # Using --keep-chain to preserve chain IDs, --ff=PARSE for force field, --clean for minimal processing
    # Note: For complex proteins, you would typically use options like --with-ph, --titration-state-method=propka, etc.
    command = [
        "pdb2pqr",
        "--keep-chain",
        "--ff=PARSE",
        "--clean", # Use --clean to skip optimization for a minimal example
        input_pdb,
        output_pqr
    ]
    print(f"Executing command: {' '.join(command)}")
    result = subprocess.run(command, capture_output=True, text=True, check=True)
    print("PDB2PQR ran successfully.")
    print("STDOUT:", result.stdout)
    print("STDERR:", result.stderr)

    if os.path.exists(output_pqr):
        print(f"Generated PQR file: {output_pqr}")
        with open(output_pqr, "r") as f:
            print("\nContent of dummy.pqr:")
            print(f.read())
    else:
        print("Error: PQR file not generated.")

except FileNotFoundError:
    print("Error: 'pdb2pqr' command not found. Please ensure pdb2pqr is installed and in your PATH.")
except subprocess.CalledProcessError as e:
    print(f"Error running pdb2pqr: {e}")
    print("STDOUT:", e.stdout)
    print("STDERR:", e.stderr)
finally:
    # Clean up dummy files
    if os.path.exists(input_pdb):
        os.remove(input_pdb)
    if os.path.exists(output_pqr):
        os.remove(output_pqr)

view raw JSON →