From 19066519066b4a71927aa9001091b7a3d03423d4 Mon Sep 17 00:00:00 2001 From: BenLangmead Date: Sat, 15 Apr 2017 22:22:43 -0400 Subject: [PATCH] fix failure to propagate nthreads and output batch size to relevant constructors --- ebwt_search.cpp | 78 +++++++++++++++++++++++++++++++++++++++------------------ hit.h | 36 +++++++++++++++++++------- sam.h | 30 +++++++++++++--------- 3 files changed, 98 insertions(+), 46 deletions(-) diff --git a/ebwt_search.cpp b/ebwt_search.cpp index f418153..7179154 100644 --- a/ebwt_search.cpp +++ b/ebwt_search.cpp @@ -91,6 +91,7 @@ static bool strata; // true -> don't stop at stratum boundaries static bool refOut; // if true, alignments go to per-ref files static int partitionSz; // output a partitioning key in first field static int readsPerBatch; // # reads to read from input file at once +static int outBatchSz; // # alignments to write to output file at once static bool noMaqRound; // true -> don't round quals to nearest 10 like maq static bool fileParallel; // separate threads read separate input files in parallel static bool useShmem; // use shared memory to hold the index @@ -198,6 +199,7 @@ static void resetOptions() { refOut = false; // if true, alignments go to per-ref files partitionSz = 0; // output a partitioning key in first field readsPerBatch = 16; // # reads to read from input file at once + outBatchSz = 16; // # alignments to wrote to output file at once noMaqRound = false; // true -> don't round quals to nearest 10 like maq fileParallel = false; // separate threads read separate input files in parallel useShmem = false; // use shared memory to hold the index @@ -2598,8 +2600,6 @@ patsrcFromStrings(int format, } } -#define PASS_DUMP_FILES dumpAlBase, dumpUnalBase, dumpMaxBase - static string argstr; template @@ -2872,17 +2872,25 @@ static void driver(const char * type, ebwt.nPat(), offBase, colorSeq, colorQual, printCost, suppressOuts, rmap, amap, - fullRef, PASS_DUMP_FILES, + fullRef, + dumpAlBase, + dumpUnalBase, + dumpMaxBase, format == TAB_MATE, sampleMax, - refnames, partitionSz); + refnames, nthreads, + outBatchSz, partitionSz); } else { sink = new VerboseHitSink( fout, offBase, colorSeq, colorQual, printCost, suppressOuts, rmap, amap, - fullRef, PASS_DUMP_FILES, + fullRef, + dumpAlBase, + dumpUnalBase, + dumpMaxBase, format == TAB_MATE, sampleMax, - refnames, partitionSz); + refnames, nthreads, + outBatchSz, partitionSz); } break; case OUTPUT_SAM: @@ -2890,23 +2898,29 @@ static void driver(const char * type, throw 1; } else { SAMHitSink *sam = new SAMHitSink( - fout, 1, rmap, amap, - fullRef, samNoQnameTrunc, defaultMapq, - PASS_DUMP_FILES, - format == TAB_MATE, sampleMax, - refnames, nthreads); + fout, 1, rmap, amap, + fullRef, samNoQnameTrunc, + dumpAlBase, + dumpUnalBase, + dumpMaxBase, + format == TAB_MATE, + sampleMax, + refnames, + nthreads, + outBatchSz); if(!samNoHead) { vector refnames; if(!samNoSQ) { readEbwtRefnames(adjustedEbwtFileBase, refnames); } sam->appendHeaders( - sam->out(0), ebwt.nPat(), - refnames, color, samNoSQ, rmap, - ebwt.plen(), fullRef, - samNoQnameTrunc, - argstr.c_str(), - rgs.empty() ? NULL : rgs.c_str()); + sam->out(0), + ebwt.nPat(), + refnames, color, samNoSQ, rmap, + ebwt.plen(), fullRef, + samNoQnameTrunc, + argstr.c_str(), + rgs.empty() ? NULL : rgs.c_str()); } sink = sam; } @@ -2914,16 +2928,30 @@ static void driver(const char * type, case OUTPUT_CONCISE: if(refOut) { sink = new ConciseHitSink( - ebwt.nPat(), offBase, - PASS_DUMP_FILES, - format == TAB_MATE, sampleMax, - refnames, reportOpps); + ebwt.nPat(), + offBase, + dumpAlBase, + dumpUnalBase, + dumpMaxBase, + format == TAB_MATE, + sampleMax, + refnames, + nthreads, + outBatchSz, + reportOpps); } else { sink = new ConciseHitSink( - fout, offBase, - PASS_DUMP_FILES, - format == TAB_MATE, sampleMax, - refnames, reportOpps); + fout, + offBase, + dumpAlBase, + dumpUnalBase, + dumpMaxBase, + format == TAB_MATE, + sampleMax, + refnames, + nthreads, + outBatchSz, + reportOpps); } break; case OUTPUT_NONE: diff --git a/hit.h b/hit.h index ee6a8d6..6b94364 100644 --- a/hit.h +++ b/hit.h @@ -156,9 +156,9 @@ class HitSink { const std::string& dumpMax, bool onePairFile, bool sampleMax, - vector* refnames = NULL, - size_t nthreads = 1, - int perThreadBufSize = 512) : + vector* refnames, + size_t nthreads, + int perThreadBufSize) : _outs(), _deleteOuts(false), _refnames(refnames), @@ -204,7 +204,9 @@ class HitSink { const std::string& dumpMax, bool onePairFile, bool sampleMax, - vector* refnames = NULL) : + vector* refnames, + size_t nthreads, + int perThreadBufSize) : _outs(), _deleteOuts(true), _refnames(refnames), @@ -1432,6 +1434,8 @@ class ConciseHitSink : public HitSink { bool onePairFile, bool sampleMax, std::vector* refnames, + size_t nthreads, + int perThreadBufSize, bool reportOpps = false) : HitSink( out, @@ -1440,7 +1444,9 @@ class ConciseHitSink : public HitSink { dumpMax, onePairFile, sampleMax, - refnames), + refnames, + nthreads, + perThreadBufSize), _reportOpps(reportOpps), offBase_(offBase) { } @@ -1457,6 +1463,8 @@ class ConciseHitSink : public HitSink { bool onePairFile, bool sampleMax, std::vector* refnames, + size_t nthreads, + int perThreadBufSize, bool reportOpps = false) : HitSink( numOuts, @@ -1465,7 +1473,9 @@ class ConciseHitSink : public HitSink { dumpMax, onePairFile, sampleMax, - refnames), + refnames, + nthreads, + perThreadBufSize), _reportOpps(reportOpps), offBase_(offBase) { } @@ -1553,6 +1563,8 @@ class VerboseHitSink : public HitSink { bool onePairFile, bool sampleMax, std::vector* refnames, + size_t nthreads, + int perThreadBufSize, int partition = 0) : HitSink( out, @@ -1561,7 +1573,9 @@ class VerboseHitSink : public HitSink { dumpMax, onePairFile, sampleMax, - refnames), + refnames, + nthreads, + perThreadBufSize), partition_(partition), offBase_(offBase), colorSeq_(colorSeq), @@ -1592,6 +1606,8 @@ class VerboseHitSink : public HitSink { bool onePairFile, bool sampleMax, std::vector* refnames, + size_t nthreads, + int perThreadBufSize, int partition = 0) : HitSink( numOuts, @@ -1600,7 +1616,9 @@ class VerboseHitSink : public HitSink { dumpMax, onePairFile, sampleMax, - refnames), + refnames, + nthreads, + perThreadBufSize), partition_(partition), offBase_(offBase), colorSeq_(colorSeq), @@ -1664,7 +1682,7 @@ class VerboseHitSink : public HitSink { */ class StubHitSink : public HitSink { public: - StubHitSink() : HitSink(new OutFileBuf(".tmp"), "", "", "", false, false, NULL) { } + StubHitSink() : HitSink(new OutFileBuf(".tmp"), "", "", "", false, false, NULL, 1, 1) { } virtual void append(BTString& o, const Hit& h, int mapq, int xms) { } }; diff --git a/sam.h b/sam.h index b6f1d45..b103418 100644 --- a/sam.h +++ b/sam.h @@ -47,14 +47,14 @@ class SAMHitSink : public HitSink { AnnotationMap *amap, bool fullRef, bool noQnameTrunc, - int defaultMapq, const std::string& dumpAl, const std::string& dumpUnal, const std::string& dumpMax, bool onePairFile, bool sampleMax, std::vector* refnames, - int nthreads) : + size_t nthreads, + int perThreadBufSize) : HitSink( out, dumpAl, @@ -63,9 +63,12 @@ class SAMHitSink : public HitSink { onePairFile, sampleMax, refnames, - nthreads), - offBase_(offBase), defaultMapq_(defaultMapq), - rmap_(rmap), amap_(amap), fullRef_(fullRef), + nthreads, + perThreadBufSize), + offBase_(offBase), + rmap_(rmap), + amap_(amap), + fullRef_(fullRef), noQnameTrunc_(noQnameTrunc) { } /** @@ -78,13 +81,14 @@ class SAMHitSink : public HitSink { ReferenceMap *rmap, AnnotationMap *amap, bool fullRef, - int defaultMapq, const std::string& dumpAl, const std::string& dumpUnal, const std::string& dumpMax, bool onePairFile, bool sampleMax, - std::vector* refnames) : + std::vector* refnames, + size_t nthreads, + int perThreadBufSize) : HitSink( numOuts, dumpAl, @@ -92,9 +96,13 @@ class SAMHitSink : public HitSink { dumpMax, onePairFile, sampleMax, - refnames), - offBase_(offBase), defaultMapq_(defaultMapq), - rmap_(rmap), amap_(amap), fullRef_(fullRef) { } + refnames, + nthreads, + perThreadBufSize), + offBase_(offBase), + rmap_(rmap), + amap_(amap), + fullRef_(fullRef) { } /** * Append a verbose, readable hit to the output stream @@ -151,8 +159,6 @@ class SAMHitSink : public HitSink { int offBase_; /// Add this to reference offsets before outputting. /// (An easy way to make things 1-based instead of /// 0-based) - int defaultMapq_; /// Default mapping quality to report when one is - /// not specified ReferenceMap *rmap_; /// mapping to reference coordinate system. AnnotationMap *amap_; /// bool fullRef_; /// print full reference name, not just up to whitespace