4cab7f311cadce7428c1d7e1c4dfdcb0d3a43033
angie
Wed Jul 27 10:32:19 2011 -0700
Feature #3710 (vcfTabix UI options): Added controls for selection of centervariant for haplotype clustering/sorting. Also, some hgc improvements:
made the Genotype Details table into a collapsible section; better display
of QUAL and FILTER column values, which also involved improving the
representation of those columns in src/inc/vcf.h.
diff --git src/hg/hgc/vcfClick.c src/hg/hgc/vcfClick.c
index 4a1565d..4339481 100644
--- src/hg/hgc/vcfClick.c
+++ src/hg/hgc/vcfClick.c
@@ -1,83 +1,102 @@
/* vcfTrack -- handlers for Variant Call Format data. */
#ifdef USE_TABIX
#include "common.h"
#include "dystring.h"
#include "errCatch.h"
#include "hCommon.h"
#include "hdb.h"
#include "hgc.h"
#include "htmshell.h"
+#include "jsHelper.h"
#if (defined USE_TABIX && defined KNETFILE_HOOKS)
#include "knetUdc.h"
#include "udc.h"
#endif//def USE_TABIX && KNETFILE_HOOKS
#include "pgSnp.h"
#include "trashDir.h"
#include "vcf.h"
-
+#include "vcfUi.h"
#define NA "n/a"
-static void printListWithDescriptions(struct vcfFile *vcff, char *str, char *sep, struct vcfInfoDef *infoDefs)
-/* Given a VCF field, its separator char and a list of vcfInfoDefs, print out a list
- * of values with descriptions if descriptions are available. */
+static void printKeysWithDescriptions(struct vcfFile *vcff, int wordCount, char **words,
+ struct vcfInfoDef *infoDefs)
+/* Given an array of keys, print out a list of values with
+ * descriptions if descriptions are available. */
{
-char *copy = cloneString(str);
-char *words[256];
-int i, wordCount = chopString(copy, sep, words, ArraySize(words));
+int i;
for (i = 0; i < wordCount; i++)
{
if (i > 0)
printf(", ");
char *key = words[i];
const struct vcfInfoDef *def = vcfInfoDefForKey(vcff, key);
if (def != NULL)
printf("%s (%s)", htmlEncode(key), def->description);
else
printf("%s", htmlEncode(key));
}
printf("
\n");
}
+static void printListWithDescriptions(struct vcfFile *vcff, char *str, char *sep, struct vcfInfoDef *infoDefs)
+/* Given a VCF field, its separator char and a list of vcfInfoDefs, print out a list
+ * of values with descriptions if descriptions are available. */
+{
+char *copy = cloneString(str);
+char *words[256];
+int wordCount = chopString(copy, sep, words, ArraySize(words));
+printKeysWithDescriptions(vcff, wordCount, words, infoDefs);
+}
+
static void vcfAltAlleleDetails(struct vcfRecord *rec)
/* If VCF header specifies any symbolic alternate alleles, pull in descriptions. */
{
printf("Alternate allele(s): ");
if (sameString(rec->alt, "."))
{
printf(NA"
\n");
return;
}
struct vcfFile *vcff = rec->file;
printListWithDescriptions(vcff, rec->alt, ",", vcff->altDefs);
}
+static void vcfQualDetails(struct vcfRecord *rec)
+/* If VCF header specifies a quality/confidence score (not "."), print it out. */
+{
+printf("Quality/confidence score: %s
\n", sameString(rec->qual, ".") ? NA : rec->qual);
+}
+
static void vcfFilterDetails(struct vcfRecord *rec)
/* If VCF header specifies any filters, pull in descriptions. */
{
-if (sameString(rec->filter, "PASS"))
- printf("Filter: ");
+if (rec->filterCount == 0 || sameString(rec->filters[0], "."))
+ printf("Filter: "NA"
\n");
+else if (rec->filterCount == 1 && sameString(rec->filters[0], "PASS"))
+ printf("Filter: PASS
\n");
else
+ {
printf("Filter failures: ");
+ printf("\n");
struct vcfFile *vcff = rec->file;
-if (sameString(rec->filter, "."))
- printf(NA"
\n");
-else
- printListWithDescriptions(vcff, rec->filter, ",", vcff->filterDefs);
+ printKeysWithDescriptions(vcff, rec->filterCount, rec->filters, vcff->filterDefs);
+ printf("\n");
+ }
}
static void vcfInfoDetails(struct vcfRecord *rec)
/* Expand info keys to descriptions, then print out keys and values. */
{
if (rec->infoCount == 0)
return;
struct vcfFile *vcff = rec->file;
puts("INFO column annotations:
");
puts("