Skip to main content

A simple module for handling protein backbone coordinates.

Project description

pdbutil.py

A simple module for handling protein backbone coordinates.

Requirement

  • python3.x
  • numpy
  • biopython

Usage

PDB file Read & Write

## Import functions
from pdbutil import read_pdb, write_pdb

## Read PDB file
data_dict = read_pdb('pdb_file_path.pdb')

data_dict: {
    'xyz_ca':    np.array [L, 3],    # C-alpha coordinates
    'xyz_bb':    np.array [L, 4, 3], # Backbone coordinates
    'xyz_aa':    list [L, np.array], # All-atom coordinates
    'chain':     np.array [L,],      # Chain ID
    'resnum':    np.array [L,],      # Residue number
    'res1':      np.array [L,],      # One letter AA type
    'res3':      np.array [L,],      # Three letter AA type
    'bfactor':   np.array [L,],      # B-factor
    'insertion': np.array [L,],      # Insertion code
    'pdbstring': str,                # PDB format string
}

## Get PDB format string
pdb_string = write_pdb(**data_dict)   # Full writing
pdb_string = write_pdb(xyz_ca=xyz_ca) # Only xyz is required

# Write as PDB file
write_pdb(**data_dict, pdb_file='output.pdb')

Superpose & RMSD

from pdbutil import superpose, calc_rmsd

## Superpose "Target" xyz (one or more) onto a "Reference" xyz
# xyz_reference.shape -> (L,3), (1,L,3), (L,4,3) or (1,L,4,3)
# xyz_targets.shape -> (L,3), (B,L,3), (L,4,3) or (B,L,4,3)

xyz_sup = superpose(xyz_reference, xyz_targets)

## Calculate C-alpha RMSD for all possible pairs
# xyz_ca1.shape -> (L,3), (1,L,3) or (B1,L,3)
# xyz_ca2.shape -> (L,3), (1,L,3) or (B2,L,3)

rmsd_matrix = calc_rmsd(xyz_ca1, xyz_ca2)
# rmsd_matrix.shape -> (B1, B2)

Author

License

MIT(https://choosealicense.com/licenses/mit/)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdbutil-2.0.7-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file pdbutil-2.0.7-py3-none-any.whl.

File metadata

  • Download URL: pdbutil-2.0.7-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pdbutil-2.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 380590a2d4c8fc01a96237b8e4bada7fa22fd1515e97f9bd62e9d5a07388f818
MD5 5d5a0bd75516acc4c5fde8fe4dcf5005
BLAKE2b-256 c988051c05fce5167e2968c1291ed79d0f8891da0c9388efe06e4bd243f3d4ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page