A small python module that can parse PDB files as pandas DataFrames.
Project description
pdbUtils
Usage
This is a small python module that can parse PDB files as pandas DataFrames.
PDB formatting can be all over the place depending on how they have been created. PdbUtils has been written such that it tolerates all sorts of weird stuff when reading a PDB file, but writes PDB files strictly according to PDB formatting rules: https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html
You can load a pdb file as a DataFrame by:
import pdbUtils
myPdbFile = "/home/eugene/5xh3.pdb"
pdbDf = pdbUtils.pdb2df(myPdbFile)
Once loaded as a DataFrame, you can modiy and interrogate it to your heart's content. You can access each column of your new DataFrame using the following column names:
print(pdbDf["ATOM"]) ## string "ATOM" or "HETATM"
print(pdbDf["ATOM_ID"]) ## int atom number
print(pdbDf["ATOM_NAME"]) ## string atom name (eg. "OG")
print(pdbDf["RES_NAME"]) ## string residue name (eg. "SER")
print(pdbDf["CHAIN_ID"]) ## chain identifier (eg. "B")
print(pdbDf["RES_ID"]) ## string residue number (eg. "131")
print(pdbDf["X"]) ## float X coordinate
print(pdbDf["Y"]) ## float Y coordinate
print(pdbDf["Z"]) ## float Z coordinate
print(pdbDf["OCCUPANCY"]) ## float occupancy (usually 1.00 or 0.00)
print(pdbDf["BETAFACTOR"]) ## float betafactor or pLDDT if it's a structural prediction
print(pdbDf["ELEMENT"]) ## string element (eg. "O")
When you want to write back to a PDB file:
outPdbFile = "home/eugene/5xh3_new.pdb"
pdbUtils.pdb2df(pdbDf, outPdbFile)
I have also added the function to read AutoDock PDBQT files in the same manner:
import pdbUtils
myPdbqtFile = "/home/eugene/5xh3.pdbqt"
pdbDf = pdbUtils.pdbqt2df(myPdbFile)
Installation
- Clone this repo
git clone https://github.com/ESPhoenix/pdbUtils
- Install Pandas (unless you already have it!)
pip install pandas
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file pdbUtils-2024.0.0-py3-none-any.whl
.
File metadata
- Download URL: pdbUtils-2024.0.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9908de30a0e1fcd1aa1d46fa9508bd16d4acc2c2f362b4522769a378333c9ec5 |
|
MD5 | 2b34ba1ff33d37a19b3f277483763c41 |
|
BLAKE2b-256 | a166202f38d7fa6a9683111363364546b92d528cd8116f97da6c003df87ec558 |