4aa77873cb618e254b2f90d091d7bdef844947c2
max
  Wed Jul 8 04:28:42 2026 -0700
Let assembly hubs assign genetic codes per sequence for amino acid display

Adds a "codonTable" genomes.txt setting, e.g. "codonTable default=1
NC_017929.1=13", so an assembly hub can pick the NCBI translation table used to
show amino acids for each sequence.  New hGeneticCodeForChrom(db, chrom) in
hdb.c resolves the code (per-db cached), falling back to the previous behavior:
chrM/chrMT use the vertebrate mitochondrial code, everything else the standard
code.

Wired into the two browser display paths, which both go through cds.c's
baseColorLookupCodon: the base position track three-frame translation and
codon-colored annotation tracks such as gene predictions (also PSL/BAM).  Also
used for the hgc SNP amino acid details, and genePredTranslate gains a db
parameter (genePredToProt gains an optional -db flag) so command-line
translation can honor the same setting.  Documented in assemblyHubHelp.html.
refs #16550

diff --git src/hg/htdocs/goldenPath/help/assemblyHubHelp.html src/hg/htdocs/goldenPath/help/assemblyHubHelp.html
index ed4a8992044..39f1d17cb4c 100755
--- src/hg/htdocs/goldenPath/help/assemblyHubHelp.html
+++ src/hg/htdocs/goldenPath/help/assemblyHubHelp.html
@@ -153,30 +153,32 @@
     <li><strong>description</strong> is displayed on the Gateway page and title pages for this
 	    assembly. It also appears in the assembly pull-down menu.</li>
     <li><strong>twoBitPath</strong> points to the <em>.2bit</em> sequence file for the assembly.
 	    This file is typically generated from FASTA files using the <em>faToTwoBit</em>
 	    kent program. The path can also point to a URL.</li>
     <li><strong>organism</strong> is displayed alongside the description on title pages. It also
 	    appears in the assembly pull-down menu.</li>
     <li><strong>defaultPos</strong> defines the initial view in the Genome Browser, usually
 	    highlighting a popular gene or region of interest.</li>
     <li><strong>orderKey</strong> controls the ordering of assemblies in the pull-down menu.</li>
     <li><strong>htmlPath</strong> points to the HTML file with assembly information. The HTML file
 	    is displayed on the Gateway page.</li>
     <li><strong>transBlat</strong>, <strong>blat</strong>, and <strong>isPcr</strong> configure
 	    different gfServer instances for amino acid searches, BLAT alignments, and PCR.
 	    <a href="#configuringAssemblyHubs"> More here.</a></li>
+    <li><strong>codonTable</strong> assigns genetic codes (translation tables) to sequences for
+	    amino acid display. <a href="#codonTable">More here.</a></li>
 </ul>
 <p><b>Note</b>: it is strongly recommended that each genome stanza includes <em>defaultPos</em>,
 <em>scientificName</em>, <em>organism</em>, <em>description</em>, so that the hub loads with
 meaningful defaults and can be more easily searched from the Gateway page.</p>
 
 <a id="twoBitFile"></a>
 <h3>2bit File</h3>
 <p>
 The <strong>.2bit</strong> file is constructed from the FASTA sequence for the assembly using the
 <strong>faToTwoBit</strong> <em>kent</em> program (available from the
 <a href="https://hgdownload.gi.ucsc.edu/admin/exe/" target="_blank">downloads</a> page).</p>
 <p>Example:</p>
 <pre>
 faToTwoBit ricCom1.fa ricCom1.2bit
 </pre>
@@ -304,30 +306,66 @@
 genome GCF_000001405.39
 taxId 9606
 groups groups.txt
 description human
 twoBitPath GCF_000001405.39.2bit
 twoBitBptUrl GCF_000001405.39.2bit.bpt
 chromSizes GCF_000001405.39.chrom.sizes.txt
 chromAlias GCF_000001405.39.chromAlias.txt
 chromAuthority ucsc
 organism human
 defaultPos chr1:82985474-82995474
 scientificName Homo sapiens
 htmlPath html/GCF_000001405.39_GRCh38.p13.description.html
 </pre>
 
+<a id="codonTable"></a>
+<p><b>Genetic Codes (codon translation tables)</b></p>
+<p>By default the Genome Browser translates codons to amino acids with the standard genetic code,
+except for sequences named <code>chrM</code> or <code>chrMT</code>, which use the vertebrate
+mitochondrial code. An assembly hub can assign a different
+<a href="https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi" target="_blank">NCBI genetic
+code</a> to individual sequences with the <code>codonTable</code> setting in the genome stanza:</p>
+<pre>codonTable default=1 NC_017929.1=13</pre>
+<p>The value is a space-separated list of <code>sequenceName=id</code> pairs, where <code>id</code>
+is an NCBI translation table number (for example 1 for the standard code, 2 for vertebrate
+mitochondrial, 13 for ascidian mitochondrial). The special name <code>default</code> sets the code
+used for any sequence not listed. Sequences with no assignment keep the default behavior described
+above. This affects amino acid display in the base position track's three-frame translation, in
+codon-colored annotation tracks such as gene predictions, and on the details pages.</p>
+<p><b>Note</b>: <code>sequenceName</code> must be the sequence's own name as stored in the assembly's
+<em>.2bit</em> file (the same name used in <code>chrom.sizes</code>), for example a RefSeq or GenBank
+accession such as <code>NC_017929.1</code>. This is the internal name even when a
+<code>chromAlias</code> and <code>chromAuthority</code> cause a different name (such as
+<code>chrM</code>) to be displayed. Because the special <code>chrM</code>/<code>chrMT</code>
+mitochondrial default only applies to sequences whose own name is literally <code>chrM</code> or
+<code>chrMT</code>, an assembly whose mitochondrial sequence has an accession name needs an explicit
+<code>codonTable</code> entry to translate it with a mitochondrial code.</p>
+<p>Example genome stanza (translating the mitochondrial sequence with the ascidian mitochondrial
+code, table 13):</p>
+<pre>
+genome GCF_000224145.3
+taxId 7719
+groups groups.txt
+description vase tunicate
+twoBitPath GCF_000224145.3.2bit
+codonTable default=1 NC_017929.1=13
+organism KH Sep. 2013
+defaultPos NC_020166.2:3347001-3357001
+scientificName Ciona intestinalis
+</pre>
+
 <a id="groupsTxt"></a>
 <h3>groups.txt</h3>
 <p>The <b>groups.txt</b> file defines the grouping of track controls under the Genome Browser graphic
 display.</p>
 <p>Example:</p>
 <pre>
 name map
 label Mapping
 priority 2
 defaultIsClosed 0
 </pre>
 
 
 <ul>
    <li>The <b>name</b> setting is used in the trackDb.txt file to associate specific tracks with a