36650b61875fa047f2c9ebc3657d1a9d10ec77e6 braney Fri Nov 12 14:42:17 2021 -0800 Give developers a way to map sequence names to labels in maf display refs #28495 diff --git src/hg/hgc/mafClick.c src/hg/hgc/mafClick.c index 8f756d6..a84dd9a 100644 --- src/hg/hgc/mafClick.c +++ src/hg/hgc/mafClick.c @@ -73,31 +73,31 @@ void updateSummaryLine(char *summaryLine, char *referenceText, char *alignText, int size) /* Blank out columns in the summary line where this alignment * differs from the reference */ { int i; for (i=0; i<size; i++) { if (alignText[i] != referenceText[i]) summaryLine[i] = ' '; } } void mafPrettyOut(FILE *f, struct mafAli *maf, int lineSize, - boolean onlyDiff, int blockNo) + boolean onlyDiff, int blockNo, struct hash *labelHash) { int ii, ch; int srcChars = 0; struct mafComp *mc; int lineStart, lineEnd; char *summaryLine = needMem(lineSize+1); char *referenceText; int startChars, sizeChars, srcSizeChars; boolean haveInserts = FALSE; struct mafComp *masterMc = maf->components; startChars = sizeChars = srcSizeChars = 0; for (mc = maf->components; mc != NULL; mc = mc->next) { @@ -157,32 +157,35 @@ int e = s + mc->size; char *org; char *revComp = ""; char strand = mc->strand; struct dyString *dy = newDyString(512); #ifdef REVERSESTRAND if (cartCgiUsualBoolean(cart, COMPLEMENT_BASES_VAR, FALSE)) strand = (strand == '+') ? '-' : '+'; #endif if (strand == '-') revComp = "&hgSeq.revComp=on"; dyStringClear(dy); safef(dbOnly, sizeof(dbOnly), "%s", mc->src); chrom = chopPrefix(dbOnly); + if ((labelHash == NULL) || ((org = hashFindVal(labelHash, dbOnly)) == NULL)) + { if ((org = hOrganism(dbOnly)) == NULL) org = dbOnly; + } if (mc->strand == '-') reverseIntRange(&s, &e, mc->srcSize); if (mc->text != NULL) { if (lineStart == 0) { if (hDbIsActive(dbOnly)) { dyStringPrintf(dy, "%s Browser %s:%d-%d %c %*dbps",hOrganism(dbOnly),chrom, s+1, e, mc->strand,sizeChars, mc->size); linkToOtherBrowserTitle(dbOnly, chrom, s, e, dy->string); dyStringClear(dy); fprintf(f, "B</A> "); @@ -502,30 +505,31 @@ } else { struct mafAli *mafList = NULL, *maf, *subList = NULL; int aliIx = 0, realCount = 0; char dbChrom[64]; char option[128]; char *capTrack; struct consWiggle *consWig, *consWiggles; struct hash *speciesOffHash = NULL; char *speciesOrder = NULL; char *speciesTarget = trackDbSetting(tdb, SPECIES_TARGET_VAR); char buffer[1024]; int useTarg = FALSE; int useIrowChains = FALSE; + struct hash *labelHash = mafGetLabelHash(tdb); safef(option, sizeof(option), "%s.%s", tdb->track, MAF_CHAIN_VAR); if (cartCgiUsualBoolean(cart, option, FALSE) && trackDbSetting(tdb, "irows") != NULL) useIrowChains = TRUE; safef(buffer, sizeof(buffer), "%s.vis",tdb->track); if (useIrowChains) { if (!cartVarExists(cart, buffer) && (speciesTarget != NULL)) useTarg = TRUE; else { char *val; @@ -777,31 +781,31 @@ printf("%s ", species); puts("<BR>"); } for (maf = subList; maf != NULL; maf = maf->next) { mafLowerCase(maf); #ifdef ADDEXONCAPITAL if (capTrack != NULL) capMafOnTrack(maf, capTrack, onlyCds); #endif printf("<B>Alignment block %d of %d in window, %d - %d, %d bps </B>\n", ++aliIx,realCount,maf->components->start + 1, maf->components->start + maf->components->size, maf->components->size); - mafPrettyOut(stdout, maf, 70,onlyDiff, aliIx); + mafPrettyOut(stdout, maf, 70,onlyDiff, aliIx, labelHash); } mafAliFreeList(&subList); } else { printf("No multiple alignment in browser window"); } printf("</PRE></TT>"); } } static void mafOrAxtClick(struct sqlConnection *conn, struct trackDb *tdb, char *axtOtherDb) { struct sqlConnection *conn2 = NULL; if (!(isHubTrack(tdb->track) || trackHubDatabase(database)))