e70152e44cc66cc599ff6b699eb8adc07f3e656a
kent
Sat May 24 21:09:34 2014 -0700
Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment.
diff --git src/hg/lib/geneCheckWidget.c src/hg/lib/geneCheckWidget.c
index e41cfdd..30831dd 100644
--- src/hg/lib/geneCheckWidget.c
+++ src/hg/lib/geneCheckWidget.c
@@ -1,136 +1,139 @@
/* geneCheckWidget - output HTML tables to display geneCheck or
* geneCheckDetails with browser links */
+
+/* Copyright (C) 2014 The Regents of the University of California
+ * See README in this or parent directory for licensing information. */
#include "common.h"
#include "geneCheckWidget.h"
#include "geneCheck.h"
#include "geneCheckDetails.h"
#include "cart.h"
#include "hCommon.h"
static void prTracksAnchor(struct cart *cart, char *chrom, int start, int end,
char *target, char *fmt, ...)
/* print an anchor to hgTracks, printf text content. Target can be
* NULL */
{
va_list args;
va_start(args, fmt);
printf("");
vprintf(fmt, args);
printf("");
va_end(args);
}
static void prNameValCellStr(char *name, char *value, char *okVal, char *probClass)
/* output a string name/value pair as adjacent cells in a table, set class to
* probClass if value is not okVal */
{
printf("
");
if (!sameString(value, okVal))
printf("%s | %s", probClass, name, probClass, value);
else
printf(" | %s | %s", name, value);
printf(" |
\n");
}
static void prNameValCellInt(char *name, int value, int okVal, char *probClass)
/* output a int name/value pair as adjacent cells in a table, set class to
* probClass if value is not okVal */
{
printf("");
if (value != okVal)
printf("%s | %d", probClass, name, probClass, value);
else
printf(" | %s | %d", name, value);
printf(" |
\n");
}
void geneCheckWidgetSummary(struct geneCheck *gc, char *tblClass, char *caption)
/* write a table with result summary for one gene; caption maybe NULL */
{
printf("\n", tblClass);
if (caption != NULL)
printf("%s\n", caption);
printf("\n");
prNameValCellStr("frame", gc->frame, "ok", "errorBg");
prNameValCellStr("start", gc->start, "ok", "warnBg");
prNameValCellStr("stop", gc->stop, "ok", "warnBg");
prNameValCellInt("ORF stops", gc->orfStop, 0, "errorBg");
prNameValCellInt("CDS gaps", gc->cdsGap-gc->cdsMult3Gap, 0, "errorBg");
prNameValCellInt("CDS mult3 gaps", gc->cdsMult3Gap, 0, "warnBg");
prNameValCellInt("CDS bad splices", gc->cdsSplice, 0, "errorBg");
prNameValCellInt("UTR gaps", gc->utrGap, 0, "warnBg");
prNameValCellInt("UTR bad splices", gc->utrSplice, 0, "errorBg");
printf("
\n");
}
static void printSpliceInfo(struct cart *cart, struct geneCheck *gc, struct geneCheckDetails *gcd,
char *target)
/* print details of splice problems, with links */
{
// info is like: CC..AG
static int context = 3;
// get correct splice site locations
int start5, end5, start3, end3;
if (gc->strand[0] == '+')
{
start5= gcd->chrStart-context;
end5 = gcd->chrStart+2+context;
start3 = (gcd->chrEnd-2)-context;
end3 = (gcd->chrEnd-2)+context;
}
else
{
start5 = (gcd->chrEnd-2)-context;
end5 = (gcd->chrEnd-2)+context;
start3= gcd->chrStart-context;
end3 = gcd->chrStart+2+context;
}
prTracksAnchor(cart, gcd->chr, start5, end5, target, "%.2s", gcd->info);
printf("..");
prTracksAnchor(cart, gcd->chr, start3, end3, target, "%.2s", gcd->info+4);
}
static void dispDetailsRow(struct cart *cart, struct geneCheck *gc,
struct geneCheckDetails *gcd, char *target)
/* display a row of geneCheck details row */
{
/* get location and a little context */
static int context = 20;
int start = (gcd->chrStart < context) ? 0 : gcd->chrStart-context;
int end = gcd->chrEnd+context;
printf("%s", gcd->problem);
printf(" | ");
if (sameString(gcd->problem, "badCdsSplice") || sameString(gcd->problem, "badUtrSplice"))
printSpliceInfo(cart, gc, gcd, target);
else
printf("%s", gcd->info);
printf(" | ");
if (gcd->chrStart < gcd->chrEnd)
prTracksAnchor(cart, gcd->chr, start, end, target,
"%s:%d-%d", gcd->chr, gcd->chrStart, gcd->chrEnd);
printf(" |
\n");
}
void geneCheckWidgetDetails(struct cart *cart, struct geneCheck *gc,
struct geneCheckDetails *gcdList, char *tblClass,
char *caption, char *target)
/* display gene-check details; caption maybe NULL. target is target of
* links if not NULL.*/
{
struct geneCheckDetails *gcd;
printf("\n", tblClass);
if (caption != NULL)
printf("%s\n", caption);
printf("\n");
printf("Problem | Info | Location |
\n");
printf("\n");
printf("\n");
for (gcd = gcdList; gcd != NULL; gcd = gcd->next)
dispDetailsRow(cart, gc, gcd, target);
printf("
\n");
}