e2ec5ef77645a662ba31c7cfbd7499794975275a
angie
  Fri Mar 23 16:44:07 2012 -0700
Feature #6152 (Variant Annotation Tool): Initial work, squashed infrom origin/annoGrator branch.  Superclasses annoColumn, annoFilter,
annoRow, annoStreamer, annoGrator, and annoFormatter define the core
interfaces for passing data and configuration to and from components.
The annoGrator superclass can join annoRows on position and pass
forward all rows of secondary source.  The annoGratorQuery module
orchestrates the passing of annoRows between the primary source,
annoGrator(s) and annoFormatter(s).  The subclasses annoStreamDb and
annoFormatTab, together with hg/lib/tests/annoGratorTester.c, can join
columns of two database tables such as hg19's pgNA12878 and knownGene
into tab-separated output.

diff --git src/lib/annoRow.c src/lib/annoRow.c
new file mode 100644
index 0000000..5f9a668
--- /dev/null
+++ src/lib/annoRow.c
@@ -0,0 +1,57 @@
+/* annoRow -- basic data interchange unit of annoGratorQuery framework. */
+
+#include "annoRow.h"
+
+struct annoRow *annoRowFromStringArray(char *chrom, uint start, uint end, boolean rightJoinFail,
+				       char **wordsIn, int numCols)
+/* Allocate & return an annoRow with words cloned from wordsIn. */
+{
+struct annoRow *aRow;
+AllocVar(aRow);
+aRow->chrom = cloneString(chrom);
+aRow->start = start;
+aRow->end = end;
+aRow->rightJoinFail = rightJoinFail;
+char **words;
+AllocArray(words, numCols);
+int i;
+for (i = 0;  i < numCols;  i++)
+    words[i] = cloneString(wordsIn[i]);
+aRow->words = words;
+return aRow;
+}
+
+struct annoRow *annoRowClone(struct annoRow *rowIn, int numCols)
+/* Allocate & return a single annoRow cloned from rowIn. */
+{
+return annoRowFromStringArray(rowIn->chrom, rowIn->start, rowIn->end, rowIn->rightJoinFail,
+			      rowIn->words, numCols);
+}
+
+void annoRowFree(struct annoRow **pRow, int numCols)
+/* Free a single annoRow. */
+{
+if (pRow == NULL)
+    return;
+struct annoRow *row = *pRow;
+freeMem(row->chrom);
+int i;
+for (i = 0;  i < numCols;  i++)
+    freeMem(row->words[i]);
+freeMem(row->words);
+freez(pRow);
+return;
+}
+
+void annoRowFreeList(struct annoRow **pList, int numCols)
+/* Free a single annoRow. */
+{
+if (pList == NULL)
+    return;
+struct annoRow *row, *nextRow;
+for (row = *pList;  row != NULL;  row = nextRow)
+    {
+    nextRow = row->next;
+    annoRowFree(&row, numCols);
+    }
+}