Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNA Plot Visualization

A Python toolkit and course project for turning annotated DNA sequences into publication-ready linear, circular, and interactive diagrams.

Python Matplotlib Biopython

What it does

  • Draws features such as genes, promoters, and coding regions on linear DNA records.
  • Renders circular constructs and plasmid-style maps.
  • Imports annotations from Biopython records, GenBank files, and optionally GFF files.
  • Exports static figures through Matplotlib and interactive plots through Bokeh.
  • Includes examples for multi-line, overview/detail, sequence, translation, and GC-content views.

Example

from DnaPlotVisualization import GraphicFeature, GraphicRecord

features = [
    GraphicFeature(start=20, end=500, strand=+1, color="#ffcccc", label="Gene 1"),
    GraphicFeature(start=400, end=700, strand=-1, color="#cffccc", label="Gene 2"),
]

record = GraphicRecord(sequence_length=1000, features=features)
ax, _ = record.plot(figure_width=6)
ax.figure.savefig("dna_record.png", bbox_inches="tight")

Example output:

Linear DNA feature plot

Installation

Clone the repository and install it locally:

git clone https://github.com/JaspinXu/DnaPlotVisualization.git
cd DnaPlotVisualization
python -m pip install .

The core package installs Matplotlib, Biopython, and Packaging. Optional features require:

python -m pip install bokeh pandas bcbio-gff
  • bokeh and pandas enable interactive plots.
  • bcbio-gff enables GFF parsing.

Run the examples

python examples/graphic_record_defined_by_hand.py
python examples/from_genbank.py
python examples/plot_with_bokeh.py

More examples are available in examples/.

Project structure

DnaPlotVisualization/
  GraphicFeature.py          Feature model and display properties
  GraphicRecord/             Linear plotting and Matplotlib/Bokeh mixins
  CircularGraphicRecord/     Circular plotting primitives
  BiopythonTranslator/       Biopython annotation conversion
  biotools.py                Sequence and annotation utilities
examples/                    Reproducible plotting examples and outputs
tests/                       Tests and sample GenBank/GFF data
setup.py                     Package metadata and dependencies

Project context

This repository was assembled as an Introduction to Life Sciences project. It focuses on learning and demonstrating programmatic biological-sequence visualization rather than publishing a new plotting library. The implementation and examples build on the design patterns of the open-source DNA Features Viewer ecosystem.

About

Python toolkit and course project for linear, circular, and interactive DNA sequence visualization with Biopython, Matplotlib, and Bokeh.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages