21e5bfb345bf372c0855901b583cc6833a67aa03 angie Wed Jan 26 14:24:05 2011 -0800 Feature #1638 (Add "this SNP also maps to" text to hgdpGeo track). diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index feff54d..c9fccb5 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -16246,86 +16246,91 @@ jsEndCollapsibleSection(); } static void checkForLsSnpMappings(struct sqlConnection *conn, char *snpTrack, char *snpId) /* check if this SNP is mapped to any protein by LS-SNP, and if so print * the information. */ { struct slName *pdbIds = lsSnpPdbChimeraGetSnpPdbs(conn, snpId); if (pdbIds != NULL) { printLsSnpMappings(conn, pdbIds, snpTrack, snpId); slFreeList(&pdbIds); } } +void printOtherSnpMappings(char *table, char *name, int start, + struct sqlConnection *conn, int rowOffset) +/* If this SNP (from any bed4+ table) is not uniquely mapped, print the other mappings. */ +{ +char query[512]; +safef(query, sizeof(query), "select * from %s where name='%s'", + table, name); +struct sqlResult *sr = sqlGetResult(conn, query); +int snpCount = 0; +char **row; +while ((row = sqlNextRow(sr)) != NULL) + { + struct bed *snp = bedLoad3(row + rowOffset); + if (snp->chromStart != start || differentString(snp->chrom, seqName)) + { + printf("
\n"); + if (snpCount == 0) + printf("This SNP maps to these additional locations:

\n"); + snpCount++; + bedPrintPos((struct bed *)snp, 3, tdb); + } + } +sqlFreeResult(&sr); +} + void doSnpWithVersion(struct trackDb *tdb, char *itemName, int version) /* Process SNP details. */ { char *table = tdb->table; struct snp132Ext *snp; struct snp *snpAlign = NULL; int start = cartInt(cart, "o"); struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr; char **row; char query[512]; int rowOffset=hOffsetPastBin(database, seqName, table); -int snpCount=0; genericHeader(tdb, NULL); printf("

dbSNP build %d %s

\n", version, itemName); safef(query, sizeof(query), "select * from %s where chrom='%s' and " "chromStart=%d and name='%s'", table, seqName, start, itemName); sr = sqlGetResult(conn, query); if ((row = sqlNextRow(sr)) != NULL) { if (version >= 132) snp = snp132ExtLoad(row+rowOffset); else snp = (struct snp132Ext *)snp125Load(row+rowOffset); printCustomUrl(tdb, itemName, FALSE); bedPrintPos((struct bed *)snp, 3, tdb); snpAlign = snp125ToSnp((struct snp125 *)snp); printf("
\n"); printSnp125Info(tdb, snp, version); doSnpEntrezGeneLink(tdb, itemName); } else errAbort("SNP %s not found at %s base %d", itemName, seqName, start); sqlFreeResult(&sr); -safef(query, sizeof(query), "select * from %s where name='%s'", - table, itemName); -sr = sqlGetResult(conn, query); -while ((row = sqlNextRow(sr)) != NULL) - { - if (version >= 132) - snp = snp132ExtLoad(row+rowOffset); - else - snp = (struct snp132Ext *)snp125Load(row+rowOffset); - if (snp->chromStart != start || differentString(snp->chrom, seqName)) - { - if (snpCount==0) - printf("
This SNP maps to these additional locations:" - "

"); - snpCount++; - bedPrintPos((struct bed *)snp, 3, tdb); - printf("
"); - } - } -sqlFreeResult(&sr); +printOtherSnpMappings(table, itemName, start, conn, rowOffset); puts("
"); // Make table for collapsible sections: puts(""); checkForGwasCatalog(conn, tdb, itemName); checkForHgdpGeo(conn, tdb, itemName, start); checkForHapmap(conn, tdb, itemName); checkForLsSnpMappings(conn, tdb->track, itemName); printSnpAlignment(tdb, snpAlign); puts("
"); printTrackHtml(tdb); hFreeConn(&conn); } void doTigrGeneIndex(struct trackDb *tdb, char *item)