Skip to content

Commit

Permalink
Add option -debug to control -vmer debugging output.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianwalenz committed Apr 19, 2021
1 parent 34e9418 commit 09c026d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 45 deletions.
4 changes: 1 addition & 3 deletions src/merfin/merfin-globals.H
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ public:

uint32 reportType = OP_NONE;




bool debug = false;

public:
double peak = 0;
Expand Down
70 changes: 36 additions & 34 deletions src/merfin/merfin-variants.C
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.

Expand Down
12 changes: 4 additions & 8 deletions src/merfin/merfin.C
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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]);
Expand Down Expand Up @@ -233,6 +228,7 @@ main(int32 argc, char **argv) {
//fprintf(stderr, " if chosen, use bcftools to compress and index, and consensus -H 1 -f <seq.fata> to polish.\n");
//fprintf(stderr, " first ALT in heterozygous alleles are better supported by avg. |k*|.\n");
fprintf(stderr, " -lookup <probabilities> use probabilities to adjust multiplicity to copy number\n");
fprintf(stderr, " -debug output a debug log, into <output>.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");
Expand Down

0 comments on commit 09c026d

Please sign in to comment.