99da3db1b62d39f9ed0e24c5fb65ba3392e575dd
kent
  Mon Jan 11 14:57:13 2021 -0800
Moving writeTsvRow to lib/obscure.c

diff --git src/lib/sparseMatrix.c src/lib/sparseMatrix.c
index 7a1e817..aa15793 100644
--- src/lib/sparseMatrix.c
+++ src/lib/sparseMatrix.c
@@ -1,19 +1,20 @@
 #include "common.h"
 #include "linefile.h"
 #include "hash.h"
 #include "localmem.h"
+#include "obscure.h"
 #include "sparseMatrix.h"
 
 
 struct sparseRowMatrix *sparseRowMatrixNew(int xSize, int ySize)
 /* Make up a new sparseRowMatrix structure */
 {
 struct sparseRowMatrix *matrix;
 AllocVar(matrix);
 matrix->xSize = xSize;
 matrix->ySize = ySize;
 matrix->lm = lmInit(0);
 lmAllocArray(matrix->lm, matrix->rows, ySize);
 return matrix;
 }
 
@@ -61,40 +62,27 @@
     {
     sparseRowMatrixUnpackRow(matrix, y, row, xSize);
     fprintf(f, "%s", rowLabels[y]);
     for (x=0; x<xSize; ++x)
 	{
 	double val = row[x];
 	if (val == 0.0) 
 	    fprintf(f, "\t0");	    // so much zero in the world
 	else
 	    fprintf(f, "\t%g", row[x]);
 	}
     fprintf(f, "\n");
     }
 }
 
-static void writeTsvRow(FILE *f, int rowSize, char **row)
-/* Write out row of strings to a line in tab-sep file */
-{
-if (rowSize > 0)
-    {
-    fprintf(f, "%s", row[0]);
-    int i;
-    for (i=1; i<rowSize; ++i)
-        fprintf(f, "\t%s", row[i]);
-    }
-fprintf(f, "\n");
-}
-
 void sparseRowMatrixSaveAsTsv(struct sparseRowMatrix *matrix, 
     char **columnLabels, char **rowLabels, char *fileName)
 /* Save sparseRowMatrix to tab-sep-file as expanded non-sparse */
 {
 FILE *f = mustOpen(fileName, "w");
 verbose(1, "outputting %d row matrix, a dot every 100 rows\n", matrix->ySize);
 fprintf(f, "gene\t");
 writeTsvRow(f, matrix->xSize, columnLabels);
 sparseRowMatrixTsvBody(matrix, rowLabels, f);
 carefulClose(&f);
 }