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/hgc/hgc.c src/hg/hgc/hgc.c index 88370e6..1665acd 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -60,30 +60,31 @@ #include "stsMarker.h" #include "stsMap.h" #include "rhMapZfishInfo.h" #include "recombRate.h" #include "recombRateRat.h" #include "recombRateMouse.h" #include "stsInfo.h" #include "stsInfo2.h" #include "mouseSyn.h" #include "mouseSynWhd.h" #include "ensPhusionBlast.h" #include "cytoBand.h" #include "knownMore.h" #include "snp125.h" #include "snp125Ui.h" +#include "snp132Ext.h" #include "snp.h" #include "snpMap.h" #include "snpExceptions.h" #include "snp125Exceptions.h" #include "snp125CodingCoordless.h" #include "cnpIafrate.h" #include "cnpIafrate2.h" #include "cnpLocke.h" #include "cnpSebat.h" #include "cnpSebat2.h" #include "cnpSharp.h" #include "cnpSharp2.h" #include "delHinds2.h" #include "delConrad2.h" #include "dgv.h" @@ -902,30 +903,59 @@ /* Wrapper to call printCustomUrlWithLabel using the url setting in trackDb */ { char urlSetting[10]; safef(urlSetting, sizeof(urlSetting), "url"); printCustomUrlWithLabel(tdb, itemName, itemName, urlSetting, encode); } void printOtherCustomUrl(struct trackDb *tdb, char *itemName, char* urlSetting, boolean encode) /* Wrapper to call printCustomUrlWithLabel to use another url setting other than url in trackDb e.g. url2, this allows the use of multiple urls for a track to be set in trackDb. */ { printCustomUrlWithLabel(tdb, itemName, itemName, urlSetting, encode); } +void beginCollapsibleSection(char *track, char *section, char *sectionTitle, boolean isOpenDefault) +/* Make the hidden input, collapse/expand button and
\n",
+ collapseGroupVar, collapseGroupVar, isOpen ? "0" : "1");
+printf("\n",
+ cgiScriptName(), cartSidUrlString(cart), collapseGroupVar, (isOpen ? "1" : "0"), section);
+char *buttonImage = (isOpen ? "../images/remove_sm.gif" : "../images/add_sm.gif");
+printf(" | \n",
+ section, track,
+ section, buttonImage, (isOpen ? "-" : "+"), (isOpen ? "Collapse": "Expand"));
+printf("%s | ||||
", isOpen ? "" : "style='display: none' ", section, 1); +} + +void endCollapsibleSection() +/* End the collapsible | |||||
%s allele: | " "%s | \n", orthoName, orthoAllele); if (!sameString(orthoAllele, "?")) { printf("%s strand: | " "%s | \n", orthoName, orthoStrand); printf("%s position: | " "\n", orthoName); if (isNotEmpty(orthoDb)) linkToOtherBrowser(orthoDb, orthoChrom, orthoStart-TINYPADDING, orthoEnd+TINYPADDING); printf("%s:%d-%d\n", orthoChrom, orthoStart+1, orthoEnd); - printf("%s | \n", + printf("%s\n", isNotEmpty(orthoDb) ? "" : ""); } else printf(FOURBLANKCELLS"\n"); printf("
%s | %s | " +#define firstTwoColumnsPctS " | |||
%s | %s | "
void getSnp125RefCodonAndSnpPos(struct snp125 *snp, struct genePred *gene, int exonIx,
int *pSnpCodonPos, char refCodon[4], char *pRefAA)
/* Given a single-base snp and a coding gene/exon containing it, determine the snp's position
* in the codon and the reference codon & amino acid. */
{
boolean geneIsRc = sameString(gene->strand, "-");
int snpStart = snp->chromStart, snpEnd = snp->chromEnd;
int exonStart = gene->exonStarts[exonIx], exonEnd = gene->exonEnds[exonIx];
int cdsStart = gene->cdsStart, cdsEnd = gene->cdsEnd;
int exonFrame = gene->exonFrames[exonIx];
if (exonFrame == -1)
exonFrame = 0;
if (cdsEnd < exonEnd) exonEnd = cdsEnd;
if (cdsStart > exonStart) exonStart = cdsStart;
@@ -15611,66 +15643,66 @@
}
slAddHead(&gpList, gp);
}
sqlFreeResult(&sr);
hFreeConn(&conn2);
return gpList;
}
void printSnp125Function(struct trackDb *tdb, struct snp125 *snp)
/* If the user has selected a gene track for functional annotation,
* report how this SNP relates to any nearby genes. */
{
char varName[512];
safef(varName, sizeof(varName), "%s_geneTrack", tdb->track);
struct slName *geneTracks = cartOptionalSlNameList(cart, varName);
-if (geneTracks == NULL)
+if (geneTracks == NULL && !cartListVarExists(cart, varName))
{
char *defaultGeneTracks = trackDbSetting(tdb, "defaultGeneTracks");
if (isNotEmpty(defaultGeneTracks))
geneTracks = slNameListFromComma(defaultGeneTracks);
else
return;
}
struct sqlConnection *conn = hAllocConn(database);
struct slName *gt;
boolean first = TRUE;
for (gt = geneTracks; gt != NULL; gt = gt->next)
- if (!sameString(gt->name, "persistentShadow") && sqlTableExists(conn, gt->name))
+ if (sqlTableExists(conn, gt->name))
{
if (first)
{
printf(" UCSC's predicted function relative to selected gene tracks:\n"); - printf(" \n"); hFreeConn(&conn); } char *dbSnpFuncFromInt(unsigned char funcCode) /* Translate an integer function code from NCBI into an abbreviated description. * Do not free return value! */ // Might be a good idea to flesh this out with all codes, libify, and share with // snpNcbiToUcsc instead of partially duplicating. { switch (funcCode) { case 3: return "coding-synon"; case 8: return "cds-reference"; @@ -15739,97 +15771,246 @@ puts(" "); continue; } if (gotRef) printf("%s (%s) --> ", anno->peptides[0], highlightCodonBase(anno->codons[0], anno->frame)); printf("%s (%s) \n", anno->peptides[i], highlightCodonBase(anno->codons[i], anno->frame)); } } sqlFreeResult(&sr); } hFreeConn(&conn); } -void printSnp125Info(struct trackDb *tdb, struct snp125 snp, int version) +void printSnp132ExtraColumns(struct trackDb *tdb, struct snp132Ext *snp) +/* Print columns new in snp132 */ +{ +// Skip exceptions column; handled below in writeSnpExceptionWithVersion +printf(" | |||
Submitter Handles | "); +int i; +for (i=0; i < snp->submitterCount; i++) + printf("%s" + "%s", (i > 0 ? ", " : ""), snp->submitters[i], snp->submitters[i]); +printf(" | ||||
Allele Frequencies | "); + for (i = 0; i < snp->alleleFreqCount; i++) + { + printf("%s%s: %.3f%% ", (i > 0 ? "; " : ""), snp->alleles[i], (snp->alleleFreqs[i]*100.0)); + // alleleNs should be integers (counts of chromosomes in which allele was observed) + // but dbSNP extrapolates them from reported frequency and reported sample count, + // so sometimes they are not integers. Present them as integers when we can, warn + // when we can't. + double f = snp->alleleFreqs[i], n = snp->alleleNs[i]; + if (f > 0) + { + total2N = round(n / f); + int roundedN = round(n); + if (fabs(n - roundedN) < 0.01) + printf("(%d / %d)", roundedN, total2N); + else + { + gotNonIntN = TRUE; + printf("(%.3f / %d)", n, total2N); + } + } + } + printf(" |
Location Type | %s |
Class | %s |
Validation | %s |
Function | %s |
Molecule Type | %s |
Average Heterozygosity | " + "%.3f +/- %.3f |
Weight | %d |
\n"); hgdpGeoFreqTable(&geo); printf(" | \n"); hgdpGeoImg(&geo); printf(" |
\n"); printf("\n"); } printf(" | \n"); printf("