# PDBBasic
Basic Functions for Protein Structure Data
## Install
```
pip install pdbbasic
```
## Usage
``` python
import numpy as np
import torch
import pdbbasic as pdbb
# simple PDB file read
coord1 = pdbb.readpdb('filename.pdb')
# coord1.shape -> (N, 4, 3), N=length, 4=atoms:(N,CA,C,O), 3=coordinates:(x,y,z)
# read PDB with information (chain-id, residue-number, residue-type, occupancy, b-factor)
coord1, info1 = pdbb.readpdb('filename.pdb', with_info=True)
# read mmCIF file
coord1, info1 = pdbb.readmmcif('filename.cif', with_info=True)
# download from PDB
coord1, info1 = pdbb.download('7bqd', with_info=True)
# calc RMSD
ca1 = coord1[:,1]
ca2 = pdbb.readpdb('filename.pdb', CA_only=True)
rmsd_np = pdbb.rmsd(ca1, ca2)
# Kabsch superposition
coo_sup1, coo_sup2 = pdbb.kabsch(ca1, ca2)
# torsion angle
torsion = pdbb.torsion_angles(coord1)
# torsion.shape -> (N, 3), 3=dihedrals:(phi,psi,omega)
# distance matrix
distmat_within = pdbb.distance_matrix(ca1)
distmat_between = pdbb.distance_matrix(ca1, ca2)
# torch Tensor is applicable
rmsd_torch = pdbb.rmsd(torch.Tensor(ca1), torch.Tensor(ca2))
# Frame representation like AlphaFold (translation, rotation)
trans, rot = pdbb.coord_to_frame(coord1)
# trans.shape -> (N, 3), rot.shape -> (N, 3, 3)
frame = trans, rot
coord_recon = pdbb.frame_to_coord(frame)
# FAPE (Frame Aligned Position Error)
frame1 = pdbb.coord_to_frame(coord1)
frame2 = pdbb.coord_to_frame(coord2)
fape = pdbb.FAPE(frame1, frame2)
# batched calculation is applicable
ca_batch1 = np.repeat(np.expand_dims(ca1, axis=0), 100, axis=0)
ca_batch2 = np.repeat(np.expand_dims(ca2, axis=0), 100, axis=0)
bb_batch = np.repeat(np.expand_dims(coord1, axis=0), 100, axis=0)
rmsd_batch = pdbb.rmsd(ca_batch1, ca_batch2)
sup_batch1, sup_batch2 = pdbb.kabsch(ca_batch1, ca_batch2)
torsion_batch = pdbb.torsion_angles(bb_batch)
distmat_batch = pdbb.distance_matrix(ca_batch1)
coord_batch = np.repeat(np.expand_dims(coord1, axis=0), 100, axis=0)
frame_batch = pdbb.coord_to_frame(coord_batch)
coord_recon_batch = pdbb.frame_to_coord(frame_batch)
fape_batch = pdbb.FAPE(frame_batch, frame_batch)
# all against all RMSD calculation
rmsd_matrix = pdbb.rmsd_many_vs_many(ca_batch1)
```
## Requirement
* python3
* numpy
* pandas
* pytorch
* einops
Raw data
{
"_id": null,
"home_page": "https://github.com/ShintaroMinami/PDBBasic",
"name": "pdbbasic",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Shintaro Minami",
"author_email": "shintaro.minami@gmail.com",
"download_url": "",
"platform": null,
"description": "# PDBBasic\nBasic Functions for Protein Structure Data\n\n## Install\n```\npip install pdbbasic\n```\n\n## Usage\n``` python\nimport numpy as np\nimport torch\nimport pdbbasic as pdbb\n\n# simple PDB file read\ncoord1 = pdbb.readpdb('filename.pdb')\n# coord1.shape -> (N, 4, 3), N=length, 4=atoms:(N,CA,C,O), 3=coordinates:(x,y,z)\n\n# read PDB with information (chain-id, residue-number, residue-type, occupancy, b-factor)\ncoord1, info1 = pdbb.readpdb('filename.pdb', with_info=True)\n\n# read mmCIF file\ncoord1, info1 = pdbb.readmmcif('filename.cif', with_info=True)\n\n# download from PDB\ncoord1, info1 = pdbb.download('7bqd', with_info=True)\n\n# calc RMSD\nca1 = coord1[:,1]\nca2 = pdbb.readpdb('filename.pdb', CA_only=True)\n\nrmsd_np = pdbb.rmsd(ca1, ca2)\n\n# Kabsch superposition\ncoo_sup1, coo_sup2 = pdbb.kabsch(ca1, ca2)\n\n# torsion angle\ntorsion = pdbb.torsion_angles(coord1)\n# torsion.shape -> (N, 3), 3=dihedrals:(phi,psi,omega)\n\n# distance matrix\ndistmat_within = pdbb.distance_matrix(ca1)\ndistmat_between = pdbb.distance_matrix(ca1, ca2)\n\n# torch Tensor is applicable\nrmsd_torch = pdbb.rmsd(torch.Tensor(ca1), torch.Tensor(ca2))\n\n# Frame representation like AlphaFold (translation, rotation)\ntrans, rot = pdbb.coord_to_frame(coord1)\n# trans.shape -> (N, 3), rot.shape -> (N, 3, 3)\nframe = trans, rot\ncoord_recon = pdbb.frame_to_coord(frame)\n\n# FAPE (Frame Aligned Position Error)\nframe1 = pdbb.coord_to_frame(coord1)\nframe2 = pdbb.coord_to_frame(coord2)\nfape = pdbb.FAPE(frame1, frame2)\n\n# batched calculation is applicable\nca_batch1 = np.repeat(np.expand_dims(ca1, axis=0), 100, axis=0)\nca_batch2 = np.repeat(np.expand_dims(ca2, axis=0), 100, axis=0)\nbb_batch = np.repeat(np.expand_dims(coord1, axis=0), 100, axis=0)\n\nrmsd_batch = pdbb.rmsd(ca_batch1, ca_batch2)\nsup_batch1, sup_batch2 = pdbb.kabsch(ca_batch1, ca_batch2)\ntorsion_batch = pdbb.torsion_angles(bb_batch)\ndistmat_batch = pdbb.distance_matrix(ca_batch1)\n\ncoord_batch = np.repeat(np.expand_dims(coord1, axis=0), 100, axis=0)\nframe_batch = pdbb.coord_to_frame(coord_batch)\ncoord_recon_batch = pdbb.frame_to_coord(frame_batch)\nfape_batch = pdbb.FAPE(frame_batch, frame_batch)\n\n# all against all RMSD calculation\nrmsd_matrix = pdbb.rmsd_many_vs_many(ca_batch1)\n\n```\n\n## Requirement\n* python3\n* numpy\n* pandas\n* pytorch\n* einops\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Basic Utilities for Protein Structure Data",
"version": "0.8.0",
"project_urls": {
"Homepage": "https://github.com/ShintaroMinami/PDBBasic"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43f1bb261d5c5ef4432c05fd1199dacf2542dec5512f7e29bd26397ebc55764d",
"md5": "e907df36c904eca6f9c19f965405b5cc",
"sha256": "cdb7e989e03ee295be05b69ef5d85f4847f90edda338457ac81e45394df3aa6f"
},
"downloads": -1,
"filename": "pdbbasic-0.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e907df36c904eca6f9c19f965405b5cc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11762,
"upload_time": "2023-11-20T22:46:20",
"upload_time_iso_8601": "2023-11-20T22:46:20.524635Z",
"url": "https://files.pythonhosted.org/packages/43/f1/bb261d5c5ef4432c05fd1199dacf2542dec5512f7e29bd26397ebc55764d/pdbbasic-0.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-20 22:46:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ShintaroMinami",
"github_project": "PDBBasic",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pdbbasic"
}