Skip to content

Commit

Permalink
Add (an overly) verbose mode for (maybe) helping to debug why bucketi…
Browse files Browse the repository at this point in the history
…zer is failing. Issue marbl#959.
  • Loading branch information
brianwalenz committed Jun 19, 2018
1 parent d6cf139 commit 3a2e695
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/stores/ovStore.H
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ private:

class ovStoreFilter {
public:
ovStoreFilter(sqStore *seq_, double maxErate);
ovStoreFilter(sqStore *seq_, double maxErate, bool beVerbose = false);
~ovStoreFilter();

void filterOverlap(ovOverlap &foverlap,
Expand Down Expand Up @@ -350,6 +350,8 @@ public:
uint32 maxID;
uint32 maxEvalue;

bool beVerbose;

uint64 saveUTG;
uint64 saveOBT;
uint64 saveDUP;
Expand Down
28 changes: 22 additions & 6 deletions src/stores/ovStoreBucketizer.C
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ writeToFile(sqStore *seq,
sliceSize[df] = 0;
}

if ((df < 1) ||
(df > config->numSlices() + 1)) {
char ovlstr[256];

fprintf(stderr, "Invalid slice file %u in overlap %s\n",
df, overlap->toString(ovlstr, ovOverlapAsUnaligned, false));
}

sliceFile[df]->writeOverlap(overlap);
sliceSize[df]++;
}
Expand All @@ -82,6 +90,7 @@ main(int argc, char **argv) {
double maxErrorRate = 1.0;

bool forceOverwrite = false;
bool beVerbose = false;

char createName[FILENAME_MAX+1];
char sliceSName[FILENAME_MAX+1];
Expand Down Expand Up @@ -110,6 +119,9 @@ main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-f") == 0) {
forceOverwrite = true;

} else if (strcmp(argv[arg], "-v") == 0) {
beVerbose = true;

} else {
char *s = new char [1024];
snprintf(s, 1024, "%s: unknown option '%s'.\n", argv[0], argv[arg]);
Expand Down Expand Up @@ -141,6 +153,7 @@ main(int argc, char **argv) {
fprintf(stderr, " -e e filter overlaps above e fraction error\n");
fprintf(stderr, "\n");
fprintf(stderr, " -f force overwriting existing data\n");
fprintf(stderr, " -v be overly verbose\n");
fprintf(stderr, "\n");

for (uint32 ii=0; ii<err.size(); ii++)
Expand Down Expand Up @@ -180,9 +193,16 @@ main(int argc, char **argv) {
exit(1);
}

// Report options.
// Open inputs.

sqStore *seq = sqStore::sqStore_open(seqName);

fprintf(stderr, "\n");
fprintf(stderr, "Opened '%s' with %u reads.\n", seqName, seq->sqStore_getNumReads());
fprintf(stderr, "\n");

// Report options.

fprintf(stderr, "Constructing slice " F_U32 " for store '%s'.\n", bucketNum, ovlName);
fprintf(stderr, " - Filtering overlaps over %.4f fraction error.\n", maxErrorRate);
fprintf(stderr, "\n");
Expand All @@ -192,10 +212,6 @@ main(int argc, char **argv) {
AS_UTL_mkdir(ovlName);
AS_UTL_mkdir(createName);

// Open inputs.

sqStore *seq = sqStore::sqStore_open(seqName);

// Allocate stuff.

ovFile **sliceFile = new ovFile * [config->numSlices() + 1];
Expand All @@ -204,7 +220,7 @@ main(int argc, char **argv) {
memset(sliceFile, 0, sizeof(ovFile *) * (config->numSlices() + 1));
memset(sliceSize, 0, sizeof(uint64) * (config->numSlices() + 1));

ovStoreFilter *filter = new ovStoreFilter(seq, maxErrorRate);
ovStoreFilter *filter = new ovStoreFilter(seq, maxErrorRate, beVerbose);
ovOverlap foverlap(seq);
ovOverlap roverlap(seq);

Expand Down
9 changes: 8 additions & 1 deletion src/stores/ovStoreBuild.C
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ main(int argc, char **argv) {
bool eValues = false;
char *configOut = NULL;

bool beVerbose = false;

argc = AS_configure(argc, argv);

vector<char *> err;
Expand All @@ -109,6 +111,9 @@ main(int argc, char **argv) {
} else if (strcmp(argv[arg], "-e") == 0) {
maxErrorRate = atof(argv[++arg]);

} else if (strcmp(argv[arg], "-v") == 0) {
beVerbose = true;

} else {
char *s = new char [1024];
snprintf(s, 1024, "%s: unknown option '%s'.\n", argv[0], argv[arg]);
Expand All @@ -132,6 +137,8 @@ main(int argc, char **argv) {
fprintf(stderr, "\n");
fprintf(stderr, " -e e filter overlaps above e fraction error\n");
fprintf(stderr, "\n");
fprintf(stderr, " -v be overly verbose\n");
fprintf(stderr, "\n");

for (uint32 ii=0; ii<err.size(); ii++)
if (err[ii])
Expand All @@ -144,7 +151,7 @@ main(int argc, char **argv) {

ovStoreConfig *config = new ovStoreConfig(cfgName);
sqStore *seq = sqStore::sqStore_open(seqName);
ovStoreFilter *filter = new ovStoreFilter(seq, maxErrorRate);
ovStoreFilter *filter = new ovStoreFilter(seq, maxErrorRate, beVerbose);

// Figure out how many overlaps there are, quit if too many.

Expand Down
26 changes: 18 additions & 8 deletions src/stores/ovStoreFilter.C
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,22 @@



ovStoreFilter::ovStoreFilter(sqStore *seq_, double maxErate) {
ovStoreFilter::ovStoreFilter(sqStore *seq_, double maxErate_, bool beVerbose_) {
seq = seq_;
maxID = seq->sqStore_getNumReads() + 1;
maxEvalue = AS_OVS_encodeEvalue(maxErate);
maxID = seq->sqStore_getNumReads();
maxEvalue = AS_OVS_encodeEvalue(maxErate_);

beVerbose = beVerbose_;

resetCounters();

skipReadOBT = new char [maxID];
skipReadDUP = new char [maxID];
skipReadOBT = new char [maxID + 1];
skipReadDUP = new char [maxID + 1];

uint32 numSkipOBT = 0;
uint32 numSkipDUP = 0;

for (uint64 iid=0; iid<maxID; iid++) {
for (uint64 iid=0; iid<=maxID; iid++) {
uint32 Lid = seq->sqStore_getRead(iid)->sqRead_libraryID();
sqLibrary *L = seq->sqStore_getLibrary(Lid);

Expand Down Expand Up @@ -154,12 +156,20 @@ void
ovStoreFilter::filterOverlap(ovOverlap &foverlap,
ovOverlap &roverlap) {

// GREATLY annoy the poor user that asked for 'overly verbose' mode.

if (beVerbose) {
char ovlstr[256];

fprintf(stderr, "%s\n", foverlap.toString(ovlstr, ovOverlapAsUnaligned, false));
}

// Quick sanity check on IIDs.

if ((foverlap.a_iid == 0) ||
(foverlap.b_iid == 0) ||
(foverlap.a_iid >= maxID) ||
(foverlap.b_iid >= maxID)) {
(foverlap.a_iid > maxID) ||
(foverlap.b_iid > maxID)) {
char ovlstr[256];

fprintf(stderr, "Overlap has IDs out of range (maxID " F_U32 "), possibly corrupt input data.\n", maxID);
Expand Down

0 comments on commit 3a2e695

Please sign in to comment.