c18ab1c5577b32368f3cf24abfe1664567a8420e
markd
  Mon Sep 22 08:59:48 2025 -0700
generate correct download link for BAMs in /gbdb #36390

diff --git src/hg/hgTables/bam.c src/hg/hgTables/bam.c
index 8a42df6df97..c60ce61ed6a 100644
--- src/hg/hgTables/bam.c
+++ src/hg/hgTables/bam.c
@@ -373,33 +373,36 @@
 lmCleanup(&lm);
 bamClose(&fh);
 freez(&fileName);
 return randomIdList;
 }
 
 void showSchemaBam(char *table, struct trackDb *tdb)
 /* Show schema on bam. */
 {
 struct sqlConnection *conn = NULL;
 if (!trackHubDatabase(database))
     conn = hAllocConn(database);
 char *fileName = bamFileName(table, conn, NULL);
 
 struct asObject *as = bamAsObj();
+char *downPrefix = "";
+if (startsWith("/gbdb", fileName))
+    downPrefix = "https://hgdownload.soe.ucsc.edu";
 hPrintf("<B>Database:</B> %s", database);
 hPrintf("&nbsp;&nbsp;&nbsp;&nbsp;<B>Primary Table:</B> %s<br>", table);
-hPrintf("<B>BAM File:</B> %s", fileName);
+hPrintf("<B>BAM File Download:</B> <A HREF='%s%s'>%s%s</A>", downPrefix, fileName, downPrefix, fileName);
 hPrintf("<BR>\n");
 hPrintf("<B>Format description:</B> %s<BR>", as->comment);
 hPrintf("See the <A HREF=\"%s\" target=_blank>SAM Format Specification</A> for  more details<BR>\n",
 	"http://samtools.sourceforge.net/SAM1.pdf");
 
 /* Put up table that describes fields. */
 hTableStart();
 hPrintf("<TR><TH>field</TH>");
 hPrintf("<TH>description</TH> ");
 puts("</TR>\n");
 struct asColumn *col;
 int colCount = 0;
 for (col = as->columnList; col != NULL; col = col->next)
     {
     hPrintf("<TR><TD><TT>%s</TT></TD>", col->name);