d3f4b110a0c7befaff49a3bf40871ec7c88ca565 angie Mon Jan 10 16:56:55 2011 -0800 Track #1864 (SNPs 132 (dbSNP)): 1. Added new-in-snp132 columns (exceptions, submitters, alleles) to hgc. Wrapped an html table around several parts of the details page so that they could be made expandable/collapsible using utils.js's setTableRowVisibility. Also wrapped some SNP attributes in an html table for readability. 2. Changed attribute-filter cart variables in hg/lib/snp125Ui.c, hgTrackUi.c and hgTracks/variation.c to use one checkbox group per attribute, with the cart variable based on the track name, instead of one checkbox per attribute value with hardcoded cart var name that applies to all SNP tracks. Refactored to remove a lot of redundant extern global variables. Still need to make other SNP control cart vars based on track name. diff --git src/hg/lib/snp125Ui.c src/hg/lib/snp125Ui.c index fc88956..1c4ee8f 100644 --- src/hg/lib/snp125Ui.c +++ src/hg/lib/snp125Ui.c @@ -1,539 +1,430 @@ /* snp125Ui.c - enums & char arrays for snp UI features and shared util code */ #include "snp125Ui.h" #include "common.h" static char const rcsid[] = "$Id: snp125Ui.c,v 1.33 2010/05/28 18:48:07 angie Exp $"; char *snp125OrthoTable(struct trackDb *tdb, int *retSpeciesCount) /* Look for a setting that specifies a table with orthologous alleles. * If retSpeciesCount is not null, set it to the number of other species * whose alleles are in the table. Do not free the returned string. */ { char *table = trackDbSetting(tdb, "chimpMacaqueOrthoTable"); int speciesCount = 2; if (table == NULL) { table = trackDbSetting(tdb, "chimpOrangMacOrthoTable"); speciesCount = 3; } if (retSpeciesCount != NULL) *retSpeciesCount = speciesCount; return table; } boolean snp125ExtendedNames = TRUE; -float snp125AvHetCutoff = 0.0; -int snp125WeightCutoff = 1; - /****** Some stuff for snp colors *******/ char *snp125ColorLabel[] = { "red", "green", "blue", "gray", "black", }; -int snp125ColorLabelSize = ArraySize(snp125ColorLabel); +int snp125ColorArraySize = ArraySize(snp125ColorLabel); /****** color source controls *******/ /* This keeps track of which SNP feature is used for color definition. */ /* Available SNP features: Molecule Type, Class, Validation, Function */ char *snp125ColorSourceLabels[] = { "Location Type", "Class", "Validation", "Function", "Molecule Type", }; -// why are these arrays? -char *snp125ColorSourceDataName[] = { - "snp125ColorSource", -}; -// could also make Class the default -char *snp125ColorSourceDefault[] = { - "Function", -}; -char *snp125ColorSourceCart[] = { - "Function", -}; +char *snp125ColorSourceVarName = "snp125ColorSource"; +char *snp125ColorSourceDefault = "Function"; -int snp125ColorSourceLabelsSize = ArraySize(snp125ColorSourceLabels); -int snp125ColorSourceDataNameSize = ArraySize(snp125ColorSourceDataName); -int snp125ColorSourceDefaultSize = ArraySize(snp125ColorSourceDefault); -int snp125ColorSourceCartSize = ArraySize(snp125ColorSourceCart); +int snp125ColorSourceArraySize = ArraySize(snp125ColorSourceLabels); /* As of dbSNP 128, locType is ignored: */ char *snp128ColorSourceLabels[] = { "Class", "Validation", "Function", "Molecule Type", }; -int snp128ColorSourceLabelsSize = ArraySize(snp128ColorSourceLabels); +int snp128ColorSourceArraySize = ArraySize(snp128ColorSourceLabels); /****** MolType related controls *******/ /* Types: unknown, genomic, cDNA */ char *snp125MolTypeLabels[] = { "Unknown", "Genomic", "cDNA", }; char *snp125MolTypeStrings[] = { "snp125MolTypeUnknown", "snp125MolTypeGenomic", "snp125MolTypecDNA", }; char *snp125MolTypeDataName[] = { "unknown", "genomic", "cDNA", }; char *snp125MolTypeDefault[] = { "red", "black", "blue", }; -char *snp125MolTypeCart[] = { - "red", - "black", - "blue", -}; -char *snp125MolTypeIncludeStrings[] = { +static char *snp125MolTypeOldVars[] = { "snp125MolTypeUnknownInclude", "snp125MolTypeGenomicInclude", "snp125MolTypecDNAInclude", }; -boolean snp125MolTypeIncludeDefault[] = { - TRUE, - TRUE, - TRUE, -}; -boolean snp125MolTypeIncludeCart[] = { - TRUE, - TRUE, - TRUE, -}; -// all of these sizes are the same -int snp125MolTypeLabelsSize = ArraySize(snp125MolTypeLabels); -int snp125MolTypeStringsSize = ArraySize(snp125MolTypeStrings); -int snp125MolTypeDataNameSize = ArraySize(snp125MolTypeDataName); -int snp125MolTypeDefaultSize = ArraySize(snp125MolTypeDefault); -int snp125MolTypeCartSize = ArraySize(snp125MolTypeCart); -int snp125MolTypeIncludeStringsSize = ArraySize(snp125MolTypeIncludeStrings); +int snp125MolTypeArraySize = ArraySize(snp125MolTypeLabels); /****** Class related controls *******/ /* Types: unknown, snp, in-del (locType exact), heterozygous, microsatellite, named, no variation, mixed, mnp, insertion (constructed from class = in-del, locType = between) deletion (constructed from class = in-del, locType = range) */ char *snp125ClassLabels[] = { "Unknown", "Single Nucleotide Polymorphism", "In/Del", "Heterozygous", "Microsatellite", "Named", "No Variation", "Mixed", "Mnp", "Insertion", "Deletion", }; char *snp125ClassStrings[] = { "snp125ClassUnknown", "snp125ClassSingle", "snp125ClassIn-del", "snp125ClassHet", "snp125ClassMicrosatellite", "snp125ClassNamed", "snp125ClassNoVar", "snp125ClassMixed", "snp125ClassMnp", "snp125ClassInsertion", "snp125ClassDeletion", }; char *snp125ClassDataName[] = { "unknown", "single", "in-del", "heterozygous", "microsatellite", "named", "no variation", "mixed", "mnp", "insertion", "deletion", }; char *snp125ClassDefault[] = { "red", // unknown "black", // single "black", // in-del "black", // het "blue", // microsatellite "blue", // named "black", // no variation "green", // mixed "green", // mnp "black", // insertion "red", // deletion }; -char *snp125ClassCart[] = { - "red", // unknown - "black", // single - "black", // in-del - "black", // het - "blue", // microsatellite - "blue", // named - "black", // no variation - "green", // mixed - "green", // mnp - "black", // insertion - "red", // deletion -}; -char *snp125ClassIncludeStrings[] = { +static char *snp125ClassOldVars[] = { "snp125ClassUnknownInclude", "snp125ClassSingleInclude", "snp125ClassIn-delInclude", "snp125ClassHetInclude", "snp125ClassMicrosatelliteInclude", "snp125ClassNamedInclude", "snp125ClassNoVarInclude", "snp125ClassMixedInclude", "snp125ClassMnpInclude", "snp125ClassInsertionInclude", "snp125ClassDeletionInclude", }; -boolean snp125ClassIncludeDefault[] = { - TRUE, // unknown - TRUE, // single - TRUE, // in-del - TRUE, // het - TRUE, // microsatellite - TRUE, // named - TRUE, // no variation - TRUE, // mixed - TRUE, // mnp - TRUE, // insertion - TRUE, // deletion -}; -boolean snp125ClassIncludeCart[] = { - TRUE, // unknown - TRUE, // single - TRUE, // in-del - TRUE, // het - TRUE, // microsatellite - TRUE, // named - TRUE, // no variation - TRUE, // mixed - TRUE, // mnp - TRUE, // insertion - TRUE, // deletion -}; -// all of these sizes are the same -int snp125ClassLabelsSize = ArraySize(snp125ClassLabels); -int snp125ClassStringsSize = ArraySize(snp125ClassStrings); -int snp125ClassDataNameSize = ArraySize(snp125ClassDataName); -int snp125ClassDefaultSize = ArraySize(snp125ClassDefault); -int snp125ClassCartSize = ArraySize(snp125ClassCart); -int snp125ClassIncludeStringsSize = ArraySize(snp125ClassIncludeStrings); +int snp125ClassArraySize = ArraySize(snp125ClassLabels); /****** Validation related controls *******/ /* Types: unknown, by-cluster, by-frequency, by-submitter, by-2hit-2allele, by-hapmap */ char *snp125ValidLabels[] = { "Unknown", "By Cluster", "By Frequency", "By Submitter", "By 2 Hit / 2 Allele", "By HapMap", "By 1000 Genomes Project", }; char *snp125ValidStrings[] = { "snp125ValidUnknown", "snp125ValidCluster", "snp125ValidFrequency", "snp125ValidSubmitter", "snp125Valid2H2A", "snp125ValidHapMap", "snp125Valid1000Genomes", }; char *snp125ValidDataName[] = { "unknown", "by-cluster", "by-frequency", "by-submitter", "by-2hit-2allele", "by-hapmap", "by-1000genomes", }; char *snp125ValidDefault[] = { "red", "black", "black", "black", "black", "green", "blue", }; -char *snp125ValidCart[] = { - "red", - "black", - "black", - "black", - "black", - "green", - "blue", -}; -char *snp125ValidIncludeStrings[] = { +static char *snp125ValidOldVars[] = { "snp125ValidUnknownInclude", "snp125ValidClusterInclude", "snp125ValidFrequencyInclude", "snp125ValidSubmitterInclude", "snp125Valid2H2AInclude", "snp125ValidHapMapInclude", "snp125Valid1000GenomesInclude", }; -boolean snp125ValidIncludeDefault[] = { - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, -}; -boolean snp125ValidIncludeCart[] = { - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, -}; -// all of these sizes are the same -int snp125ValidLabelsSize = ArraySize(snp125ValidLabels); -int snp125ValidCartSize = ArraySize(snp125ValidCart); +int snp125ValidArraySize = ArraySize(snp125ValidLabels); /****** function related controls *******/ /* Values are a subset of snpNNN.func values: * unknown, locus, coding, coding-synon, coding-nonsynon, * untranslated, intron, splice-site, cds-reference */ char *snp125FuncLabels[] = { "Unknown", "Locus", "Coding - Synonymous", "Coding - Non-Synonymous", "Untranslated", "Intron", "Splice Site", "Reference (coding)", }; char *snp125FuncStrings[] = { "snp125FuncUnknown", "snp125FuncLocus", "snp125FuncSynon", "snp125FuncNonSynon", "snp125FuncUntranslated", "snp125FuncIntron", "snp125FuncSplice", "snp125FuncReference", }; char *snp125FuncDataName[] = { "unknown", "locus", "coding-synon", "coding-nonsynon", "untranslated", "intron", "splice-site", "cds-reference", }; char *snp125FuncDefault[] = { "black", // unknown "black", // locus "green", // coding-synon "red", // coding-nonsynon "blue", // untranslated "black", // intron "red", // splice-site "black", // cds-reference }; -char *snp125FuncCart[] = { - "gray", // unknown - "blue", // locus - "green", // coding-synon - "red", // coding-nonsynon - "blue", // untranslated - "black", // intron - "red", // splice-site - "blue", // cds-reference -}; /* NCBI has added some new, more specific function types that map onto * pre-existing simpler function classes. This mapping is an array of * arrays, each of which has the simpler type (from snp125FuncDataName * above) followed by more specific subtypes, if any. All arrays are * NULL-terminated. */ static char *locusSyn[] = {"locus", "gene-segment", "near-gene-3", "near-gene-5", NULL}; static char *nonsynonSyn[] = {"coding-nonsynon", "nonsense", "missense", "frameshift", "cds-indel", "coding-synonymy-unknown", NULL}; static char *untranslatedSyn[] = {"untranslated", "untranslated-3", "untranslated-5", NULL}; static char *spliceSyn[] = {"splice-site", "splice-3", "splice-5", NULL}; static char *cdsRefSyn[] = {"cds-reference", "coding", NULL}; char **snp125FuncDataSynonyms[] = { locusSyn, nonsynonSyn, untranslatedSyn, spliceSyn, cdsRefSyn, NULL }; -char *snp125FuncIncludeStrings[] = { +static char *snp125FuncOldVars[] = { "snp125FuncUnknownInclude", "snp125FuncLocusInclude", "snp125FuncSynonInclude", "snp125FuncNonSynonInclude", "snp125FuncUntranslatedInclude", "snp125FuncIntronInclude", "snp125FuncSpliceInclude", "snp125FuncReferenceInclude", }; -boolean snp125FuncIncludeDefault[] = { - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, -}; -boolean snp125FuncIncludeCart[] = { - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, -}; -// all of these sizes are the same -int snp125FuncLabelsSize = ArraySize(snp125FuncLabels); -int snp125FuncStringsSize = ArraySize(snp125FuncStrings); -int snp125FuncDataNameSize = ArraySize(snp125FuncDataName); -int snp125FuncDefaultSize = ArraySize(snp125FuncDefault); -int snp125FuncCartSize = ArraySize(snp125FuncCart); -int snp125FuncIncludeStringsSize = ArraySize(snp125FuncIncludeStrings); +int snp125FuncArraySize = ArraySize(snp125FuncLabels); /****** LocType related controls *******/ /* Types: unknown, range, exact, between, rangeInsertion, rangeSubstitution, rangeDeletion */ char *snp125LocTypeLabels[] = { "Unknown", "Range", "Exact", "Between", "RangeInsertion", "RangeSubstitution", "RangeDeletion", }; char *snp125LocTypeStrings[] = { "snp125LocTypeUnknown", "snp125LocTypeRange", "snp125LocTypeExact", "snp125LocTypeBetween", "snp125LocTypeRangeInsertion", "snp125LocTypeRangeSubstitution", "snp125LocTypeDeletion", }; char *snp125LocTypeDataName[] = { "unknown", "range", "exact", "between", "rangeInsertion", "rangeSubstitution", "rangeDeletion", }; char *snp125LocTypeDefault[] = { "black", "red", "black", "blue", "green", "green", "green", }; -char *snp125LocTypeCart[] = { - "black", - "red", - "black", - "blue", - "green", - "green", - "green", -}; -char *snp125LocTypeIncludeStrings[] = { +static char *snp125LocTypeOldVars[] = { "snp125LocTypeUnknownInclude", "snp125LocTypeRangeInclude", "snp125LocTypeExactInclude", "snp125LocTypeBetweenInclude", "snp125LocTypeRangeInsertionInclude", "snp125LocTypeRangeSubstitutionInclude", "snp125LocTypeRangeDeletionInclude", }; -boolean snp125LocTypeIncludeDefault[] = { - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, -}; -boolean snp125LocTypeIncludeCart[] = { - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, - TRUE, -}; -// all of these sizes are the same -int snp125LocTypeLabelsSize = ArraySize(snp125LocTypeLabels); -int snp125LocTypeStringsSize = ArraySize(snp125LocTypeStrings); -int snp125LocTypeDataNameSize = ArraySize(snp125LocTypeDataName); -int snp125LocTypeDefaultSize = ArraySize(snp125LocTypeDefault); -int snp125LocTypeCartSize = ArraySize(snp125LocTypeCart); -int snp125LocTypeIncludeStringsSize = ArraySize(snp125LocTypeIncludeStrings); +int snp125LocTypeArraySize = ArraySize(snp125LocTypeLabels); + +struct slName *snp125FilterFromCart(struct cart *cart, char *track, char *attribute, + boolean *retFoundInCart) +/* Look up snp125 filter settings in the cart, keeping backwards compatibility with old + * cart variable names. */ +{ +struct slName *values = NULL; +boolean foundInCart = FALSE; +char cartVar[256]; +safef(cartVar, sizeof(cartVar), "%s.include_%s", track, attribute); +if (cartListVarExists(cart, cartVar)) + { + foundInCart = TRUE; + values = cartOptionalSlNameList(cart, cartVar); + } +else + { + char **oldVarNames = NULL, **oldDataName = NULL; + int oldArraySize = 0; + if (sameString(attribute, "molType")) + { + oldVarNames = snp125MolTypeOldVars; + oldDataName = snp125MolTypeDataName; + oldArraySize = snp125MolTypeArraySize; + } + else if (sameString(attribute, "class")) + { + oldVarNames = snp125ClassOldVars; + oldDataName = snp125ClassDataName; + oldArraySize = snp125ClassArraySize; + } + else if (sameString(attribute, "valid")) + { + oldVarNames = snp125ValidOldVars; + oldDataName = snp125ValidDataName; + oldArraySize = snp125ValidArraySize; + } + else if (sameString(attribute, "func")) + { + oldVarNames = snp125FuncOldVars; + oldDataName = snp125FuncDataName; + oldArraySize = snp125FuncArraySize; + } + else if (sameString(attribute, "locType")) + { + oldVarNames = snp125LocTypeOldVars; + oldDataName = snp125LocTypeDataName; + oldArraySize = snp125LocTypeArraySize; + } + if (oldVarNames != NULL) + { + int i; + for (i=0; i < oldArraySize; i++) + if (cartVarExists(cart, oldVarNames[i])) + { + foundInCart = TRUE; + break; + } + if (foundInCart) + { + for (i=0; i < oldArraySize; i++) + if (cartUsualBoolean(cart, oldVarNames[i], TRUE)) + slNameAddHead(&values, oldDataName[i]); + } + } + } +if (retFoundInCart != NULL) + *retFoundInCart = foundInCart; +return values; +}