4dcb41c179c6fae38abffb52dd2b764b74301c7c angie Mon Jul 30 16:39:17 2012 -0700 Feature #8551 (Sequence Ontology terms for predicted functional effects on SNP details pages):at Ensembl's request, instead of displaying dbSNP's predicted function terms, instead show terms from the Sequence Ontology (SO). Where possible, terms from Ensembl's list at http://staging.ensembl.org/info/docs/variation/predicted_data.html are used. diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c index 82bea33..d34f088 100644 --- src/hg/hgTrackUi/hgTrackUi.c +++ src/hg/hgTrackUi/hgTrackUi.c @@ -218,30 +218,79 @@ safef(cartVar, sizeof(cartVar), "%s.include_%s", track, attributeVar); jsMakeCheckboxGroupSetClearButton(cartVar, TRUE); puts(" "); jsMakeCheckboxGroupSetClearButton(cartVar, FALSE); printf("</TD></TR>\n<TR><TD>\n"); boolean foundInCart = FALSE; struct slName *selectedAttributes = snp125FilterFromCart(cart, track, attributeVar, &foundInCart); // Include all by default: if (! foundInCart) selectedAttributes = slNameListFromStringArray(values, menuSize); cgiMakeCheckboxGroupWithVals(cartVar, labels, values, menuSize, selectedAttributes, SNP125_FILTER_COLUMNS); printf("</TD></TR>\n"); } +static char *getSetFieldValStr(struct sqlFieldInfo *fi, char *table) +/* Destructively prepare fi->type for chopCommas, making sure it looks like a set() def. */ +{ +if (!startsWith("set(", fi->type)) + errAbort("Expected %s.%s's type to begin with 'set(' but got '%s'", + table, fi->field, fi->type); +char *vals = fi->type + strlen("set("); +char *rightParen = strrchr(vals, ')'); +if (rightParen == NULL || rightParen[1] != '\0') + errAbort("Expected %s.%s's type to end with ')' but got '%s'", + table, fi->field, fi->type); +else + *rightParen = '\0'; +stripChar(vals, '\''); +return vals; +} + +static void snp137PrintFunctionFilterControls(struct trackDb *tdb) +/* As of snp137, show func filter choices based on sql field set + * values and Sequence Ontology (SO) terms so we won't have to + * hardcode menus as new functional categories are added. */ +{ +struct sqlConnection *conn = hAllocConn(database); +struct sqlFieldInfo *fi, *fiList = sqlFieldInfoGet(conn, tdb->table); +hFreeConn(&conn); +for (fi = fiList; fi != NULL; fi = fi->next) + { + if (sameString(fi->field, "func")) + { + char *vals = getSetFieldValStr(fi, tdb->table); + char *values[128]; + int valCount = chopCommas(vals, values); + char *labels[valCount]; + int i; + for (i = 0; i < valCount; i++) + { + char *val = values[i]; + if (sameString(val, "unknown")) + labels[i] = "Unknown"; + else + labels[i] = snpMisoLinkFromFunc(val); + } + snp125PrintFilterControls(tdb->track, "Function", "func", labels, values, valCount); + return;; + } + } +errAbort("Didn't find definition of func field in %s", tdb->table); +} + static void snp125PrintFilterControlSection(struct trackDb *tdb, int version) /* Print a collapsible section of filtering controls on SNP properties, first numeric * and then enum/set. */ { char cartVar[512]; printf("<TR><TD colspan=2><A name=\"filterControls\"></TD></TR>\n"); jsBeginCollapsibleSection(cart, tdb->track, "filterByAttribute", "Filtering Options", FALSE); printf("<BR>\n"); safef(cartVar, sizeof(cartVar), "%s.minAvHet", tdb->track); double minAvHet = cartUsualDouble(cart, cartVar, // Check old cart var name: cartUsualDouble(cart, "snp125AvHetCutoff", SNP125_DEFAULT_MIN_AVHET)); printf("<B>Minimum <A HREF=\"#AvHet\">Average Heterozygosity</A>:</B> "); cgiMakeDoubleVar(cartVar, minAvHet, 6); @@ -289,39 +338,47 @@ printf("Check the boxes below to include SNPs with those attributes. " "In order to be displayed, a SNP must pass the filter for each " "category. \n" "Some assemblies may not contain any SNPs that have some of the " "listed attributes.\n" "<BR><BR>\n"); printf("<TABLE border=0 cellspacing=0 cellpadding=0>\n"); if (version <= 127) snp125PrintFilterControls(tdb->track, "Location Type", "locType", snp125LocTypeLabels, snp125LocTypeDataName, snp125LocTypeArraySize); snp125PrintFilterControls(tdb->track, "Class", "class", snp125ClassLabels, snp125ClassDataName, snp125ClassArraySize); snp125PrintFilterControls(tdb->track, "Validation", "valid", snp125ValidLabels, snp125ValidDataName, snp125ValidArraySize); +if (version < 137) + { int funcArraySize = (version < 130) ? snp125FuncArraySize : (snp125FuncArraySize - 1); snp125PrintFilterControls(tdb->track, "Function", "func", snp125FuncLabels, snp125FuncDataName, funcArraySize); + } +else + snp137PrintFunctionFilterControls(tdb); snp125PrintFilterControls(tdb->track, "Molecule Type", "molType", snp125MolTypeLabels, snp125MolTypeDataName, snp125MolTypeArraySize); if (version >= 132) { + int excArraySize = snp132ExceptionArraySize; + if (version < 135) + excArraySize -= 2; snp125PrintFilterControls(tdb->track, "Unusual Conditions (UCSC)", "exceptions", - snp132ExceptionLabels, snp132ExceptionVarName, snp132ExceptionArraySize); + snp132ExceptionLabels, snp132ExceptionVarName, excArraySize); snp125PrintFilterControls(tdb->track, "Miscellaneous Attributes (dbSNP)", "bitfields", snp132BitfieldLabels, snp132BitfieldDataName, snp132BitfieldArraySize); } printf("</TABLE>\n"); jsEndCollapsibleSection(); } static void snp125PrintColorSpec(char *track, char *attribute, char *vars[], boolean varsAreOld, char *labels[], char *defaults[], int varCount) /* Print a table displaying snp125 attribute color selects. */ { int i; printf("If a SNP has more than one of these attributes, the stronger color will override the\n" "weaker color. The order of colors, from strongest to weakest, is red,\n" "green, blue, gray, and black.\n" @@ -441,58 +498,61 @@ char javascript[2048]; safef(javascript, sizeof(javascript), "document."MAIN_FORM".action='%s'; %s document."MAIN_FORM".submit();", cgiScriptName(), jsSetVerticalPosition(MAIN_FORM)); cgiMakeOnClickSubmitButton(javascript, defaultButtonVar, JS_DEFAULTS_BUTTON_LABEL); printf("<BR><BR>\n" "The selected "Feature for Color Specification" above has the\n" "selection of colors below for each attribute. Only the color\n" "options for the feature selected above will be used to color items;\n" "color options for other features will not be shown.\n"); if (version > 127 && colorSourceCart == snp125ColorSourceLocType) colorSourceCart = SNP125_DEFAULT_COLOR_SOURCE; switch (colorSourceCart) { - int funcArraySize; + int funcArraySize, excArraySize; case snp125ColorSourceLocType: snp125PrintColorSpec(tdb->track, "locType", snp125LocTypeOldColorVars, TRUE, snp125LocTypeLabels, snp125LocTypeDefault, snp125LocTypeArraySize); break; case snp125ColorSourceClass: snp125PrintColorSpec(tdb->track, "class", snp125ClassOldColorVars, TRUE, snp125ClassLabels, snp125ClassDefault, snp125ClassArraySize); break; case snp125ColorSourceValid: snp125PrintColorSpec(tdb->track, "valid", snp125ValidOldColorVars, TRUE, snp125ValidLabels, snp125ValidDefault, snp125ValidArraySize); break; case snp125ColorSourceFunc: funcArraySize = (version < 130) ? snp125FuncArraySize : (snp125FuncArraySize - 1); snp125PrintColorSpec(tdb->track, "func", snp125FuncOldColorVars, TRUE, snp125FuncLabels, snp125FuncDefault, funcArraySize); break; case snp125ColorSourceMolType: snp125PrintColorSpec(tdb->track, "molType", snp125MolTypeOldColorVars, TRUE, snp125MolTypeLabels, snp125MolTypeDefault, snp125MolTypeArraySize); break; case snp125ColorSourceExceptions: + excArraySize = snp132ExceptionArraySize; + if (version < 135) + excArraySize -= 2; snp125PrintColorSpec(tdb->track, "exceptions", snp132ExceptionVarName, FALSE, snp132ExceptionLabels, snp132ExceptionDefault, - snp132ExceptionArraySize); + excArraySize); break; case snp125ColorSourceBitfields: snp125PrintColorSpec(tdb->track, "bitfields", snp132BitfieldVarName, FALSE, snp132BitfieldLabels, snp132BitfieldDefault, snp132BitfieldArraySize); break; case snp125ColorSourceAlleleFreq: printf("<P>Items are be colored by allele frequency on a red-blue spectrum, " "with red representing rare alleles and blue representing common alleles. " "Items with no allele frequency data are colored black.</P>"); break; default: errAbort("Unrecognized value of enum snp125ColorSource (%d)", colorSourceCart); } jsEndCollapsibleSection();