Skip to main content

Ramachandran plotting tool

Project description

Ramachandran plotting tool

ramachandraw coverage python version Poetry Ruff license: MIT PyPI PyPI - Downloads

Draws a Ramachandran plot based on the input PDB file (e.g. 1mbn.pdb). Makes use of a Gaussian KDE (kernel density estimation) to plot the density of favoured torsion angles (φ and ψ).

Single mode Batch mode

Installation

RamachanDraw is hosted on PyPi.

pip install ramachandraw

Usage

RamachanDraw includes useful functions to effortlessly draw a Ramachandran plot.

Fetch the PDB file

To draw a Ramachandran plot, we need a PDB file. RamachanDraw conveniently includes a function to automatically fetch and locally store the PDB file for the given PDB id.

Example

from ramachandraw.utils import fetch_pdb

fetch_pdb(pdb_id, verbose)
  • pdb_id (str|list|tuple): PDB id(s) corresponding to the PDB file(s) to be downloaded
  • verbose (bool) (optional): set the verbosity, defaults to False
  • Returns: path(s) to PDB file(s)

Extract φ and ψ torsion angles

RamachanDraw extracts the φ and ψ torsion angles from the PDB file by taking advantage of the Biopython module. Additionally, aminoacid residues that were not drawn on the plot can be extract using the return_ignored argument.

Example

from ramachandraw.parser import get_phi_psi

phi_psi(pdb_filepath, prune, hide_warnings)
  • pdb_id (str|list|tuple): PDB filepath(s)
  • prune (bool) (optional): prunes aminoacids with missing torsion angle(s), defaults to True
  • hide_warnings (bool) (optional): sets the verbosity of the PDB structure parser, defaults to True
  • Returns: Dictionary with keys as aminoacid residues and values as (φ, ψ) angles.

Ramachandran plot

Makes use of the matplotlib module to draw a highly customizable Ramachandran plot.

Example

from ramachandraw.utils import plot

plot(pdb_filepath, cmap="viridis", alpha=0.75, dpi=100, save=True, show=False, filename="plot.png")
  • pdb_file (str|list|tuple): PDB id(s) corresponding to the PDB entry to be downloaded
  • cmap (str) (optional): colormap to be used (from matplotlib) for the density of the favoured ("allowed") regions; default is viridis.
  • alpha (float) (optional): sets the opacity of the colormap (value between 0-1); default is 0.75.
  • dpi (int) (optional): resolution (in dots per inch); default is 100.
  • save (bool) (optional):
    • True: saves the plot locally; default is True.
  • show (bool) (optional):
    • True: shows the plot using the Qt5Agg backend; default is False.
  • filename (str) (optional): filename to be used in case the plot is saved (i.e. save=True); default is plot.png.
  • Returns: Ramachandran plot (matplotlib.axes.Axes object) that can be further customized if needed

Example

Herein you will find an example from the PDB id corresponding to the myoglobin entry: 1MBN - in the Protein Data Bank.

from ramachandraw.parser import get_phi_psi
from ramachandraw.utils import fetch_pdb, plot

# PDB id
pdb_id = "1mbn"

# Draw the Ramachandran plot
plot(fetch_pdb(pdb_id))

# Generate a dictionary to store the (phi, psi) torsion angles
torsion_angles = get_phi_psi(fetch_pdb(pdb_id))

Contributing

Feedback and constructive criticism is welcome. If necessary, open an issue in the issues tab.

License

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 Distribution

ramachandraw-1.0.1.tar.gz (85.1 kB view details)

Uploaded Source

Built Distribution

ramachandraw-1.0.1-py3-none-any.whl (83.8 kB view details)

Uploaded Python 3

File details

Details for the file ramachandraw-1.0.1.tar.gz.

File metadata

  • Download URL: ramachandraw-1.0.1.tar.gz
  • Upload date:
  • Size: 85.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.2 Darwin/23.3.0

File hashes

Hashes for ramachandraw-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1ce2cbdbe4457c2cdfab05c7ca14458d0b3b10916afd18b01642eec0f1e8f8de
MD5 b1a1de64ff34ac48bb820dfcd8f18793
BLAKE2b-256 4f69217c70a33e785dcb0752f1b75f115708b95031cb1184a23a0aad45f5c9ec

See more details on using hashes here.

File details

Details for the file ramachandraw-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ramachandraw-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 83.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.2 Darwin/23.3.0

File hashes

Hashes for ramachandraw-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 333b1baa22edee0e1faefdbcced5d4b05442d18c4a4da37cb67bfd6bfd75068a
MD5 e606c05f7b68d1b194e4ec0275719dd2
BLAKE2b-256 d1984de5516ce9ed3f296aa75f5c4919fd1df0aebbd93769ca34c2896cae6112

See more details on using hashes here.

Supported by

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