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/hgTracks/cds.c src/hg/hgTracks/cds.c index 6d753b144a6..2f774345c7d 100644 --- src/hg/hgTracks/cds.c +++ src/hg/hgTracks/cds.c @@ -657,37 +657,36 @@ sprintf(codon,"%c",grayIx - 26 + 'A' - 1); if (codon[0] == GRAYIX_STOP_CODON_ALPHA) codon[0] = '*'; } else { errAbort("colorAndCodonFromGrayIx: invalid grayIx %d", grayIx); color = cdsColor[CDS_ERROR]; sprintf(codon,"X"); } return color; } static char baseColorLookupCodon(DNA *dna) -/* Call dnautil's lookupCodon, but translate stop codon '\0' to '*' for display. */ +/* Translate a codon to its amino acid, but return '*' for a stop codon instead + * of '\0'. Uses the genetic code assigned to the current sequence, which an + * assembly hub may set with a genomes.txt "codonTable" line (chrM/chrMT default + * to the vertebrate mitochondrial code). */ { -char peptide; -if (isMito(chromName)) - peptide = lookupMitoCodon(dna); -else - peptide = lookupCodon(dna); +char peptide = lookupCodonInCode(hGeneticCodeForChrom(database, chromName), dna); if (peptide == '\0') peptide = '*'; return peptide; } static int peptideToGrayIx(char peptide, boolean codonFirstColor) /* Encode peptide (a letter or '*') and alternating gray shade into our alpha-offset scheme. */ { if (peptide == '*') peptide = GRAYIX_STOP_CODON_ALPHA; if (codonFirstColor) return(peptide - 'A' + 1); else return(peptide - 'A' + 1 + 26); }