d18a8487b9078785b90e331bf388e0fcbff3d181 kent Mon May 24 17:29:24 2021 -0700 Cleaning up diagnostic/verbose output diff --git src/utils/matrixMarketToTsv/matrixMarketToTsv.c src/utils/matrixMarketToTsv/matrixMarketToTsv.c index 533d55e..e8de5c8 100644 --- src/utils/matrixMarketToTsv/matrixMarketToTsv.c +++ src/utils/matrixMarketToTsv/matrixMarketToTsv.c @@ -1,23 +1,25 @@ /* matrixMarketToTsv - Convert matrix file from Matrix Market sparse matrix format to tab-separated-values.. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "matrixMarket.h" #include "obscure.h" +int dotMod = 100; // Put out an I'm alive dot every so often + void usage() /* Explain usage and exit. */ { errAbort( "matrixMarketToTsv - Convert matrix file from Matrix Market sparse matrix format to tab-separated-values.\n" "usage:\n" " matrixMarketToTsv in.mtx sampleLabels.lst geneLabels.lst out.tsv\n" "where in.mtx is a matrix market format matrix. SampleLabels is a text file\n" "with one label per line. It will end in the first row of the output.\n" "GeneLabels.lst is a text file with one gene name per line. It will end up\n" "in the first column of the output\n" ); } /* Command line validation table. */ @@ -42,57 +44,61 @@ errAbort("Mismatch between column count in matrix and gene count"); /* Create matrix in memory the right size */ double **rows; AllocArray(rows, geneCount); int i; for (i=0; i<geneCount; ++i) rows[i] = needMem(sampleCount * sizeof(double) ); /* Fill in matrix from mart */ verbose(1, "Reading matrix\n"); while (matrixMarketNext(mm)) { rows[mm->x][mm->y] = mm->val; } -verbose(1, "Done reading matrix\n"); matrixMarketClose(&mm); /* Open output */ +verbose(1, "Writing output matrix\n"); FILE *f = mustOpen(outMatrix, "w"); /* Write first line */ struct slName *name = sampleList; for (i=0; i<sampleCount; ++i) { fprintf(f, "\t%s", name->name); name = name->next; } fprintf(f, "\n"); /* Write out rest of lines */ -dotForUserInit(100); +if (geneCount >= dotMod) + verbose(1, "Showing one dot for every dotMod genes output\n"); +dotForUserInit(dotMod); name = geneList; for (i=0; i<geneCount; ++i) { fprintf(f, "%s", name->name); name = name->next; int j; for (j=0; j<sampleCount; ++j) { fprintf(f, "\t%g", rows[i][j]); } fprintf(f, "\n"); dotForUser(); } +if (geneCount >= dotMod) + fprintf(stderr, "\n"); /* To avoid ragged end of dots */ carefulClose(&f); } int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 5) usage(); matrixMarketToTsv(argv[1], argv[2], argv[3], argv[4]); return 0; }