d170e9c72cc042ed0e1dccb657568b7fa14a17a1
angie
  Fri Oct 15 09:47:39 2021 -0700
Instead of making super-long custom track names by concatenating sequence names, name the custom tracks after numbered subtrees since those are also displayed in the results table.

diff --git src/hg/hgPhyloPlace/writeCustomTracks.c src/hg/hgPhyloPlace/writeCustomTracks.c
index 188ef73..08ca4be 100644
--- src/hg/hgPhyloPlace/writeCustomTracks.c
+++ src/hg/hgPhyloPlace/writeCustomTracks.c
@@ -239,56 +239,44 @@
 
 static struct vcfFile *parseUserVcf(char *userVcfFile, int *pStartTime)
 /* Read in user VCF file and parse genotypes. */
 {
 struct vcfFile *userVcf = vcfFileMayOpen(userVcfFile, chrom, 0, chromSize, 0, maxVcfRows, TRUE);
 if (! userVcf)
     return NULL;
 reportTiming(pStartTime, "read userVcf");
 struct vcfRecord *rec;
 for (rec = userVcf->records;  rec != NULL;  rec = rec->next)
     vcfParseGenotypesGtOnly(rec);
 reportTiming(pStartTime, "parse userVcf genotypes");
 return userVcf;
 }
 
-static char *trackNameFromSampleIds(struct slName *sampleIds)
-/* Make a name for our subtree custom track by concatenating sample names. */
-{
-struct dyString *dy = dyStringCreate("subtree_%s", sampleIds->name);
-struct slName *id;
-for (id = sampleIds->next;  id != NULL;  id = id->next)
-    {
-    dyStringPrintf(dy, "_%s", id->name);
-    if (dy->stringSize > 200)
-        break;
-    }
-return dyStringCannibalize(&dy);
-}
-
-static void writeSubtreeTrackLine(FILE *ctF, struct subtreeInfo *ti, char *source, int fontHeight)
+static void writeSubtreeTrackLine(FILE *ctF, struct subtreeInfo *ti, int subtreeNum, char *source,
+                                  int fontHeight)
 /* Write a custom track line to ctF for one subtree. */
 {
-fprintf(ctF, "track name=%s", trackNameFromSampleIds(ti->subtreeUserSampleIds));
+fprintf(ctF, "track name=subtree%d", subtreeNum);
 // Keep the description from being too long in order to avoid buffer overflow in hgTrackUi
-int descLen = fprintf(ctF, " description='Uploaded sample%s %s",
-                      (slCount(ti->subtreeUserSampleIds) > 1 ? "s" : ""),
+// (and limited space for track title in hgTracks)
+int descLen = fprintf(ctF, " description='Subtree %d: uploaded sample%s %s",
+                      subtreeNum, (slCount(ti->subtreeUserSampleIds) > 1 ? "s" : ""),
                       ti->subtreeUserSampleIds->name);
 struct slName *id;
 for (id = ti->subtreeUserSampleIds->next;  id != NULL;  id = id->next)
     {
-    if (descLen > 200)
+    if (descLen > 100)
         {
         fprintf(ctF, " and %d other samples", slCount(id));
         break;
         }
     descLen += fprintf(ctF, ", %s", id->name);
     }
 int height = heightForSampleCount(fontHeight, slCount(ti->subtreeNameList));
 fprintf(ctF, " and nearest neighboring %s sequences' type=vcf visibility=dense "
         "hapClusterEnabled=on hapClusterHeight=%d hapClusterMethod='treeFile %s' "
         "highlightIds=%s",
         source, height, ti->subtreeTn->forHtml,
         slNameListToString(ti->subtreeUserSampleIds, ','));
 if (isNotEmpty(geneTrack))
     fprintf(ctF, " hapClusterColorBy=function geneTrack=%s", geneTrack);
 fputc('\n', ctF);
@@ -546,33 +534,34 @@
                                    struct hash *samplePlacements,
                                    struct mutationAnnotatedTree *bigTree,
                                    char *source, int fontHeight, int *pStartTime)
 /* For each subtree trashfile, write VCF+treeFile custom track text to ctF. */
 {
 struct vcfFile *userVcf = parseUserVcf(userVcfFile, pStartTime);
 if (! userVcf)
     {
     warn("Problem parsing VCF file with user variants '%s'; can't make subtree subtracks.",
          userVcfFile);
     return;
     }
 if (!bigTree)
     return;
 struct subtreeInfo *ti;
-for (ti = subtreeInfoList;  ti != NULL;  ti = ti->next)
+int subtreeNum;
+for (subtreeNum = 1, ti = subtreeInfoList;  ti != NULL;  ti = ti->next, subtreeNum++)
     {
-    writeSubtreeTrackLine(ctF, ti, source, fontHeight);
+    writeSubtreeTrackLine(ctF, ti, subtreeNum, source, fontHeight);
     writeVcfHeader(ctF, ti->subtreeNameList);
     writeSubtreeVcf(ctF, ti->subtreeIdToIx, userVcf, bigTree);
     fputc('\n', ctF);
     }
 vcfFileFree(&userVcf);
 reportTiming(pStartTime, "write subtree custom tracks");
 }
 
 struct tempName *writeCustomTracks(struct tempName *vcfTn, struct usherResults *ur,
                                    struct slName *sampleIds, struct mutationAnnotatedTree *bigTree,
                                    char *source, int fontHeight, struct phyloTree **retSampleTree,
                                    int *pStartTime)
 /* Write one custom track per subtree, and one custom track with just the user's uploaded samples. */
 {
 struct tempName *ctVcfTn = userVcfWithImputedBases(vcfTn, ur->samplePlacements, sampleIds);