diff --git a/src/merfin/merfin-globals.H b/src/merfin/merfin-globals.H index 7dca9e1..35c7cea 100644 --- a/src/merfin/merfin-globals.H +++ b/src/merfin/merfin-globals.H @@ -229,9 +229,7 @@ public: uint32 reportType = OP_NONE; - - - + bool debug = false; public: double peak = 0; diff --git a/src/merfin/merfin-variants.C b/src/merfin/merfin-variants.C index f193712..9400656 100644 --- a/src/merfin/merfin-variants.C +++ b/src/merfin/merfin-variants.C @@ -142,7 +142,7 @@ processVariants(void *G, void *T, void *S) { // Initialize the per-thread data if needed. - if (t->oDebug == nullptr) { + if ((g->debug == true) && (t->oDebug == nullptr)) { char name[FILENAME_MAX+1]; snprintf(name, FILENAME_MAX, "%s.%02d.debug.gz", g->outName, t->threadID); @@ -237,42 +237,44 @@ processVariants(void *G, void *T, void *S) { // Save debug info. - for (uint64 idx = 0; idx < seqMer->seqs.size(); idx++) { - fprintf(t->oDebug->file(), "%lu\t%s:%u-%u\t%s\t%u\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t", - t->varMerId++, - s->seq.ident(), - rStart, - rEnd, - seqMer->seqs[idx].c_str(), // seq - seqMer->numMs[idx], // missing - seqMer->getMinAbsK(idx), - seqMer->getMaxAbsK(idx), - seqMer->getMedAbsK(idx), - seqMer->getAvgAbsK(idx), - //seqMer->getAvgAbsdK(idx, RefAvgK), - seqMer->getTotdK(idx)); - - // new vcf records - // fprintf(stderr, "%s:%u-%u seqMer->gtPaths[idx].size() %d\n", s->seq.ident(), rStart, rEnd, seqMer->gtPaths[idx].size()); - - if ( seqMer->gtPaths[idx].size() > 0 ) { - for (uint64 i = 0; i < seqMer->gtPaths[idx].size(); i++) { - // Ignore the ref-allele (0/0) GTs - // print only the non-ref allele variants for fixing - int altIdx = seqMer->gtPaths[idx][i]; - if (altIdx > 0) { - fprintf(t->oDebug->file(), "%s %u . %s %s . PASS . GT 1/1 ", - s->seq.ident(), - gts[i]->_pos+1, - gts[i]->_alleles[0], - gts[i]->_alleles[altIdx] - ); + if (t->oDebug) { + for (uint64 idx = 0; idx < seqMer->seqs.size(); idx++) { + fprintf(t->oDebug->file(), "%lu\t%s:%u-%u\t%s\t%u\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t", + t->varMerId++, + s->seq.ident(), + rStart, + rEnd, + seqMer->seqs[idx].c_str(), // seq + seqMer->numMs[idx], // missing + seqMer->getMinAbsK(idx), + seqMer->getMaxAbsK(idx), + seqMer->getMedAbsK(idx), + seqMer->getAvgAbsK(idx), + //seqMer->getAvgAbsdK(idx, RefAvgK), + seqMer->getTotdK(idx)); + + // new vcf records + // fprintf(stderr, "%s:%u-%u seqMer->gtPaths[idx].size() %d\n", s->seq.ident(), rStart, rEnd, seqMer->gtPaths[idx].size()); + + if ( seqMer->gtPaths[idx].size() > 0 ) { + for (uint64 i = 0; i < seqMer->gtPaths[idx].size(); i++) { + // Ignore the ref-allele (0/0) GTs + // print only the non-ref allele variants for fixing + int altIdx = seqMer->gtPaths[idx][i]; + if (altIdx > 0) { + fprintf(t->oDebug->file(), "%s %u . %s %s . PASS . GT 1/1 ", + s->seq.ident(), + gts[i]->_pos+1, + gts[i]->_alleles[0], + gts[i]->_alleles[altIdx] + ); + } } } - } - fprintf(t->oDebug->file(), "\n"); - } + fprintf(t->oDebug->file(), "\n"); + } + } // End of debug dump. // Generate output VCFs. diff --git a/src/merfin/merfin.C b/src/merfin/merfin.C index b82c503..eae0369 100644 --- a/src/merfin/merfin.C +++ b/src/merfin/merfin.C @@ -108,14 +108,6 @@ main(int32 argc, char **argv) { } else if (strcmp(argv[arg], "-memory") == 0) { G->maxMemory = strtodouble(argv[++arg]); -#if 0 - } else if (strcmp(argv[arg], "-memory1") == 0) { - G->maxMemory += strtodouble(argv[++arg]); - - } else if (strcmp(argv[arg], "-memory2") == 0) { - G->maxMemory += strtodouble(argv[++arg]); -#endif - } else if (strcmp(argv[arg], "-nosplit") == 0) { G->nosplit = true; @@ -140,6 +132,9 @@ main(int32 argc, char **argv) { } else if (strcmp(argv[arg], "-comb") == 0) { G->comb = strtouint32(argv[++arg]); + } else if (strcmp(argv[arg], "-debug") == 0) { + G->debug = true; + } else { char *s = new char [1024]; snprintf(s, 1024, "Unknown option '%s'.\n", argv[arg]); @@ -233,6 +228,7 @@ main(int32 argc, char **argv) { //fprintf(stderr, " if chosen, use bcftools to compress and index, and consensus -H 1 -f to polish.\n"); //fprintf(stderr, " first ALT in heterozygous alleles are better supported by avg. |k*|.\n"); fprintf(stderr, " -lookup use probabilities to adjust multiplicity to copy number\n"); + fprintf(stderr, " -debug output a debug log, into .THREAD_ID.debug.gz\n"); fprintf(stderr, "\n"); fprintf(stderr, " -completeness\n"); fprintf(stderr, " Compute kmer completeness using expected copy numbers for all kmers.\n");