Skip to main content

Ramachandran plotting tool

ramachandraw coverage python version uv 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", title=None)
  • 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.
  • title (str|None) (optional): custom title for the plot. If None, defaults to the PDB filepath.
  • 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.

Single PDB

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))

Batch of PDBs

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


# PDB id
pdb_ids = ["1mbn", "4hhb"]

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

# Generate a list of dictionaries to store the (phi, psi) torsion angles
torsion_angles = get_phi_psi(fetch_pdb(pdb_ids))

Contributing

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

License

MIT

Metadata

Release files for ramachandraw 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ramachandraw 2.0.0
File Size Uploaded Provenance
ramachandraw-2.0.0.tar.gz 84.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ramachandraw 2.0.0
File Interpreter ABI Platform
ramachandraw-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 168.7 kB

Release files / ramachandraw-2.0.0.tar.gz

Download URL ramachandraw-2.0.0.tar.gz
Size 84.8 kB
Tags Source
SHA-256 checksum
How to use checksums
21881b2464e0a3e5dde5b5b1c99fb148643c7bad6562a0502a0dfaacefc5244e
BLAKE2b-256 checksum
How to use checksums
73b364d524fe7fef6d7d6e83e0bd61f258f9c1f9ae4025ea533af9092e5bf660
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / ramachandraw-2.0.0-py3-none-any.whl

Download URL ramachandraw-2.0.0-py3-none-any.whl
Size 83.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
091caf7a9918f224cdb5f4b7bf0b10ee4760be55ec15c89b3b8c447e44402412
BLAKE2b-256 checksum
How to use checksums
4351e7cd4a49b63f0597280c3eb1d2021ba46d13166d06cb84c654a8cf7d4d3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for ramachandraw 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ramachandraw-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page