a9862308753c6554e6185ec527df7b7ebc0f5450
angie
  Fri Jan 16 12:29:48 2015 -0800
Implementing Kate's suggestions from code review: use CSS classes instead of hardcoded styles in JSX; fix comment and proliferation of if's in annoFormatTab.refs #14649

diff --git src/lib/annoFormatTab.c src/lib/annoFormatTab.c
index e7dbf7a..d6683ce 100644
--- src/lib/annoFormatTab.c
+++ src/lib/annoFormatTab.c
@@ -6,33 +6,33 @@
 #include "annoFormatTab.h"
 #include "annoGratorQuery.h"
 #include "dystring.h"
 
 struct annoFormatTab
     {
     struct annoFormatter formatter;     // External interface
     char *fileName;                     // Output file name, can be "stdout"
     FILE *f;                            // Output file handle
     struct hash *columnVis;             // Hash of columns that have been explicitly selected
                                         // or deselected by user.
     boolean needHeader;			// TRUE if we should print out the header
     };
 
 static void makeFullColumnName(char *fullName, size_t size, char *sourceName, char *colName)
-/* If sourceName is non-full, make fullName sourceName.colName, otherwise just colName. */
+/* If sourceName is non-empty, make fullName sourceName.colName, otherwise just colName. */
 {
-if (sourceName)
+if (isNotEmpty(sourceName))
     safef(fullName, size, "%s.%s", sourceName, colName);
 else
     safecpy(fullName, size, colName);
 }
 
 void annoFormatTabSetColumnVis(struct annoFormatter *vSelf, char *sourceName, char *colName,
                                boolean enabled)
 /* Explicitly include or exclude column in output.  sourceName must be the same
  * as the corresponding annoStreamer source's name. */
 {
 struct annoFormatTab *self = (struct annoFormatTab *)vSelf;
 if (! self->columnVis)
     self->columnVis = hashNew(0);
 char fullName[PATH_LEN];
 makeFullColumnName(fullName, sizeof(fullName), sourceName, colName);
@@ -47,63 +47,60 @@
     char fullName[PATH_LEN];
     makeFullColumnName(fullName, sizeof(fullName), sourceName, colName);
     int vis = hashIntValDefault(self->columnVis, fullName, 1);
     if (vis == 0)
         return FALSE;
     }
 return TRUE;
 }
 
 static void printHeaderColumns(struct annoFormatTab *self, struct annoStreamer *source,
                                boolean isFirst)
 /* Print names of included columns from this source. */
 {
 FILE *f = self->f;
 char *sourceName = source->name;
+char fullName[PATH_LEN];
 if (source->rowType == arWig)
     {
     // Fudge in the row's chrom, start, end as output columns even though they're not in autoSql
     if (isFirst)
 	{
-        if (sourceName)
-            fprintf(f, "#%s.chrom", sourceName);
-        else
-            fputs("#chrom", f);
+        makeFullColumnName(fullName, sizeof(fullName), sourceName, "chrom");
+        fprintf(f, "#%s", fullName);
 	isFirst = FALSE;
 	}
-    if (sourceName)
-        fprintf(f, "\t%s.start\t%s.end", sourceName, sourceName);
-    else
-        fputs("\tstart\tend", f);
+    makeFullColumnName(fullName, sizeof(fullName), sourceName, "start");
+    fprintf(f, "\t%s", fullName);
+    makeFullColumnName(fullName, sizeof(fullName), sourceName, "end");
+    fprintf(f, "\t%s", fullName);
     }
 struct asColumn *col;
 int i;
 for (col = source->asObj->columnList, i = 0;  col != NULL;  col = col->next, i++)
     {
     if (columnIsIncluded(self, sourceName, col->name))
         {
         if (isFirst)
             {
             fputc('#', f);
             isFirst = FALSE;
             }
         else
             fputc('\t', f);
-        if (sourceName)
-            fprintf(f, "%s.%s", sourceName, col->name);
-        else
-            fputs(col->name, f);
+        makeFullColumnName(fullName, sizeof(fullName), sourceName, col->name);
+        fputs(fullName, f);
         }
     }
 }
 
 static void aftInitialize(struct annoFormatter *vSelf, struct annoStreamer *primary,
 			  struct annoStreamer *integrators)
 /* Print header, regardless of whether we get any data after this. */
 {
 struct annoFormatTab *self = (struct annoFormatTab *)vSelf;
 if (self->needHeader)
     {
     char *primaryHeader = primary->getHeader(primary);
     if (isNotEmpty(primaryHeader))
 	fprintf(self->f, "# Header from primary input:\n%s", primaryHeader);
     printHeaderColumns(self, primary, TRUE);