pdbutil.py
===
A simple module for handling protein backbone coordinates.
## Requirement
* python3.x
* numpy
* biopython
## Usage
#### PDB file Read & Write
``` python
## 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': np.array [L,14, 3], # All-atom coordinates
'mask_aa': np.array [L,14], # Boolian array to address existing (=True) atoms
'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
'occupancy': np.array [L,], # Occupancy
'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
```python
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)
# Case of (L, 3) x (L, 3) -> float
rmsd = calc_rmsd(xyz_ca1, xyz_ca2)
# Case of (B1, L, 3) x (B2, L, 3) -> (B1, B2)
rmsd_matrix = calc_rmsd(xyz_ca1, xyz_ca2)
```
#### FASTA file Read & Write
``` python
## Import functions
from pdbutil import read_fasta
## Read FASTA file -> fasta object
fasta = read_fasta('fasta_file_path.fasta')
## Get deflines/sequences
deflines = fasta.deflines # list[str], e.g. ['protein1', 'protein2', ...]
sequences = fasta.sequences # list[str], e.g. ['SEQUENCE1', 'SEQUENCE2', ...]
## Use the object as an Iterator
for data in fasta:
print(data.defline)
print(data.sequence)
## To get FASTA format string
fasta_string = str(fasta)
## To print as FASTA format on STDOUT
print(fasta)
```
## Author
* Shintaro Minami(https://github.com/ShintaroMinami)
* shintaro.minami@gmail.com
## License
MIT(https://choosealicense.com/licenses/mit/)
Raw data
{
"_id": null,
"home_page": "https://github.com/ShintaroMinami/pdbutil",
"name": "pdbutil",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "pdb, backbone",
"author": "Shintaro Minami",
"author_email": "shintaro.minami@gmail.com",
"download_url": null,
"platform": null,
"description": "pdbutil.py\n===\n\nA simple module for handling protein backbone coordinates.\n\n## Requirement\n* python3.x\n* numpy\n* biopython\n\n## Usage\n#### PDB file Read & Write\n``` python\n## Import functions\nfrom pdbutil import read_pdb, write_pdb\n\n## Read PDB file\ndata_dict = read_pdb('pdb_file_path.pdb')\n\ndata_dict: {\n 'xyz_ca': np.array [L, 3], # C-alpha coordinates\n 'xyz_bb': np.array [L, 4, 3], # Backbone coordinates\n 'xyz_aa': np.array [L,14, 3], # All-atom coordinates\n 'mask_aa': np.array [L,14], # Boolian array to address existing (=True) atoms\n 'chain': np.array [L,], # Chain ID\n 'resnum': np.array [L,], # Residue number\n 'res1': np.array [L,], # One letter AA type\n 'res3': np.array [L,], # Three letter AA type\n 'occupancy': np.array [L,], # Occupancy\n 'bfactor': np.array [L,], # B-factor\n 'insertion': np.array [L,], # Insertion code\n 'pdbstring': str, # PDB format string\n}\n\n## Get PDB format string\npdb_string = write_pdb(**data_dict) # Full writing\npdb_string = write_pdb(xyz_ca=xyz_ca) # Only xyz is required\n\n# Write as PDB file\nwrite_pdb(**data_dict, pdb_file='output.pdb')\n```\n\n#### Superpose & RMSD\n```python\nfrom pdbutil import superpose, calc_rmsd\n\n## Superpose \"Target\" xyz (one or more) onto a \"Reference\" xyz\n# xyz_reference.shape -> (L,3), (1,L,3), (L,4,3) or (1,L,4,3)\n# xyz_targets.shape -> (L,3), (B,L,3), (L,4,3) or (B,L,4,3)\n\nxyz_sup = superpose(xyz_reference, xyz_targets)\n\n## Calculate C-alpha RMSD for all possible pairs\n# xyz_ca1.shape -> (L,3), (1,L,3) or (B1,L,3)\n# xyz_ca2.shape -> (L,3), (1,L,3) or (B2,L,3)\n\n# Case of (L, 3) x (L, 3) -> float\nrmsd = calc_rmsd(xyz_ca1, xyz_ca2)\n\n# Case of (B1, L, 3) x (B2, L, 3) -> (B1, B2)\nrmsd_matrix = calc_rmsd(xyz_ca1, xyz_ca2)\n```\n\n#### FASTA file Read & Write\n``` python\n## Import functions\nfrom pdbutil import read_fasta\n\n## Read FASTA file -> fasta object\nfasta = read_fasta('fasta_file_path.fasta')\n\n## Get deflines/sequences\ndeflines = fasta.deflines # list[str], e.g. ['protein1', 'protein2', ...]\nsequences = fasta.sequences # list[str], e.g. ['SEQUENCE1', 'SEQUENCE2', ...]\n\n## Use the object as an Iterator\nfor data in fasta:\n print(data.defline)\n print(data.sequence)\n\n## To get FASTA format string\nfasta_string = str(fasta)\n\n## To print as FASTA format on STDOUT\nprint(fasta)\n\n```\n\n## Author\n* Shintaro Minami(https://github.com/ShintaroMinami)\n* shintaro.minami@gmail.com\n\n## License\nMIT(https://choosealicense.com/licenses/mit/)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A simple module for handling protein backbone coordinates.",
"version": "2.1.3",
"project_urls": {
"Homepage": "https://github.com/ShintaroMinami/pdbutil"
},
"split_keywords": [
"pdb",
" backbone"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "55de5fb597540ba25018d2dd7a9ecd3d1d98b4a11142a853bd7700f1f1ca880d",
"md5": "48c0db4f3933bb3dd8f69567df9cffd0",
"sha256": "0f242459af57c3834a64277c0e40ce3354c0307056a952be241115e741c216d0"
},
"downloads": -1,
"filename": "pdbutil-2.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "48c0db4f3933bb3dd8f69567df9cffd0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 25211,
"upload_time": "2025-07-09T05:21:13",
"upload_time_iso_8601": "2025-07-09T05:21:13.415902Z",
"url": "https://files.pythonhosted.org/packages/55/de/5fb597540ba25018d2dd7a9ecd3d1d98b4a11142a853bd7700f1f1ca880d/pdbutil-2.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-09 05:21:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ShintaroMinami",
"github_project": "pdbutil",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "setuptools",
"specs": []
},
{
"name": "numpy",
"specs": []
},
{
"name": "biopython",
"specs": []
}
],
"lcname": "pdbutil"
}