c240989c15afc0e39b1a3dc9158501759b3b31ba
kent
  Mon Apr 24 16:49:25 2017 -0700
A first cut at a utility that might be useful for returning context information on a trix search.

diff --git src/index/trixContextIndex/trixContextIndex.c src/index/trixContextIndex/trixContextIndex.c
new file mode 100644
index 0000000..04e1e99
--- /dev/null
+++ src/index/trixContextIndex/trixContextIndex.c
@@ -0,0 +1,50 @@
+/* trixContextIndex - Index in.txt file used with ixIxx to produce a two column file with symbol name and file offset for that line.. */
+#include "common.h"
+#include "linefile.h"
+#include "hash.h"
+#include "options.h"
+
+void usage()
+/* Explain usage and exit. */
+{
+errAbort(
+  "trixContextIndex - Index in.txt file used with ixIxx to produce a two column file with symbol name and file offset for that line.\n"
+  "usage:\n"
+  "   trixContextIndex in.txt out.tab\n"
+  "options:\n"
+  "   -xxx=XXX\n"
+  );
+}
+
+/* Command line validation table. */
+static struct optionSpec options[] = {
+   {NULL, 0},
+};
+
+void trixContextIndex(char *input, char *output)
+/* trixContextIndex - Index in.txt file used with ixIxx to produce a two column file with symbol name and file offset for that line.. */
+{
+struct lineFile *lf = lineFileOpen(input, TRUE);
+FILE *f = mustOpen(output, "w");
+char *line;
+while (lineFileNextReal(lf, &line))
+    {
+    long long pos = lineFileTell(lf);
+    char *word = nextWord(&line);
+    if (word == NULL)
+        errAbort("Short line %d of %s", lf->lineIx, input);
+     fprintf(f, "%s\t%lld\n", word, pos);
+    }
+
+carefulClose(&f);
+}
+
+int main(int argc, char *argv[])
+/* Process command line. */
+{
+optionInit(&argc, argv, options);
+if (argc != 3)
+    usage();
+trixContextIndex(argv[1], argv[2]);
+return 0;
+}