006f538b5a95fd704a106546add7b6cd9bd77fa3 jcasper Sun Jul 19 22:26:32 2026 -0700 Muting warnings when retrieving hic data for a region not in the hic file, refs #36444 diff --git src/hg/lib/straw/cStraw.cpp src/hg/lib/straw/cStraw.cpp index 484108a5009..1f901a32e22 100644 --- src/hg/lib/straw/cStraw.cpp +++ src/hg/lib/straw/cStraw.cpp @@ -132,30 +132,33 @@ * chr1loc and chr2loc are the two positions to retrieve interaction data for, specified as chr:start-end. * unit is one of BP/FRAG. * Values are returned in newly allocated arrays in xActual, yActual, and counts, with the number of * returned records in numRecords. * The function returns NULL unless an error was encountered, in which case the return value points * to a character string explaining the error. */ { string thisnorm(norm); string thischr1loc(chr1loc); string thischr2loc(chr2loc); string thisunit(unit); vector strawRecords; try { strawRecords = straw("observed", thisnorm, *(hicFile->fileName), thischr1loc, thischr2loc, unit, binsize); + } catch (strawChromNotFoundException& err) { + // Chromosome not in file: intentionally return an empty result set rather than an + // error. strawRecords stays empty and we fall through to return 0 records below. } catch (strawException& err) { char *errMsg = (char*) calloc((size_t) strlen(err.what())+1, sizeof(char)); strcpy(errMsg, err.what()); return errMsg; } *numRecords = strawRecords.size(); *xActual = (int*) calloc((size_t) *numRecords, sizeof(int)); *yActual = (int*) calloc((size_t) *numRecords, sizeof(int)); *counts = (double*) calloc((size_t) *numRecords, sizeof(double)); for (int i=0; i<*numRecords; i++) { (*xActual)[i] = strawRecords[i].binX; (*yActual)[i] = strawRecords[i].binY; (*counts)[i] = (double) strawRecords[i].counts; }