Plasmid map of a pet28a vectorΒΆ

This script downloads the GenBank file for a pET28a plasmid from AddGene and draws a plasmid map using a custom feature formatter.

  • Promoters - green arrow

  • Terminators - red arrow

  • Protein binding sites - light green rectangle

  • RBS - light orange rectangle

  • CDS - orange arrow

  • Ori - gray arrow

  • Primer - blue arrow

plasmid map
# Code source: Patrick Kunzmann
# License: BSD 3 clause

import io
import requests
import matplotlib.pyplot as plt
import numpy as np
import biotite
import as gb
import as graphics
import biotite.database.entrez as entrez

              "v1.6.2-0-g4b4ed87/sequences/67/17/246717/" \

response = requests.get(PLASMID_URL)
gb_file =
annotation = gb.get_annotation(gb_file, include_only=[
    "promoter", "terminator", "protein_bind",
    "RBS", "CDS", "rep_origin", "primer_bind"
_, seq_length, _, _, _, _ = gb.get_locus(gb_file)
# AddGene stores the plasmid name in the 'KEYWORDS' field
# [0][0][0] ->
# The first (and only) 'KEYWORDS' field
# The first entry in the tuple
# The first (and only) line in the field
plasmid_name = gb_file.get_fields("KEYWORDS")[0][0][0]

def custom_feature_formatter(feature):
    # AddGene stores the feature label in the '\label' qualifier
    label = feature.qual.get("label")
    if feature.key == "promoter":
        return True, biotite.colors["dimgreen"], "black", label
    elif feature.key == "terminator":
        return True, "firebrick", "black", label
    elif feature.key == "protein_bind":
        return False, biotite.colors["lightgreen"], "black", label
    elif feature.key == "RBS":
        return False, biotite.colors["brightorange"], "black", label
    elif feature.key == "CDS":
        return True, biotite.colors["orange"], "black", label
    elif feature.key == "rep_origin":
        return True, "lightgray", "black", label
    elif feature.key == "primer_bind":
        return True, "blue", "black", label

fig = plt.figure(figsize=(8.0, 8.0))
ax = fig.add_subplot(111, projection="polar")
    ax, annotation, plasmid_size=seq_length,
    label=plasmid_name, feature_formatter=custom_feature_formatter

Gallery generated by Sphinx-Gallery