void doPeakClusters(struct trackDb *tdb, char *item) /* Display detailed info about a cluster of DNase peaks from other tracks. */ { int start = cartInt(cart, "o"); char *table = tdb->table; int rowOffset = hOffsetPastBin(database, seqName, table); char query[256]; struct sqlResult *sr; char **row; struct bed *cluster = NULL; struct sqlConnection *conn = hAllocConn(database); cartWebStart(cart, database, "%s item details", tdb->shortLabel); sqlSafef(query, sizeof(query), "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d", table, item, seqName, start); sr = sqlGetResult(conn, query); row = sqlNextRow(sr); if (row != NULL) cluster = bedLoadN(row+rowOffset, 5); sqlFreeResult(&sr); if (cluster != NULL) { /* Get list of subgroups to display */ char *inputTableFieldDisplay = trackDbSetting(tdb, "inputTableFieldDisplay"); if (inputTableFieldDisplay != NULL) { struct slName *fieldList = stringToSlNames(inputTableFieldDisplay); char *inputTrackTable = trackDbRequiredSetting(tdb, "inputTrackTable"); /* Print out some information about the cluster overall. */ printf("<B>Items in Cluster:</B> %s of %d<BR>\n", cluster->name, sqlRowCount(conn, sqlCheckIdentifier(inputTrackTable))); printf("<B>Cluster Score (out of 1000):</B> %d<BR>\n", cluster->score); printPos(cluster->chrom, cluster->chromStart, cluster->chromEnd, NULL, TRUE, NULL); /* In a new section put up list of hits. */ webNewSection("List of Items in Cluster"); webPrintLinkTableStart(); printClusterTableHeader(fieldList, FALSE, FALSE, TRUE); printPeakClusterInfo(tdb, cart, conn, inputTrackTable, fieldList, cluster); } else errAbort("Missing required trackDb setting %s for track %s", "inputTableFieldDisplay", tdb->track); webPrintLinkTableEnd(); } printf("<A HREF=\"%s&g=htcListItemsAssayed&table=%s\" TARGET_blank>", hgcPathAndSettings(), tdb->track); printf("List all items assayed"); printf("</A><BR>\n"); webNewSection("Track Description"); printTrackHtml(tdb); hFreeConn(&conn); }
void expRestoreTable(char *file) /* Fill empty table with experiments in .ra file with id's */ { struct hash *ra = NULL; struct lineFile *lf = lineFileOpen(file, TRUE); struct encodeExp *exp; int ix = 1; int expId; char *accession; char *key; verbose(1, "Restoring experiments from file \'%s\' to table \'%s\'\n", file, table); if (sqlRowCount(connExp, sqlCheckIdentifier(table)) != 0) errAbort("ERROR: table for restore must exist and be empty"); while ((ra = raNextRecord(lf)) != NULL) { exp = encodeExpFromRa(ra); /* save accession and id as we may stomp on these for to-delete experiments */ accession = cloneString(exp->lab); expId = exp->ix; key = encodeExpKey(exp); while (ix < expId) { exp->accession = "DELETED"; exp->ix = ix; verbose(3, "Adding row for deleted experiment %d\n", ix); encodeExpAdd(connExp, table, exp); ix++; } /* restore accession and id */ exp->accession = accession; exp->ix = expId; encodeExpAdd(connExp, table, exp); verbose(3, "Adding row for experiment %d: %s\n", ix, key); ix++; } verbose(1, "To complete restore, delete rows where accession=DELETED\n"); }
SQLRETURN SQL_API SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount) { o::SQLRowCount sqlRowCount(StatementHandle, RowCount); return sqlRowCount(); }