71bb7711b1374deea53e3dd4fa91fd4da8f21042
lrnassar
  Fri Sep 4 17:52:53 2026 -0700
Fall back to the RefSeq Historical protein table when an NP_ accession is a deprecated version.

getProteinSeq read only ncbiRefSeqPepTable, so an HGVS protein term naming a
superseded NP_ failed validation and the search fell through to a whole-gene
match, or to nothing. getCdnaSeq has had the equivalent historical fallback for
years; this gives the protein path the same one, guarded by hTableExists so it
degrades cleanly where the new table is not loaded yet. refs #38248

diff --git src/hg/lib/hgHgvs.c src/hg/lib/hgHgvs.c
index cccf4d10816..7a63970b249 100644
--- src/hg/lib/hgHgvs.c
+++ src/hg/lib/hgHgvs.c
@@ -906,30 +906,39 @@
         struct sqlConnection *conn = hAllocConn(db);
         seq = sqlQuickString(conn, query);
         hFreeConn(&conn);
         freeMem(txAcc);
         }
     }
 else
     {
     if (hDbHasNcbiRefSeq(db))
         {
         char query[2048];
         sqlSafef(query, sizeof(query), "select seq from ncbiRefSeqPepTable "
                  "where name = '%s'", acc);
         struct sqlConnection *conn = hAllocConn(db);
         seq = sqlQuickString(conn, query);
+        // deprecated protein versions live in the RefSeq Historical pep table
+        if (isEmpty(seq) && hDbHasNcbiRefSeqHistorical(db) &&
+            hTableExists(db, "ncbiRefSeqPepTableHistorical"))
+            {
+            freez(&seq);
+            sqlSafef(query, sizeof(query), "select seq from ncbiRefSeqPepTableHistorical "
+                     "where name = '%s'", acc);
+            seq = sqlQuickString(conn, query);
+            }
         hFreeConn(&conn);
         }
     else
         {
         aaSeq *aaSeq = hGenBankGetPep(db, acc, NULL);
         if (aaSeq)
             seq = aaSeq->dna;
         }
     }
 return seq;
 }
 
 static char refBaseForNp(char *db, char *npAcc, int pos)
 // Get the amino acid base in NP_'s sequence at 1-based offset pos.
 {