b2387705edc15aa154101bca5f0b786537958886 galt Fri Sep 16 08:23:51 2011 -0700 fixing peptideMapping - use name-and-position based query instead of just position to prevent picking up nearby peptides that are different, show all peptide mapping details, pull out peptideRepeatCount since it does not vary, show only unique alternate locations diff --git src/hg/hgc/encodeClick.c src/hg/hgc/encodeClick.c index b1950dc..4edf210 100644 --- src/hg/hgc/encodeClick.c +++ src/hg/hgc/encodeClick.c @@ -184,63 +184,96 @@ if (++outCount == 50) break; if (inter->next != NULL) webPrintLinkTableNewRow(); } webPrintLinkTableEnd(); sqlFreeResult(&sr); } void doPeptideMapping(struct sqlConnection *conn, struct trackDb *tdb, char *item) /* Print details for a peptideMapping track. */ { char *chrom = cartString(cart,"c"); int start = cgiInt("o"); int end = cgiInt("t"); +char query[256]; char **row; struct sqlResult *sr; -struct peptideMapping *pos = NULL; -int rowOffset; +struct peptideMapping pos; +int rowOffset = 0; // skip bin field +int found = 0; genericHeader(tdb, NULL); + /* Just get the current item. */ -sr = hOrderedRangeQuery(conn, tdb->track, chrom, start, end, NULL, &rowOffset); -if ((row = sqlNextRow(sr)) != NULL) +safef(query, sizeof(query), "select * from %s where name='%s' and chrom='%s' and chromStart=%d and chromEnd=%d", + tdb->track, item, chrom, start, end); +sr = sqlGetResult(conn, query); + +if (sqlFieldColumn(sr, "bin") == 0) + rowOffset = 1; + +while ((row = sqlNextRow(sr)) != NULL) { - pos = peptideMappingLoad(row + rowOffset); - sqlFreeResult(&sr); - } -else + ++found; + peptideMappingStaticLoad(row + rowOffset, &pos); + if (found == 1) { - errAbort("No items in range"); + printf("Item: %s
\n", pos.name); + printPos(pos.chrom, pos.chromStart, pos.chromEnd, pos.strand, TRUE, item); + + printf("
\n"); + printf("Additional details for all peptide mappings of %s:
\n", item); + + webPrintLinkTableStart(); + webPrintLabelCell("Score"); + webPrintLabelCell("Raw Score"); + webPrintLabelCell("Spectrum ID"); + webPrintLabelCell("Peptide Rank"); + } + webPrintLinkTableNewRow(); + webPrintIntCell(pos.score); + webPrintDoubleCell(pos.rawScore); + webPrintLinkCell(pos.spectrumId); + webPrintIntCell(pos.peptideRank); } -printf("Item: %s
\n", pos->name); -printf("Score: %d
\n", pos->score); -printPos(pos->chrom, pos->chromStart, pos->chromEnd, pos->strand, TRUE, item); -printf("Raw Score: %f
\n", pos->rawScore); -printf("Peptide Rank: %d
\n", pos->peptideRank); -printf("Peptide Repeat Count: %d
\n", pos->peptideRepeatCount); -printf("Spectrum ID: %s
\n", pos->spectrumId); -if (pos->peptideRepeatCount > 1) +if (found == 0) + errAbort("No items in range"); + +webPrintLinkTableEnd(); +sqlFreeResult(&sr); + +/* Draw table of other locations */ +printf("
\n"); +printf("Peptide Repeat Count: %d
\n", pos.peptideRepeatCount); +if (pos.peptideRepeatCount > 1) { - char query[256]; + struct hash *hash = hashNew(8); struct peptideMapping anotherPos; - safef(query, sizeof(query), "select * from %s where name=\'%s\' and not (chrom=\'%s\' and chromStart=%d and chromEnd=%d)", - tdb->track, pos->name, pos->chrom, pos->chromStart, pos->chromEnd); + safef(query, sizeof(query), "select * from %s where name='%s' and not (chrom='%s' and chromStart=%d and chromEnd=%d)", + tdb->track, item, chrom, start, end); printf("
\n"); webPrintLinkTableStart(); webPrintLabelCell("Other genomic loci"); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { char s[1024]; peptideMappingStaticLoad(row + rowOffset, &anotherPos); + char k[1024]; + safef(k, sizeof k, "%s.%d.%d", anotherPos.chrom, anotherPos.chromStart, anotherPos.chromEnd); + if (!hashLookup(hash, k)) + { + hashAdd(hash, k, NULL); safef(s, sizeof(s), "%s:%d-%d", hgTracksPathAndSettings(), database, anotherPos.chrom, anotherPos.chromStart+1, anotherPos.chromEnd, anotherPos.chrom, anotherPos.chromStart+1, anotherPos.chromEnd); webPrintLinkTableNewRow(); webPrintLinkCell(s); } + } webPrintLinkTableEnd(); sqlFreeResult(&sr); + freeHash(&hash); } -peptideMappingFree(&pos); + }