d9573e3b023c7f5d3e312df94a42aeb044cb12b8 hiram Tue Jan 2 13:39:40 2024 -0800 protect crispr track click for no database (e.g. hub hs1) no redmine diff --git src/hg/hgc/bigBedClick.c src/hg/hgc/bigBedClick.c index 87a82bb..f018643 100644 --- src/hg/hgc/bigBedClick.c +++ src/hg/hgc/bigBedClick.c @@ -82,33 +82,38 @@ return; } printf("<tr><td>Potential Off-targets</td>\n"); printf("<td>\n"); char *coords[65536]; int coordCount = chopByChar(val, '|', coords, ArraySize(coords)); int i; struct subText *subList = NULL; slSafeAddHead(&subList, subTextNew("ig:", "intergenic ")); slSafeAddHead(&subList, subTextNew("ex:", "exon ")); slSafeAddHead(&subList, subTextNew("in:", "intron ")); slSafeAddHead(&subList, subTextNew("|", "-")); -struct sqlConnection *conn = hAllocConn(database); - -boolean hasLocus = sqlTableExists(conn, "locusName"); +boolean hasDb = sqlDatabaseExists(database); +boolean hasLocus = FALSE; +struct sqlConnection *conn = NULL; +if (hasDb) + { + conn = hAllocConn(database); + hasLocus = sqlTableExists(conn, "locusName"); + } if (coordCount==0) puts("Too many off-targets found to display or no off-targets. Please use the Crispor.org link at the top of the page to show all off-targets.\n"); else { printf("<table style='border-collapse:collapse; font-size:12px; table-layout:fixed'>\n"); printf("<tr>\n" "<th style='width:26em'>Mismatched nucleotides</th>\n" "<th style='width:9em'>CFD Score</th>\n"); if (hasLocus) printf("<th style='width:40em'>Locus</th>\n"); printf("<th style='width:30em'>Position</th></tr>\n"); } @@ -166,30 +171,31 @@ char *desc = row[4]; char *descLong = subTextString(subList, desc); printf("<td>%s</td>", descLong); freeMem(descLong); } sqlFreeResult(&sr); } // print link to location printf("<td><a href='%s&db=%s&position=%s%%3A%d-%d'>%s:%d (%c)</a></td>\n", hgTracksPathAndSettings(), database, chrom, pos+1, pos+23, chrom, pos+1, strand); printf("</tr>\n"); } +if (hasDb) hFreeConn(&conn); printf("<tr>\n"); if (coordCount!=0) printf("</table>\n"); if (collapsed) { printf("<p><a id='crisprShowAllLink' href='#'>" "Show all %d off-targets...</a>\n", coordCount); jsOnEventById("click", "crisprShowAllLink", "crisprShowAll(); return false;"); // inline .js is bad style but why pollute our global .js files for such a rare // case? Maybe we should have a generic "collapsible" class, like bootstrap? jsInline( "function crisprShowAll() {\n" " $('#crisprShowAllLink').hide();\n" " $('.crisprLinkHidden').show();\n"