def test_invalid_argument(self): """ Test that exceptions can be caught and they have the expected message """ tmp = numpy.asarray([ 2, 38, 7, 0, 90, 4, 1, 0, -12, -56, 15, 64, -98, 35, 12, 64, 0, 0, 0, 0, 0, 0, 0, 0, 46, 1, 17, 1, 0, 0, 0, 0, 96, -41, -104, 36, 122, -86, -46, -120, 7, 0, -66, 4, 1, 0, 96, -43, 14, 64, -63, 49, 13, 64, 0, 0, 0, 0, 0, 0, 0, 0, 56, 1, 17, 1, 0, 0, 0, 0, 112, 125, 77, 38, 122, -86, -46, -120, 7, 0, 66, 8, 1, 0, 74, -68, 6, 64, -118, -7, 8, 64, 0, 0, 0, 0, 0, 0, 0, 0, 93, 1, 46, 1, 0, 0, 0, 0, -47, -104, 2, 40, 122, -86, -46, -120 ], dtype=numpy.uint8) run = py_interop_run_metrics.run_metrics() py_interop_comm.read_interop_from_buffer(tmp, run.extraction_metric_set()) try: buf = numpy.zeros(3, dtype=numpy.uint8) py_interop_comm.write_interop_to_buffer( run.extraction_metric_set(), buf) self.fail("invalid_argument should have been thrown") except py_interop_comm.invalid_argument as ex: self.assertEqual(str(ex).split('\n')[0], "Buffer size too small")
def test_bad_format_exception(self): """ Test that exceptions can be caught and they have the expected message """ tmp = numpy.asarray([ 0, 3, 7, 0, 90, 4, 1, 0, -12, -56, 15, 64, -98, 35, 12, 64, 0, 0, 0, 0, 0, 0, 0, 0, 46, 1, 17, 1, 0, 0, 0, 0, 96, -41, -104, 36, 122, -86, -46, -120, 7, 0, -66, 4, 1, 0, 96, -43, 14, 64, -63, 49, 13, 64, 0, 0, 0, 0, 0, 0, 0, 0, 56, 1, 17, 1, 0, 0, 0, 0, 112, 125, 77, 38, 122, -86, -46, -120, 7, 0, 66, 8, 1, 0, 74, -68, 6, 64, -118, -7, 8, 64, 0, 0, 0, 0, 0, 0, 0, 0, 93, 1, 46, 1, 0, 0, 0, 0, -47, -104, 2, 40, 122, -86, -46, -120 ], dtype=numpy.uint8) run = py_interop_run_metrics.run_metrics() try: py_interop_comm.read_interop_from_buffer( tmp, run.extraction_metric_set()) self.fail("bad_format_exception should have been thrown") except py_interop_comm.bad_format_exception as ex: self.assertEqual( str(ex).split('\n')[0], "No format found to parse ExtractionMetricsOut.bin with version: 0 of 2" )
def test_incomplete_file_exception(self): """ Test that exceptions can be caught and they have the expected message """ tmp = numpy.asarray([ 3, 38, 7, 0, 90, 4, 1, 0, -12, -56, 15, 64, -98, 35, 12, 64, 0, 0, 0, 0, 0, 0, 0, 0, 46, 1, 17, 1, 0, 0, 0, 0, 96, -41, -104, 36, 122, -86, -46, -120, 7, 0, -66, 4, 1, 0, 96, -43, 14, 64, -63, 49, 13, 64, 0, 0, 0, 0, 0, 0, 0, 0, 56, 1, 17, 1, 0, 0, 0, 0, 112, 125, 77, 38, 122, -86, -46, -120, 7, 0, 66, 8, 1, 0, 74, -68, 6, 64, -118, -7, 8, 64, 0, 0, 0, 0, 0, 0, 0, 0, 93, 1, 46, 1, 0, 0, 0, 0, -47, -104, 2, 40, 122, -86, -46, -120 ], dtype=numpy.uint8) run = py_interop_run_metrics.run_metrics() try: py_interop_comm.read_interop_from_buffer( tmp, run.extraction_metric_set()) self.fail("incomplete_file_exception should have been thrown") except py_interop_comm.incomplete_file_exception as ex: self.assertEqual( str(ex).split('\n')[0], "Insufficient data read from the file, got: 13 != expected: 50 for Extraction v3" )
def test_populate_imaging_table(self): """ Test if imaging logic can be properly used """ tmp = numpy.asarray([2,38 ,7,0,90,4,1,0,-12,-56,15,64,-98,35,12,64,0,0,0,0,0,0,0,0,46,1,17,1,0,0,0,0,96,-41,-104,36,122,-86,-46,-120 ,7,0,-66,4,1,0,96,-43,14,64,-63,49,13,64,0,0,0,0,0,0,0,0,56,1,17,1,0,0,0,0,112,125,77,38,122,-86,-46,-120 ,7,0,66,8,1,0,74,-68,6,64,-118,-7,8,64,0,0,0,0,0,0,0,0,93,1,46,1,0,0,0,0,-47,-104,2,40,122,-86,-46,-120], dtype=numpy.uint8) run = py_interop_run_metrics.run_metrics() py_interop_comm.read_interop_from_buffer(tmp, run.extraction_metric_set()) self.assertEqual(run.extraction_metric_set().size(), 3) reads = py_interop_run.read_info_vector() reads.append(py_interop_run.read_info(1, 1, 26)) reads.append(py_interop_run.read_info(2, 27, 76)) run.run_info(py_interop_run.info( py_interop_run.flowcell_layout(2, 2, 2, 16), reads )) run.legacy_channel_update(py_interop_run.HiSeq) columns = py_interop_table.imaging_column_vector() py_interop_table.create_imaging_table_columns(run, columns) row_offsets = py_interop_table.map_id_offset() py_interop_table.count_table_rows(run, row_offsets) column_count = py_interop_table.count_table_columns(columns) data = numpy.zeros((len(row_offsets), column_count), dtype=numpy.float32) py_interop_table.populate_imaging_table_data(run, columns, row_offsets, data.ravel()) self.assertEqual(data[0, 0], 7)