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)
def test_missing_xml_element_exception(self): """ """ run_info = py_interop_run.info() try: run_info.parse("<RunInfo><Run><FlowcellLayout> <TileSet> </TileSet></FlowcellLayout></Run></RunInfo>") self.fail("missing_xml_element_exception should have been thrown") except py_interop_run.missing_xml_element_exception as ex: self.assertEqual(str(ex).split('\n')[0], "Cannot find attribute: TileNamingConvention")
def test_xml_parse_exception(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() try: run_info.parse("<RunInfo></RunInfo") self.fail("xml_parse_exception should have been thrown") except py_interop_run.xml_parse_exception as ex: self.assertEqual(str(ex).split('\n')[0], "expected >")
def test_empty_xml_format_exception(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() try: run_info.parse("") self.fail("empty_xml_format_exception should have been thrown") except py_interop_run.empty_xml_format_exception as ex: self.assertEqual(str(ex).split('\n')[0], "Root node not found")
def test_xml_file_not_found_exception(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() try: run_info.read("file/not/found") self.fail("xml_file_not_found_exception should have been thrown") except py_interop_run.xml_file_not_found_exception as ex: self.assertEqual(str(ex).split('\n')[0], "cannot open file " + os.path.join("file/not/found", "RunInfo.xml"))
def test_invalid_run_info_cycle_exception(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info(py_interop_run.flowcell_layout(8, 2, 4, 99)) try: run_info.validate_cycle(1, 1101, 3000) self.fail("invalid_run_info_cycle_exception should have been thrown") except py_interop_run.invalid_run_info_cycle_exception as ex: self.assertEqual(str(ex).split('\n')[0], "Cycle number exceeds number of cycles: 3000 > 0")
def test_invalid_run_info_exception(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() try: run_info.validate(20, 9999) self.fail("invalid_run_info_exception should have been thrown") except py_interop_run.invalid_run_info_exception as ex: self.assertEqual(str(ex).split('\n')[0], "Lane identifier exceeds number of lanes")
def test_invalid_tile_naming_method(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() try: run_info.validate() self.fail("invalid_tile_naming_method should have been thrown") except py_interop_run.invalid_tile_naming_method as ex: self.assertEqual(str(ex).split('\n')[0], "Unknown tile naming method")
def test_invalid_read_exception(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() try: run_info.read(8) self.fail("invalid_read_exception should have been thrown") except py_interop_run.invalid_read_exception as ex: self.assertEqual(str(ex).split('\n')[0], "Read number not found: 8")
def missing_xml_element_exception(self): """ TODO: Exception never thrown, remove? """ run_info = py_interop_run.info() try: run_info.parse("<RunInfo><Run Id=\"2\" Number=\"2\"><FlowcellLayout LaneCount=\"2\" /></Run></RunInfo>") self.fail("missing_xml_element_exception should have been thrown") except py_interop_run.missing_xml_element_exception as ex: self.assertEqual(str(ex).split('\n')[0], "Run node not found")
def test_invalid_filter_option(self): """ Test that exceptions can be caught and they have the expected message """ run_info = py_interop_run.info() options = py_interop_plot.filter_options(py_interop_run.FourDigit) try: options.validate(py_interop_run.Intensity, run_info) self.fail("invalid_filter_option should have been thrown") except py_interop_plot.invalid_filter_option as ex: self.assertEqual(str(ex).split('\n')[0], "Invalid tile naming method: does not match RunInfo.xml")
## Import runfolder import argparse parser = argparse.ArgumentParser(description='Process Illumina raw data.') parser.add_argument('runfolder', action='store', help='full path to run directory') args = parser.parse_args() runfolder = args.runfolder print(">> Analyzing Runfolder:") print(runfolder) # Import libs from interop import py_interop_run_metrics, py_interop_run, py_interop_summary ## Run Info: run_info = py_interop_run.info() run_info.read(runfolder) print(">> Run Info: ") print("- Number of cycles %d" % run_info.total_cycles()) print("- Is paired end: %s" % run_info.is_paired_end()) run_metrics = py_interop_run_metrics.run_metrics() valid_to_load = py_interop_run.uchar_vector(py_interop_run.MetricCount, 0) py_interop_run_metrics.list_summary_metrics_to_load(valid_to_load) run_folder = run_metrics.read(runfolder, valid_to_load) summary = py_interop_summary.run_summary() py_interop_summary.summarize_run_metrics(run_metrics, summary)