Many researchers struggle to get a clear, publication‑ready view of circular genomes. Common pain points include: figuring out how to plot GC‑skew or local GC deviation, adding feature tracks without manual tweaking, ensuring the circle scales correctly for different sequence lengths, and avoiding cluttered axis labels that hide important details. The provided Python function solves these issues by packing all of the usual circular‑map elements into a single, reproducible routine.
First, make sure you have the required libraries: Biopython for SeqRecord handling, NumPy for linspace, and Matplotlib for drawing. Load your genome (or plasmid) as a SeqRecord object, then call circular_map(rec, title="My Plasmid", show_gc=True). The function automatically computes the mean GC content, draws a deviating GC track in two contrasting colors, places evenly spaced ticks with base‑pair numbers, and paints each feature as a thick colored arc with an arrow‑like tip indicating strand direction. Because the geometry is calculated internally, you do not need to worry about converting coordinates manually; the helper functions _ang, _pt, and _arc take care of the circular math.
If your feature list lacks color or strand information, add them before calling the function—e.g., set f["color"] = "#ff7f0e" and f["strand"] = 1 for forward, -1 for reverse. Adjust the w (window size) and step parameters if you notice the GC track looks too noisy or too smooth for your genome size. The output figure is displayed inline; to save it, replace plt.show() with plt.savefig("my_circular_map.png", dpi=300).
By using this self‑contained script you eliminate the need for multiple plugins, reduce trial‑and‑error formatting, and obtain a consistent, high‑resolution circular map ready for presentations or supplements.