04a8bccb5e10e09d1c37b01541389aa5083ccf7b angie Mon Feb 7 15:25:24 2011 -0800 Track #1684 (SNPs 132 (dbSNP)): Added filtering by allele frequency:min/max minor allele freq and min chromosome sample count (2N). diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c index d1509c9..0e0a44d 100644 --- src/hg/hgTrackUi/hgTrackUi.c +++ src/hg/hgTrackUi/hgTrackUi.c @@ -194,47 +194,137 @@ } cgiMakeCheckboxGroupWithVals(cartVar, labels, values, menuSize, selectedGeneTracks, numCols); jsEndCollapsibleSection(); } hFreeConn(&conn); } #define SNP125_FILTER_COLUMNS 4 #define SNP125_DEFAULTS "snp125Defaults" void snp125PrintFilterControls(char *track, char *attributeLabel, char *attributeVar, char *labels[], char *values[], int menuSize) /* Print two or more rows (attribute name header and row(s) of checkboxes) * of a table displaying snp125 attribute filter checkboxes. */ { -printf("<TR><TD><B>%s:</B> \n", attributeLabel); +char anchor[256]; +safecpy(anchor, sizeof(anchor), attributeVar); +anchor[0] = toupper(anchor[0]); +printf("<TR><TD><B><A HREF=\"#%s\">%s</A>:</B> \n", anchor, attributeLabel); char cartVar[256]; 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 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); +printf("<BR>\n"); + +safef(cartVar, sizeof(cartVar), "%s.maxWeight", tdb->track); +int defaultMaxWeight = SNP125_DEFAULT_MAX_WEIGHT; +char *setting = trackDbSetting(tdb, "defaultMaxWeight"); +if (isNotEmpty(setting)) + defaultMaxWeight = atoi(setting); +int maxWeight = cartUsualInt(cart, cartVar, + // Check old cart var name: + cartUsualInt(cart, "snp125WeightCutoff", defaultMaxWeight)); +printf("<B>Maximum <A HREF=\"#Weight\">Weight</A>:</B> "); +cgiMakeIntVar(cartVar, maxWeight, 4); +printf(" <EM>Range: 1, 2 or 3; SNPs with higher weights are less reliable</EM><BR>\n"); + +if (version >= 132) + { + printf("<B>Minimum number of distinct " + "<A HREF=\"#Submitters\">Submitters</A>:</B> "); + safef(cartVar, sizeof(cartVar), "%s.minSubmitters", tdb->track); + cgiMakeIntVar(cartVar, cartUsualInt(cart, cartVar, SNP132_DEFAULT_MIN_SUBMITTERS), 4); + printf("<BR>\n"); + printf("<B><A HREF=\"#AlleleFreq\">Minor Allele Frequency</A> range:</B> "); + safef(cartVar, sizeof(cartVar), "%s.minMinorAlFreq", tdb->track); + float maf = cartUsualDouble(cart, cartVar, SNP132_DEFAULT_MIN_MINOR_AL_FREQ); + cgiMakeDoubleVarInRange(cartVar, maf, NULL, 4, "0.0", "0.5"); + printf(" to "); + safef(cartVar, sizeof(cartVar), "%s.maxMinorAlFreq", tdb->track); + maf = cartUsualDouble(cart, cartVar, SNP132_DEFAULT_MAX_MINOR_AL_FREQ); + cgiMakeDoubleVarInRange(cartVar, maf, NULL, 4, "0.0", "0.5"); + printf(" <em>Range: 0.0 - 0.5</em>\n"); + printf("<BR>\n"); + printf("<B>Minimum chromosome sample count (2N) for " + "<A HREF=\"#AlleleFreq\">Allele Frequency</A> data:</B> "); + safef(cartVar, sizeof(cartVar), "%s.minAlFreq2N", tdb->track); + cgiMakeIntVar(cartVar, cartUsualInt(cart, cartVar, SNP132_DEFAULT_MIN_AL_FREQ_2N), 4); + printf("<BR>\n"); + } + +printf("<BR>\n"); + +printf("<B>Filter by attribute:</B><BR>\n"); +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); +int funcArraySize = (version < 130) ? snp125FuncArraySize : (snp125FuncArraySize - 1); +snp125PrintFilterControls(tdb->track, "Function", "func", snp125FuncLabels, + snp125FuncDataName, funcArraySize); +snp125PrintFilterControls(tdb->track, "Molecule Type", "molType", snp125MolTypeLabels, + snp125MolTypeDataName, snp125MolTypeArraySize); +if (version >= 132) + { + snp125PrintFilterControls(tdb->track, "Unusual Conditions (UCSC)", "exceptions", + snp132ExceptionLabels, snp132ExceptionVarName, snp132ExceptionArraySize); + 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" "<BR><BR>\n"); printf("<TABLE border=0 cellspacing=0 cellpadding=1>\n"); for (i=0; i < varCount; i++) { if (i % SNP125_FILTER_COLUMNS == 0) { if (i > 0) @@ -294,31 +384,31 @@ tdb->track, "func"); snp125RemoveColorVars(cart, snp125MolTypeOldColorVars, TRUE, snp125MolTypeArraySize, tdb->track, "molType"); snp125RemoveColorVars(cart, snp132ExceptionVarName, FALSE, snp132ExceptionArraySize, tdb->track, "exceptions"); snp125RemoveColorVars(cart, snp132BitfieldVarName, FALSE, snp132BitfieldArraySize, tdb->track, "bitfields"); } } void snp125PrintColorControlSection(struct trackDb *tdb, int version) /* Print a collapsible section of color controls: user selects an attribute to color by, * and then a color for each possible value of the selected attribute. */ { printf("<TR><TD colspan=2><A name=\"colorSpec\"></TD></TR>\n"); -jsBeginCollapsibleSection(cart, tdb->track, "colorByAttribute", "Color by Attribute", FALSE); +jsBeginCollapsibleSection(cart, tdb->track, "colorByAttribute", "Coloring Options", FALSE); char defaultButtonVar[512]; safef(defaultButtonVar, sizeof(defaultButtonVar), "%s_coloring", SNP125_DEFAULTS); stripChar(defaultButtonVar, ' '); snp125ResetColorVarsIfNecessary(tdb, defaultButtonVar, version); printf("<BR><B>SNP Feature for Color Specification:</B>\n"); char **labels = snp132ColorSourceLabels; int arraySize = snp132ColorSourceArraySize; if (version <= 127) { labels = snp125ColorSourceLabels; arraySize = snp125ColorSourceArraySize; } else if (version <= 131) @@ -418,95 +508,32 @@ snp125ExtendedNames = cartUsualBoolean(cart, cartVar, // Check old cart var name for backwards compatibility w/ old sessions: cartUsualBoolean(cart, "snp125ExtendedNames", FALSE)); cgiMakeCheckBox(cartVar, snp125ExtendedNames); printf("<BR>(If enabled, chimp allele is displayed first, then '>', then human alleles)."); printf("<BR><BR>\n"); } else puts("<BR>"); // Make wrapper table for collapsible sections: puts("<TABLE border=0 cellspacing=0 cellpadding=0>"); snp125OfferGeneTracksForFunction(tdb); -printf("<TR><TD colspan=2><BR></TD></TR>\n"); -printf("<TR><TD colspan=2><A name=\"filterControls\"></TD></TR>\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("<TR><TD colspan=2><B>Minimum <A HREF=\"#AvHet\">Average Heterozygosity</A>:</B> "); -cgiMakeDoubleVar(cartVar, minAvHet, 6); -printf("</TD></TR>\n"); - -safef(cartVar, sizeof(cartVar), "%s.maxWeight", tdb->track); -int defaultMaxWeight = SNP125_DEFAULT_MAX_WEIGHT; -char *setting = trackDbSetting(tdb, "defaultMaxWeight"); -if (isNotEmpty(setting)) - defaultMaxWeight = atoi(setting); -int maxWeight = cartUsualInt(cart, cartVar, - // Check old cart var name: - cartUsualInt(cart, "snp125WeightCutoff", defaultMaxWeight)); -printf("<TR><TD colspan=2><B>Maximum <A HREF=\"#Weight\">Weight</A>:</B> "); -cgiMakeIntVar(cartVar, maxWeight, 4); -printf(" <EM>Range: 1, 2 or 3; SNPs with higher weights are less reliable</EM><BR>\n"); -printf("</TD></TR>\n"); - -if (version >= 132) - { - printf("<TR><TD colspan=2><B>Minimum number of distinct " - "<A HREF=\"#Submitters\">Submitters</A>:</B> "); - safef(cartVar, sizeof(cartVar), "%s.minSubmitters", tdb->track); - cgiMakeIntVar(cartVar, cartUsualInt(cart, cartVar, SNP132_DEFAULT_MIN_SUBMITTERS), 4); - printf("</TD></TR>\n"); - } - -printf("<TR><TD colspan=2><BR></TD></TR>\n"); - -jsBeginCollapsibleSection(cart, tdb->track, "filterByAttribute", "Filter by Attribute", FALSE); -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); -int funcArraySize = (version < 130) ? snp125FuncArraySize : (snp125FuncArraySize - 1); -snp125PrintFilterControls(tdb->track, "Function", "func", snp125FuncLabels, - snp125FuncDataName, funcArraySize); -snp125PrintFilterControls(tdb->track, "Molecule Type", "molType", snp125MolTypeLabels, - snp125MolTypeDataName, snp125MolTypeArraySize); -if (version >= 132) - { - snp125PrintFilterControls(tdb->track, "Unusual Conditions (UCSC)", "exceptions", - snp132ExceptionLabels, snp132ExceptionVarName, snp132ExceptionArraySize); - snp125PrintFilterControls(tdb->track, "Miscellaneous Attributes (dbSNP)", "bitfields", - snp132BitfieldLabels, snp132BitfieldDataName, snp132BitfieldArraySize); - } -printf("</TABLE>\n"); -jsEndCollapsibleSection(); +puts("<TR><TD colspan=2><BR></TD></TR>"); +snp125PrintFilterControlSection(tdb, version); puts("<TR><TD colspan=2><BR></TD></TR>"); snp125PrintColorControlSection(tdb, version); // End wrapper table for collapsible sections: puts("</TABLE>"); } void snpUi(struct trackDb *tdb) /* Put up UI snp data. */ { int snpSource = 0; int snpMolType = 0; int snpClass = 0; int snpValid = 0; int snpFunc = 0;