5c213974bb28e98d1b10ad9a86063101e684e5e3
braney
  Mon Oct 31 12:16:52 2022 -0700
add Jim's track duplication code

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 64552ba..8b825e4 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -244,30 +244,31 @@
 #include "mdb.h"
 #include "yaleGencodeAssoc.h"
 #include "itemDetailsHtml.h"
 #include "trackVersion.h"
 #include "numtsClick.h"
 #include "geneReviewsClick.h"
 #include "bigBed.h"
 #include "bigPsl.h"
 #include "bedTabix.h"
 #include "longRange.h"
 #include "hmmstats.h"
 #include "aveStats.h"
 #include "trix.h"
 #include "bPlusTree.h"
 #include "customFactory.h"
+#include "dupTrack.h"
 #include "iupac.h"
 #include "clinvarSubLolly.h"
 #include "jsHelper.h"
 #include "errCatch.h"
 #include "htslib/bgzf.h"
 #include "htslib/kstring.h"
 #include "pipeline.h"
 #include "genark.h"
 #include "chromAlias.h"
 
 static char *rootDir = "hgcData";
 
 #define LINESIZE 70  /* size of lines in comp seq feature */
 #define MAX_DISPLAY_QUERY_SEQ_SIZE 5000000  // Big enough for HLA alts
 
@@ -26166,30 +26167,38 @@
 
 customTracksSaveCart(database, cart, theCtList);
 
 cartSetString(cart, "i", "PrintAllSequences");
 hgCustom(newCts->tdb->track, NULL);
 }
 
 void doMiddle()
 /* Generate body of HTML. */
 {
 char *track = cartString(cart, "g");
 char *item = cloneString(cartOptionalString(cart, "i"));
 char *parentWigMaf = cartOptionalString(cart, "parentWigMaf");
 struct trackDb *tdb = NULL;
 
+char *dupWholeName = NULL;
+boolean isDup = isDupTrack(track);
+if (isDup)
+    {
+    dupWholeName = track;
+    track = dupTrackSkipToSourceName(track);
+    }
+
 if (issueBotWarning)
     {
     char *ip = getenv("REMOTE_ADDR");
     botDelayMessage(ip, botDelayMillis);
     }
 
 /*	database and organism are global variables used in many places	*/
 getDbAndGenome(cart, &database, &genome, NULL);
 chromAliasSetup(database);
 organism = hOrganism(database);
 scientificName = hScientificName(database);
 
 initGenbankTableNames(database);
 
 dbIsFound = trackHubDatabase(database) || sqlDatabaseExists(database);
@@ -26294,30 +26303,41 @@
         freeMem(typeLine);
         cartRemove(cart, "parentWigMaf");	/* ONE TIME ONLY USE !!!	*/
         }
     else
 	{
         tdb = hashFindVal(trackHash, track);
 	if (tdb == NULL)
 	    {
             if (startsWith("all_mrna", track))
 		tdb = hashFindVal(trackHash, "mrna");
                   /* Oh what a tangled web we weave. */
 	    }
 	}
     }
 
+if (isDup)
+    {
+    struct dupTrack *dupList = dupTrackListFromCart(cart);
+    struct dupTrack *dup = dupTrackFindInList(dupList, dupWholeName);
+    if (dup != NULL)
+	{
+	tdb = dupTdbFrom(tdb, dup);
+	track = dupWholeName;
+	}
+    }
+
 char* handler = trackDbSetting(tdb, "trackHandler");
 
 /* Start of 1000+ line dispatch on table involving 100+ if/elses. */
 char *table = (tdb ? tdb->table : track);
 if (sameWord(table, "getDna"))
     {
     doGetDna1();
     }
 else if (sameWord(table, "htcGetDna2"))
     {
     doGetDna2();
     }
 else if (sameWord(table, "htcGetDna3"))
     {
     doGetDna3();