6819e624cfe2476aa5e10be99ebaf8c96e319278 angie Tue Aug 9 15:40:00 2011 -0700 Feature #3710 (vcfTabix UI options): added checkbox to enable/disable haplotype sorting display. diff --git src/hg/hgTracks/vcfTrack.c src/hg/hgTracks/vcfTrack.c index f9aa9df..5d3d96f 100644 --- src/hg/hgTracks/vcfTrack.c +++ src/hg/hgTracks/vcfTrack.c @@ -6,33 +6,30 @@ #include "errCatch.h" #include "hacTree.h" #include "hdb.h" #include "hgTracks.h" #include "pgSnp.h" #include "trashDir.h" #include "vcf.h" #include "vcfUi.h" #if (defined USE_TABIX && defined KNETFILE_HOOKS) #include "knetUdc.h" #include "udc.h" #endif//def USE_TABIX && KNETFILE_HOOKS #ifdef USE_TABIX -//#*** TODO: use trackDb/cart setting or something -static boolean doHapClusterDisplay = TRUE; - static struct pgSnp *vcfFileToPgSnp(struct vcfFile *vcff) /* Convert vcff's records to pgSnp; don't free vcff until you're done with pgSnp * because it contains pointers into vcff's records' chrom. */ { struct pgSnp *pgsList = NULL; struct vcfRecord *rec; int maxLen = 33; for (rec = vcff->records; rec != NULL; rec = rec->next) { struct pgSnp *pgs = pgSnpFromVcfRecord(rec); // Insertion sequences can be quite long; abbreviate here for display. int len = strlen(pgs->name); if (len > maxLen) { if (strchr(pgs->name, '/') != NULL) @@ -443,31 +440,31 @@ hvGfxLine(hvg, x1-2, yOff, x2+2, yOff, MG_BLACK); hvGfxLine(hvg, x1-2, yBot, x2+2, yBot, MG_BLACK); // Special mouseover instructions: static struct dyString *dy = NULL; if (dy == NULL) dy = dyStringNew(0); dyStringPrintf(dy, "%s Haplotypes sorted on ", mouseoverText); char cartVar[512]; safef(cartVar, sizeof(cartVar), "%s.centerVariantChrom", tg->tdb->track); char *centerChrom = cartOptionalString(cart, cartVar); if (centerChrom == NULL || !sameString(chromName, centerChrom)) dyStringAppend(dy, "middle variant by default. "); else dyStringAppend(dy, "this variant. "); dyStringAppend(dy, "To anchor sorting to a different variant, click on that variant and " - "then click on the link below the variant name."); + "then click on the 'Use this variant' button below the variant name."); mouseoverText = dy->string; } mapBoxHgcOrHgGene(hvg, rec->chromStart, rec->chromEnd, x1, yOff, w, tg->height, tg->track, rec->name, mouseoverText, NULL, TRUE, NULL); } static int getCenterVariantIx(struct track *tg, int seqStart, int seqEnd, struct vcfRecord *records) // If the user hasn't specified a local variant/position to use as center, // just use the median variant in window. { int defaultIx = (slCount(records)-1) / 2; char cartVar[512]; safef(cartVar, sizeof(cartVar), "%s.centerVariantChrom", tg->tdb->track); char *centerChrom = cartOptionalString(cart, cartVar); @@ -560,38 +557,41 @@ /* Figure out url or file name. */ if (tg->parallelLoading) { /* do not use mysql uring parallel-fetch load */ fileOrUrl = trackDbSetting(tg->tdb, "bigDataUrl"); } else { // TODO: may need to handle per-chrom files like bam, maybe fold bamFileNameFromTable into this: struct sqlConnection *conn = hAllocConnTrack(database, tg->tdb); fileOrUrl = bbiNameFromSettingOrTable(tg->tdb, conn, tg->table); hFreeConn(&conn); } int vcfMaxErr = 100; struct vcfFile *vcff = NULL; +boolean compositeLevel = isNameAtCompositeLevel(tg->tdb, tg->tdb->track); +boolean hapClustEnabled = cartUsualBooleanClosestToHome(cart, tg->tdb, compositeLevel, + VCF_HAP_ENABLED_VAR, TRUE); /* protect against temporary network error */ struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) { vcff = vcfTabixFileMayOpen(fileOrUrl, chromName, winStart, winEnd, vcfMaxErr); if (vcff != NULL) { - if (doHapClusterDisplay && vcff->genotypeCount > 1 && vcff->genotypeCount < 3000 && + if (hapClustEnabled && vcff->genotypeCount > 1 && vcff->genotypeCount < 3000 && (tg->visibility == tvPack || tg->visibility == tvSquish)) vcfHapClusterOverloadMethods(tg, vcff); else { tg->items = vcfFileToPgSnp(vcff); // pgSnp bases coloring/display decision on count of items: tg->customInt = slCount(tg->items); } // Don't vcfFileFree here -- we are using its string pointers! } } errCatchEnd(errCatch); if (errCatch->gotError || vcff == NULL) { if (isNotEmpty(errCatch->message->string))