From b0edf2fb4aed4f9735dd8db51bb711b93af3c444 Mon Sep 17 00:00:00 2001 From: Robert Langlois Date: Tue, 24 Jan 2017 07:13:28 -0800 Subject: [PATCH] IPA-6036: Explicit exception for writing binned q-metric as unbinned --- CMakeLists.txt | 2 +- src/interop/model/metrics/q_metric.cpp | 2 + .../interop/metrics/q_by_lane_metric_test.cpp | 46 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0fec0437..28cbfc8da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project(InterOp) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) enable_testing() include(${PROJECT_SOURCE_DIR}/cmake/Modules/UseGitVersion.cmake) -set(ARCHIVE_VERSION "v1.0.13-src") +set(ARCHIVE_VERSION "v1.0.16-src") if (NOT CMAKE_BUILD_TYPE) diff --git a/src/interop/model/metrics/q_metric.cpp b/src/interop/model/metrics/q_metric.cpp index 17eda969b..236e05060 100644 --- a/src/interop/model/metrics/q_metric.cpp +++ b/src/interop/model/metrics/q_metric.cpp @@ -82,6 +82,8 @@ namespace illumina { namespace interop { namespace io template static std::streamsize map_stream(Stream &stream, Metric &metric, Header &, const bool) { + if(metric.size() < q_metric::MAX_Q_BINS) + INTEROP_THROW(bad_format_exception, "Cannot write out binned q-score histogram in an unbinned format"); const std::streamsize count = stream_map(stream, metric.m_qscore_hist, q_metric::MAX_Q_BINS); resize_accumulated(stream, metric); return count; diff --git a/src/tests/interop/metrics/q_by_lane_metric_test.cpp b/src/tests/interop/metrics/q_by_lane_metric_test.cpp index e19dc3c08..45e514786 100644 --- a/src/tests/interop/metrics/q_by_lane_metric_test.cpp +++ b/src/tests/interop/metrics/q_by_lane_metric_test.cpp @@ -80,3 +80,49 @@ TEST(run_metrics_q_by_lane_test, test_is_group_empty) logic::metric::create_q_metrics_by_lane(metrics.get(), metrics.get()); EXPECT_FALSE(metrics.is_group_empty(constants::QByLane)); } + +// Test that unsupported feature throws an exception +TEST(run_metrics_q_by_lane_test, try_write_binned_as_unbinned) +{ + typedef model::run::flowcell_layout::uint_t uint_t; + run_metrics metrics; + + + const uint_t swath_count = 4; + const uint_t tile_count = 99; + const uint_t sections_per_lane = 1; + const uint_t lanes_per_section = 1; + const uint_t lane_count = 8;//expected.max_lane(); + const uint_t surface_count = 2; + const model::run::read_info read_array[]={ + model::run::read_info(1, 1, 4, false) + }; + std::vector channels; + model::run::info run_info("XX", + "", + 1, + model::run::flowcell_layout(lane_count, + surface_count, + swath_count, + tile_count, + sections_per_lane, + lanes_per_section), + channels, + model::run::image_dimensions(), + util::to_vector(read_array)); + + q_metric_v6::create_expected(metrics.get()); + metrics.run_info(run_info); + metrics.legacy_channel_update(constants::HiSeq); + metrics.finalize_after_load(); + + ASSERT_GT(metrics.get().size(), 0u); + + const size_t buffer_size = io::compute_buffer_size(metrics.get()); + ASSERT_GT(buffer_size, 0u); + std::vector< ::uint8_t > buffer(buffer_size); + metrics.get().set_version(4); + EXPECT_THROW(io::write_interop_to_buffer(metrics.get(), &buffer.front(), buffer.size()), + io::bad_format_exception); + +}