Skip to content

Commit

Permalink
Merge pull request #529 from Bioinformatics/ipa-6039-fix-q-by-lane-pu…
Browse files Browse the repository at this point in the history
…blic

IPA-6036: Explicit exception for writing binned q-metric as unbinned
  • Loading branch information
ezralanglois authored and GitHub Enterprise committed Jan 24, 2017
2 parents bc8610b + b0edf2f commit 8abfede
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/interop/model/metrics/q_metric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ namespace illumina { namespace interop { namespace io
template<class Stream, class Metric, class Header>
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<count_t>(stream, metric.m_qscore_hist, q_metric::MAX_Q_BINS);
resize_accumulated(stream, metric);
return count;
Expand Down
46 changes: 46 additions & 0 deletions src/tests/interop/metrics/q_by_lane_metric_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,49 @@ TEST(run_metrics_q_by_lane_test, test_is_group_empty)
logic::metric::create_q_metrics_by_lane(metrics.get<q_metric>(), metrics.get<q_by_lane_metric>());
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<std::string> 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<q_metric>());
metrics.run_info(run_info);
metrics.legacy_channel_update(constants::HiSeq);
metrics.finalize_after_load();

ASSERT_GT(metrics.get<q_by_lane_metric>().size(), 0u);

const size_t buffer_size = io::compute_buffer_size(metrics.get<q_by_lane_metric>());
ASSERT_GT(buffer_size, 0u);
std::vector< ::uint8_t > buffer(buffer_size);
metrics.get<q_by_lane_metric>().set_version(4);
EXPECT_THROW(io::write_interop_to_buffer(metrics.get<q_by_lane_metric>(), &buffer.front(), buffer.size()),
io::bad_format_exception);

}

0 comments on commit 8abfede

Please sign in to comment.