A Python toolkit and course project for turning annotated DNA sequences into publication-ready linear, circular, and interactive diagrams.
- 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.
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:
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-gffbokehandpandasenable interactive plots.bcbio-gffenables GFF parsing.
python examples/graphic_record_defined_by_hand.py
python examples/from_genbank.py
python examples/plot_with_bokeh.pyMore examples are available in examples/.
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
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.
