From 1a1db870b9220216b5a13296e1d036d8baf05e34 Mon Sep 17 00:00:00 2001 From: "Brian P. Walenz" Date: Wed, 3 Mar 2021 19:43:42 -0500 Subject: [PATCH] Save results in memory, write them to the actual output file instead of temporary files. --- src/merfin/merfin-globals.H | 11 ++++++++--- src/merfin/merfin-variants.C | 20 +++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/merfin/merfin-globals.H b/src/merfin/merfin-globals.H index d2138d2..7dca9e1 100644 --- a/src/merfin/merfin-globals.H +++ b/src/merfin/merfin-globals.H @@ -82,6 +82,7 @@ public: // Variant results. + string result; //uint64 vmersLen = 0; //uint64 vmersMax = 0; //char *vmers = nullptr; @@ -102,7 +103,6 @@ public: } ~merfinThrData() { delete oDebug; - delete oVcf; } // Our ident. @@ -113,8 +113,6 @@ public: compressedFileWriter *oDebug = nullptr; uint64 varMerId = 0; - - compressedFileWriter *oVcf = nullptr; }; @@ -132,8 +130,15 @@ public: class merfinGlobal { public: ~merfinGlobal() { + delete dumpOutFile; + delete oVCF; + + delete [] histUndr; + delete [] histOver; + delete seqFile; delete inVcf; + delete asmLookup; delete readLookup; } diff --git a/src/merfin/merfin-variants.C b/src/merfin/merfin-variants.C index c248e9e..f7d2b6d 100644 --- a/src/merfin/merfin-variants.C +++ b/src/merfin/merfin-variants.C @@ -149,14 +149,8 @@ processVariants(void *G, void *T, void *S) { if (t->oDebug == nullptr) { char name[FILENAME_MAX+1]; - snprintf(name, FILENAME_MAX, "%s.%02d.debug", g->outName, t->threadID); + snprintf(name, FILENAME_MAX, "%s.%02d.debug.gz", g->outName, t->threadID); t->oDebug = new compressedFileWriter(name); - - snprintf(name, FILENAME_MAX, "%s.%02d.vcf", g->outName, t->threadID); - t->oVcf = new compressedFileWriter(name); - - for (string header : g->inVcf->getHeaders()) - fprintf(t->oVcf->file(), "%s\n", header.c_str()); } // Get chromosome specific posGTs, and iterate over. @@ -286,7 +280,8 @@ processVariants(void *G, void *T, void *S) { // Experimental: output vcf according to k* if (g->bykstar) { - fprintf(t->oVcf->file(), "%s", seqMer->bestVariant().c_str()); + //fprintf(t->oVcf->file(), "%s", seqMer->bestVariant().c_str()); + s->result += seqMer->bestVariant(); } // Filter vcf and print as it was in the original vcf, conservatively @@ -294,7 +289,8 @@ processVariants(void *G, void *T, void *S) { vector records = seqMer->bestVariantOriginalVCF(); for (uint64 i = 0; i < records.size(); i++) - records[i]->save(t->oVcf); + //records[i]->save(t->oVcf); + s->result += records[i]->save(); } // Cleanup. @@ -329,9 +325,11 @@ outputVariants(void *G, void *S) { fprintf(g->oVCF->file(), "%s\n", header.c_str()); } - // - + // Dump the output string to the output file. Flush it just + // so we can get a reliable record of where we are. + fputs(s->result.c_str(), g->oVCF->file()); + fflush(g->oVCF->file()); // Bye.