<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PlasmidLab</title>
    <description>The latest articles on DEV Community by PlasmidLab (@plasmidlab).</description>
    <link>https://dev.to/plasmidlab</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250935%2F9de73453-e5e3-4d2f-89c8-aaf2d6bf2bb4.png</url>
      <title>DEV Community: PlasmidLab</title>
      <link>https://dev.to/plasmidlab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/plasmidlab"/>
    <language>en</language>
    <item>
      <title>What is inside an annotated plasmid file, and why you cannot rename .dna to .gb</title>
      <dc:creator>PlasmidLab</dc:creator>
      <pubDate>Wed, 18 Nov 2026 04:36:17 +0000</pubDate>
      <link>https://dev.to/plasmidlab/what-is-inside-an-annotated-plasmid-file-and-why-you-cannot-rename-dna-to-gb-fnk</link>
      <guid>https://dev.to/plasmidlab/what-is-inside-an-annotated-plasmid-file-and-why-you-cannot-rename-dna-to-gb-fnk</guid>
      <description>&lt;h1&gt;
  
  
  What is inside an annotated plasmid file, and why you cannot rename .dna to .gb
&lt;/h1&gt;

&lt;p&gt;Renaming a binary &lt;code&gt;.dna&lt;/code&gt; file to &lt;code&gt;.gb&lt;/code&gt; gives you a file that no GenBank parser will read, because the two formats share an idea and nothing else. Anyone who writes code for plasmid maps learns this the same way: a rename fails, a parser throws, and the real differences between the formats turn up one bug at a time.&lt;/p&gt;

&lt;p&gt;The details come from the reader and writer code in PlasmidLab, which opens both.&lt;/p&gt;

&lt;h2&gt;
  
  
  More than bases
&lt;/h2&gt;

&lt;p&gt;A FASTA file is a name and a string of letters. A plasmid map needs more:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the bases, with flags for circular or linear and for double- or single-stranded&lt;/li&gt;
&lt;li&gt;features: a type, a name, one or more segments with start and end, a strand, and free-form qualifiers&lt;/li&gt;
&lt;li&gt;primers, with their full sequences, which often include a 5' tail that matches nothing on the template&lt;/li&gt;
&lt;li&gt;notes such as description, organism and accession&lt;/li&gt;
&lt;li&gt;editing state such as feature colours and which items are visible&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What GenBank looks like
&lt;/h2&gt;

&lt;p&gt;GenBank is text with fixed columns. A feature key starts at column 6 and its location at column 22. Qualifiers sit on their own lines, indented 21 spaces. Our writer wraps qualifier text at 58 characters after that indent, so every line stays within 79 columns. A feature looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     CDS             complement(join(2900..3000,1..420))
                     /label="exampleR"
                     /note="crosses the origin on the bottom strand"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sequence follows an &lt;code&gt;ORIGIN&lt;/code&gt; line, 60 bases per line in blocks of ten, each line starting with a right-aligned base number. A record ends with &lt;code&gt;//&lt;/code&gt;, and one file can hold several records.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;LOCUS&lt;/code&gt; line packs name, length, molecule type, topology, division and date into fixed positions. Our writer pads the name to 16 characters and cuts it there. Our reader does not trust the positions. It splits the line on whitespace, takes the second token as the name, looks for the word &lt;code&gt;circular&lt;/code&gt;, and checks for an &lt;code&gt;ss-&lt;/code&gt; prefix on the molecule type. It ignores the length on that line and counts the bases under &lt;code&gt;ORIGIN&lt;/code&gt;. The writer turns spaces in a name into underscores.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locations
&lt;/h2&gt;

&lt;p&gt;GenBank coordinates are 1-based and inclusive: &lt;code&gt;1..10&lt;/code&gt; is the first ten bases. Most code works with 0-based positions, so the conversion happens once, at the reader and the writer: ours subtracts one from each end on the way in and adds one on the way out. An off-by-one here is silent. The feature draws one base to the left and nothing complains.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;complement(...)&lt;/code&gt; puts a feature on the bottom strand. &lt;code&gt;join(a..b,c..d)&lt;/code&gt; makes one feature from several segments, which is how exons are listed and also how a feature crosses the origin. &lt;code&gt;&amp;lt;1..300&lt;/code&gt; and &lt;code&gt;1..&amp;gt;300&lt;/code&gt; say the feature continues past the record. For a CDS that matters, because a cut-off 5' end does not start at a start codon. Our reader strips the brackets from the coordinates but remembers the case, so the first codon is translated as written instead of being forced to Met. A site between two bases, &lt;code&gt;5^6&lt;/code&gt;, has no representation in our model, so the reader collapses it to base 5.&lt;/p&gt;

&lt;h2&gt;
  
  
  The feature that crosses the origin
&lt;/h2&gt;

&lt;p&gt;A circular plasmid has no end, so a feature can start at base 2900 of a 3,000 bp plasmid and finish at base 420. GenBank cannot say &lt;code&gt;2900..420&lt;/code&gt;. It says &lt;code&gt;join(2900..3000,1..420)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A reader that wants one segment has to recognise this. Ours collapses a two-part join into a single wrapping segment only when the first part ends at the last base and the second starts at base 1. A join of two ordinary exons stays two segments. In memory our convention is that an end before a start means a wrap, which is legal only on a circular sequence. On a linear sequence the same numbers mean two pieces, and our reader splits them. The writer goes the other way and emits &lt;code&gt;join(start..n,1..end)&lt;/code&gt; whenever a segment's end comes before its start.&lt;/p&gt;

&lt;p&gt;Wrap the join in &lt;code&gt;complement(&lt;/code&gt; and you have a bottom-strand feature across the origin. A second form complements each piece and lists the pieces in biological 5' to 3' order. A reader has to cope with both. Ours treats any &lt;code&gt;complement(&lt;/code&gt; as reverse, which settles direction but leaves segment order as the file wrote it. The reader also needs the sequence length to interpret a wrap, so the bases must be known before the features can be finished.&lt;/p&gt;

&lt;h2&gt;
  
  
  The binary .dna container
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;.dna&lt;/code&gt; file is a sequence of packets. Each has one byte of type, a four-byte big-endian length, and that many bytes of data. The first packet is type 9 and its data begins with the ASCII text &lt;code&gt;SnapGene&lt;/code&gt;. The reader checks that cookie first, then checks that the lengths add up to exactly the file size and rejects a short final packet, so a truncated download does not open as a smaller plasmid.&lt;/p&gt;

&lt;p&gt;The packets our code interprets:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;type 0: a flags byte, then the sequence as UTF-8 text. Bit 1 of the flags is circular, 2 is double-stranded, and 4, 8 and 16 are Dam, Dcm and EcoKI methylation.&lt;/li&gt;
&lt;li&gt;type 10: features as XML. Directionality is 0, 1, 2 or 3 (none, forward, reverse, both). Each segment has a &lt;code&gt;start-end&lt;/code&gt; range, 1-based, and a colour. Qualifiers are &lt;code&gt;Q&lt;/code&gt; elements.&lt;/li&gt;
&lt;li&gt;type 5: primers as XML, with binding sites and hybridization settings.&lt;/li&gt;
&lt;li&gt;type 6: notes as XML.&lt;/li&gt;
&lt;li&gt;type 7: the edit history, xz-compressed.&lt;/li&gt;
&lt;li&gt;type 20: per-base colours.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Packets we do not interpret are kept as raw bytes and written back unchanged while the sequence is unedited. After an edit, packets that depend on base positions are dropped, because stale coordinates do more harm than missing ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a rename fails
&lt;/h2&gt;

&lt;p&gt;A GenBank reader looks for the text &lt;code&gt;LOCUS&lt;/code&gt;. A &lt;code&gt;.dna&lt;/code&gt; file starts with a byte of value 9, a length, and then &lt;code&gt;SnapGene&lt;/code&gt;. The extension is only a hint, so our reader decides by content. A name ending in &lt;code&gt;.dna&lt;/code&gt; is believed only if the first 4,096 bytes contain a zero byte, which text never does, or the cookie is present. GenBank text saved under a &lt;code&gt;.dna&lt;/code&gt; name is read as GenBank.&lt;/p&gt;

&lt;h2&gt;
  
  
  What conversion keeps and what it loses
&lt;/h2&gt;

&lt;p&gt;Going from &lt;code&gt;.dna&lt;/code&gt; to GenBank, our writer keeps the bases, circularity, strandedness, features with their segments, strand and qualifiers, feature colours (as &lt;code&gt;ApEinfo_fwdcolor&lt;/code&gt; and &lt;code&gt;ApEinfo_revcolor&lt;/code&gt; qualifiers), and the description, organism and accession.&lt;/p&gt;

&lt;p&gt;It drops the edit history, the methylation flags, per-base colours, hybridization settings, segment attributes such as translation numbering, and feature visibility. Direction narrows as well. GenBank has complement or not, so a feature with no direction, or with both, comes back as forward.&lt;/p&gt;

&lt;p&gt;Primers are the clearest case. GenBank has &lt;code&gt;primer_bind&lt;/code&gt; for where a primer sits, but nothing for the whole oligo, and a tail matches no template base. Our writer puts the binding site in a &lt;code&gt;primer_bind&lt;/code&gt; feature with the full sequence in a note. It also stores each primer's complete record as base64 JSON in the &lt;code&gt;COMMENT&lt;/code&gt; section. That is our own convention. Other programs show the primer where it binds and ignore the rest. Our reader accepts a re-wrapped comment, since base64 survives a cut at any column.&lt;/p&gt;

&lt;p&gt;The other direction loses nothing that was not already missing, since GenBank holds no history to begin with. FASTA keeps only the bases, so a circular plasmid and a linear one look the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two more parsing details
&lt;/h2&gt;

&lt;p&gt;Multi-line qualifiers have to be joined on purpose: a translation joins with no spaces, other values with one. Quotes inside GenBank values are escaped by doubling, and a line starting with &lt;code&gt;/&lt;/code&gt; can still sit inside a quoted value.&lt;/p&gt;

&lt;p&gt;PlasmidLab reads and writes both formats and is free for Mac and Windows: &lt;a href="https://plasmidlab.com/" rel="noopener noreferrer"&gt;plasmidlab.com&lt;/a&gt;. There is a short guide to &lt;a href="https://plasmidlab.com/guides/open-dna-genbank/" rel="noopener noreferrer"&gt;opening .dna and GenBank files&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;SnapGene is a trademark of GSL Biotech LLC; PlasmidLab is not affiliated with or endorsed by them.&lt;/p&gt;

</description>
      <category>bioinformatics</category>
      <category>genbank</category>
    </item>
  </channel>
</rss>
