Skip to content

Commit

Permalink
Save results in memory, write them to the actual output file instead …
Browse files Browse the repository at this point in the history
…of temporary files.
  • Loading branch information
brianwalenz committed Mar 4, 2021
1 parent 77384a0 commit 1a1db87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
11 changes: 8 additions & 3 deletions src/merfin/merfin-globals.H
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public:

// Variant results.

string result;
//uint64 vmersLen = 0;
//uint64 vmersMax = 0;
//char *vmers = nullptr;
Expand All @@ -102,7 +103,6 @@ public:
}
~merfinThrData() {
delete oDebug;
delete oVcf;
}

// Our ident.
Expand All @@ -113,8 +113,6 @@ public:

compressedFileWriter *oDebug = nullptr;
uint64 varMerId = 0;

compressedFileWriter *oVcf = nullptr;
};


Expand All @@ -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;
}
Expand Down
20 changes: 9 additions & 11 deletions src/merfin/merfin-variants.C
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -286,15 +280,17 @@ 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
else {
vector<vcfRecord*> 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.
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 1a1db87

Please sign in to comment.