bc21bd3d27fe3d29971231955b3fc544fa1c3d1e angie Wed Oct 16 11:51:39 2013 -0700 Two new tracks for Locus Reference Genomic (LRG) (#11863) with customhandlers: LRG Regions and LRG Transcripts. LRGs are frozen reference sequences for a particular gene plus some upstream and downstream sequence. They are intended to provide a stable coordinate system for gene annotations that won't change with every new genome assembly, but can be mapped to each genome assembly. Since there is a lot of metadata associated with each region, I made LRG Regions a bigBed 12 + with fields describing mismatches and indels, so that PSL can be derived from the bigBed and the original LRG sequence can be reconstructed using genome assembly sequence and the mismatch/indel info. hgTracks shows differences and LRG insertions into the reference assembly using the cds.c baseColor code. (LRG deletions from the reference appear as gaps, which we get for free with bed12 info). For LRG Transcripts, I found the genePred codon-coloring code inadequate for showing an insertion into hg19 (or even mismatches), so instead of genePred I ended up using PSL + sequence, more like the mRNA track representation and display. diff --git src/hg/lib/hui.c src/hg/lib/hui.c index 9cb5fac..5434484 100644 --- src/hg/lib/hui.c +++ src/hg/lib/hui.c @@ -1042,36 +1042,37 @@ else if (startsWith("genePred", tdb->type)) gotIt = TRUE; return gotIt; } static boolean baseColorGotSequence(struct trackDb *tdb) /* Return true if this track has aligned sequence according to tdb. */ { boolean gotIt = FALSE; char *setting = trackDbSetting(tdb, BASE_COLOR_USE_SEQUENCE); if (isNotEmpty(setting)) { if (sameString(setting, "genbank") || sameString(setting, "seq") || sameString(setting, "ss") || startsWith("extFile", setting) || sameString(setting, "hgPcrResult") || sameString(setting, "nameIsSequence") || - sameString(setting, "seq1Seq2") || sameString(setting, "lfExtra")) + sameString(setting, "seq1Seq2") || sameString(setting, "lfExtra") || + sameString(setting, "lrg") || startsWith("table ", setting)) gotIt = TRUE; else if (differentString(setting, "none")) errAbort("trackDb for %s, setting %s: unrecognized value \"%s\". " "must be one of {none, genbank, seq, ss, extFile, nameIsSequence, seq1Seq2," - "hgPcrResult,lfExtra}.", + "hgPcrResult, lfExtra, lrg, table <em>table</em>}.", tdb->track, BASE_COLOR_USE_SEQUENCE, setting); } return gotIt; } static void baseColorDropLists(struct cart *cart, struct trackDb *tdb, char *name) /* draw the baseColor drop list options */ { enum baseColorDrawOpt curOpt = baseColorDrawOptEnabled(cart, tdb); char *curValue = baseColorDrawAllOptionValues[curOpt]; char var[512]; safef(var, sizeof(var), "%s." BASE_COLOR_VAR_SUFFIX, name); boolean gotCds = baseColorGotCds(tdb); boolean gotSeq = baseColorGotSequence(tdb); if (gotCds && gotSeq) @@ -1141,31 +1142,32 @@ static boolean tdbOrCartBoolean(struct cart *cart, struct trackDb *tdb, char *settingName, char *defaultOnOff) /* Query cart & trackDb to determine if a boolean variable is set. */ { boolean alreadySet; alreadySet = !sameString("off",trackDbSettingOrDefault(tdb, settingName, defaultOnOff)); alreadySet = cartUsualBooleanClosestToHome(cart, tdb, FALSE, settingName, alreadySet); // NOTE: parentLevel=FALSE because tdb param already is at appropriate level return alreadySet; } static boolean indelAppropriate(struct trackDb *tdb) /* Return true if it makes sense to offer indel display options for tdb. */ { -return (tdb && (startsWith("psl", tdb->type) || sameString("bam", tdb->type)) && +return (tdb && (startsWith("psl", tdb->type) || sameString("bam", tdb->type) || + sameString("lrg", tdb->track)) && (cfgOptionDefault("browser.indelOptions", NULL) != NULL)); } static void indelEnabledByName(struct cart *cart, struct trackDb *tdb, char *name, float basesPerPixel, boolean *retDoubleInsert, boolean *retQueryInsert, boolean *retPolyA) /* Query cart & trackDb to determine what indel display (if any) is enabled. Set * basesPerPixel to 0.0 to disable check for zoom level. */ { struct trackDb *tdbLevel = tdb; if (differentString(tdb->track, name) && tdb->parent != NULL) tdbLevel = tdb->parent; boolean apropos = indelAppropriate(tdb); if (apropos && (basesPerPixel > 0.0)) @@ -1185,64 +1187,77 @@ tdbOrCartBoolean(cart, tdbLevel, INDEL_QUERY_INSERT, "off"); if (retPolyA) *retPolyA = apropos && tdbOrCartBoolean(cart, tdbLevel, INDEL_POLY_A, "off"); } void indelEnabled(struct cart *cart, struct trackDb *tdb, float basesPerPixel, boolean *retDoubleInsert, boolean *retQueryInsert, boolean *retPolyA) /* Query cart & trackDb to determine what indel display (if any) is enabled. Set * basesPerPixel to 0.0 to disable check for zoom level. */ { indelEnabledByName(cart,tdb,tdb->track,basesPerPixel,retDoubleInsert,retQueryInsert,retPolyA); } -static void indelShowOptionsWithName(struct cart *cart, struct trackDb *tdb,char *name) +static void indelShowOptionsWithNameExt(struct cart *cart, struct trackDb *tdb, char *name, + char *queryTerm, + boolean includeDoubleInsert, boolean includePolyA) /* Make HTML inputs for indel display options if any are applicable. */ { if (indelAppropriate(tdb)) { boolean showDoubleInsert, showQueryInsert, showPolyA; char var[512]; indelEnabledByName(cart, tdb, name, 0.0, &showDoubleInsert, &showQueryInsert, &showPolyA); printf("<TABLE><TR><TD colspan=2><B>Alignment Gap/Insertion Display Options</B>"); printf(" <A HREF=\"%s\">Help on display options</A>\n<TR valign='top'><TD>", INDEL_HELP_PAGE); + if (includeDoubleInsert) + { safef(var, sizeof(var), "%s.%s", name, INDEL_DOUBLE_INSERT); cgiMakeCheckBox(var, showDoubleInsert); - printf("</TD><TD>Draw double horizontal lines when both genome and query have " - "an insertion</TD></TR>\n<TR valign='top'><TD>"); + printf("</TD><TD>Draw double horizontal lines when both genome and %s have " + "an insertion</TD></TR>\n<TR valign='top'><TD>", queryTerm); + } safef(var, sizeof(var), "%s.%s", name, INDEL_QUERY_INSERT); cgiMakeCheckBox(var, showQueryInsert); printf("</TD><TD>Draw a vertical purple line for an insertion at the beginning or " - "end of the <BR>query, orange for insertion in the middle of the query</TD></TR>\n" - "<TR valign='top'><TD>"); + "end of the <BR>%s, orange for insertion in the middle of the %s</TD></TR>\n" + "<TR valign='top'><TD>", queryTerm, queryTerm); + if (includePolyA) + { safef(var, sizeof(var), "%s.%s", name, INDEL_POLY_A); /* We can highlight valid polyA's only if we have query sequence -- * so indelPolyA code piggiebacks on baseColor code: */ if (baseColorGotSequence(tdb)) { cgiMakeCheckBox(var, showPolyA); - printf("</TD><TD>Draw a vertical green line where query has a polyA tail " - "insertion</TD></TR>\n"); + printf("</TD><TD>Draw a vertical green line where %s has a polyA tail " + "insertion</TD></TR>\n", queryTerm); + } } - printf("</TABLE>\n"); } } +static void indelShowOptionsWithName(struct cart *cart, struct trackDb *tdb, char *name) +/* Make HTML inputs for indel display options if any are applicable. */ +{ +indelShowOptionsWithNameExt(cart, tdb, name, "query", TRUE, TRUE); +} + void indelShowOptions(struct cart *cart, struct trackDb *tdb) /* Make HTML inputs for indel display options if any are applicable. */ { indelShowOptionsWithName(cart, tdb, tdb->track); } /****** base position (ruler) controls *******/ static char *zoomOptions[] = { ZOOM_1PT5X, ZOOM_3X, ZOOM_10X, ZOOM_BASE }; @@ -6349,30 +6364,52 @@ printf("<BR>\n"); } cgiMakeRadioButton(cartVarName, BAM_COLOR_MODE_OFF, sameString(selected, BAM_COLOR_MODE_OFF)); printf("No additional coloring"); //TODO: include / exclude flags if (!boxed && fileExists(hHelpFile("hgBamTrackHelp"))) printf("<P><A HREF=\"../goldenPath/help/hgBamTrackHelp.html\" TARGET=_BLANK>BAM " "configuration help</A></P>"); cfgEndBox(boxed); } #endif//def USE_BAM +void lrgCfgUi(struct cart *cart, struct trackDb *tdb, char *name, char *title, boolean boxed) +/* LRG: Locus Reference Genomic sequences mapped to assembly. */ +{ +boxed = cfgBeginBoxAndTitle(tdb, boxed, title); +printf("<TABLE%s><TR><TD>",boxed?" width='100%'":""); +baseColorDrawOptDropDown(cart, tdb); +indelShowOptionsWithNameExt(cart, tdb, name, "LRG sequence", FALSE, FALSE); +cfgEndBox(boxed); +} + +void lrgTranscriptAliCfgUi(struct cart *cart, struct trackDb *tdb, char *name, char *title, + boolean boxed) +/* LRG Transcripts: Locus Reference Genomic transcript sequences mapped to assembly. */ +{ +boxed = cfgBeginBoxAndTitle(tdb, boxed, title); +printf("<TABLE%s><TR><TD>",boxed?" width='100%'":""); +baseColorDrawOptDropDown(cart, tdb); +indelShowOptionsWithNameExt(cart, tdb, name, "LRG transcript sequence", FALSE, FALSE); +cfgEndBox(boxed); +} + + struct trackDb *rFindView(struct trackDb *forest, char *view) // Return the trackDb on the list that matches the view tag. Prefers ancestors before decendents { struct trackDb *tdb; for (tdb = forest; tdb != NULL; tdb = tdb->next) { char *viewSetting = trackDbSetting(tdb, "view"); if (sameOk(viewSetting, view) || sameOk(tagEncode(viewSetting), view)) return tdb; } for (tdb = forest; tdb != NULL; tdb = tdb->next) { struct trackDb *viewTdb = rFindView(tdb->subtracks, view); if (viewTdb != NULL) return viewTdb;