ff67e7b0b5e3338d066afedf2464f8056bb2e0cc jcasper Tue Nov 5 19:29:36 2024 -0800 Replacing a stderr warning about absent hic normalization with a thrown exception that can be caught, refs #34394 diff --git src/hg/lib/straw/straw.cpp src/hg/lib/straw/straw.cpp index 47fa883..a2e2004 100644 --- src/hg/lib/straw/straw.cpp +++ src/hg/lib/straw/straw.cpp @@ -676,32 +676,36 @@ } if (chrIdx == c1 && normtype == norm && unit1 == unit && resolution1 == resolution) { c1NormEntry.position = filePosition; c1NormEntry.size = sizeInBytes; found1 = true; } if (chrIdx == c2 && normtype == norm && unit1 == unit && resolution1 == resolution) { c2NormEntry.position = filePosition; c2NormEntry.size = sizeInBytes; found2 = true; } } delete buffer; if (!found1 || !found2) { +/* cerr << "Remote file did not contain " << norm << " normalization vectors for one or both chromosomes at " << resolution << " " << unit << endl; +*/ + throw strawException("Remote file did not contain " + norm + " normalization vectors for one or both chromosomes at " + + to_string(resolution) + " " + unit); } return true; } bool readFooter(istream &fin, int64_t master, int32_t version, int32_t c1, int32_t c2, const string &matrixType, const string &norm, const string &unit, int32_t resolution, int64_t &myFilePos, indexEntry &c1NormEntry, indexEntry &c2NormEntry, vector &expectedValues) { if (version > 8) { int64_t nBytes = readInt64FromFile(fin); } else { int32_t nBytes = readInt32FromFile(fin); } stringstream ss; @@ -822,32 +826,36 @@ // added UCSC globalNormOptions.insert(normtype); if (chrIdx == c1 && normtype == norm && unit1 == unit && resolution1 == resolution) { c1NormEntry.position = filePosition; c1NormEntry.size = sizeInBytes; found1 = true; } if (chrIdx == c2 && normtype == norm && unit1 == unit && resolution1 == resolution) { c2NormEntry.position = filePosition; c2NormEntry.size = sizeInBytes; found2 = true; } } if (!found1 || !found2) { +/* cerr << "File did not contain " << norm << " normalization vectors for one or both chromosomes at " << resolution << " " << unit << endl; +*/ + throw strawException("File did not contain " + norm + " normalization vectors for one or both chromosomes at " + + to_string(resolution) + " " + unit); } return true; } indexEntry readIndexEntry(istream &fin) { int64_t filePosition = readInt64FromFile(fin); int32_t blockSizeInBytes = readInt32FromFile(fin); indexEntry entry = indexEntry(); entry.size = (int64_t) blockSizeInBytes; entry.position = filePosition; return entry; } void setValuesForMZD(istream &fin, const string &myunit, float &mySumCounts, int32_t &mybinsize, int32_t &myBlockBinCount, int32_t &myBlockColumnCount, bool &found) {