082f118d6f5d17754c5fafd8d95f700c9397d99e
angie
  Thu Jun 21 11:10:32 2018 -0700
Update multi-region haplotype mode to work with _fix patch sequences in addition to _alt sequences.  refs #18854

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 237e74b..edf2398 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -3300,53 +3300,46 @@
 sqlFreeResult(&sr);
 slReverse(&virtRegionList);
 hFreeConn(&conn);
 }
 
 boolean initSingleAltHaplotype(char *haplotypeId)
 /* create a testing regionlist from haplotype with given id */
 {
 struct sqlConnection *conn = hAllocConn(database);
 if (!virtRegionList) // this should already contain allchroms.
     errAbort("unexpected error in initSingleAltHaplotype: virtRegionList is NULL, should contain all chroms");
 struct virtRegion *after = virtRegionList;
 virtRegionList = NULL;
 struct sqlResult *sr;
 char **row;
-char *table = NULL;
-if (sameString(database,"hg17"))
-    table = "altLocations"; // was haplotypeLocations which I made with BLAT and self-chains ;  // bin+bed4
-else if (sameString(database,"hg18"))
-    table = "altLocations"; // was haplotypeLocationsEnsembl which got renamed;  // bin+bed4
-else if (sameString(database,"hg19"))
-    table = "altLocations"; // created from hapRegions, was "altSeqHaplotypes";  // was bin+bed6, now bin+bed4
-else if (sameString(database,"hg38"))
-    table = "altLocations";  // bin+bed4
-else
-    {
-    warn("initSingleAltHaplotype() was expecting database to be hg17, hg18, hg19, or hg38");
+char *table = endsWith(haplotypeId, "_fix") ? "fixLocations" : "altLocations";
+if (! hTableExists(database, table))
+    {
+    warn("initSingleAltHaplotype: table '%s' not found in database %s, "
+         "can't find %s", table, database, haplotypeId);
     return FALSE;
     }
 
 // where is the alt haplo placed?
 char query[256];
 sqlSafef(query, sizeof(query), "select chrom, chromStart, chromEnd from %s where name='%s'", table, haplotypeId);
 sr = sqlGetResult(conn, query);
 row = sqlNextRow(sr);
 if (!row)
     {
-    warn("no haplotype found for [%s]", haplotypeId);
+    warn("no haplotype found for [%s] in %s", haplotypeId, table);
     return FALSE;
     }
 char *haploChrom = cloneString(row[0]);
 int haploStart = sqlUnsigned(row[1]);
 int haploEnd   = sqlUnsigned(row[2]);
 sqlFreeResult(&sr);
 // what is the size of the alt haplo?
 int haploSize = hChromSize(database, haplotypeId); // hopefully this will work
 
 // insert into list replacing original haploChrom record
 struct virtRegion *before = NULL;
 boolean found = FALSE;
 long offset = 0;
 struct virtRegion *v;
 while ((v=slPopHead(&after)))
@@ -4400,31 +4393,32 @@
 	warn("Single transcript Id should not be blank");
 	return FALSE; // return to default mode
 	}
     setEMGeneTrack();
     dySaveCartSetting(dy, "singleTransId", TRUE);
     }
 else if (sameString(virtModeType, "singleAltHaplo"))
     {
     singleAltHaploId = cartUsualString(cart, "singleAltHaploId", singleAltHaploId); // default is chr6_cox_hap2
     initAllChroms();  // we want to default to full genome view.
     if (!initSingleAltHaplotype(singleAltHaploId))
 	{
 	virtRegionList = NULL;
 	return FALSE; // return to default mode
 	}
-    virtModeShortDescr = "alt haplo";  // was "single haplo" but that might confuse some users.
+    // was "single haplo" but that might confuse some users.
+    virtModeShortDescr = endsWith(singleAltHaploId, "_fix") ? "fix patch" : "alt haplo";
     dySaveCartSetting(dy, "singleAltHaploId", TRUE);
     }
 else if (sameString(virtModeType, "allChroms"))
     { // TODO more work on this mode
     //warn("show all regular chromosomes (not alts)\n"
 	//"Warning must turn off all tracks except big*");
     initAllChroms();
     }
 else if (sameString(virtModeType, "demo1"))
     {
     // demo two windows on two chroms (default posn chr21, and same loc on chr22
 
     //chr21:33,031,597-33,041,570
     AllocVar(v);
     //chr21:33,031,597-33,041,570