def add_read(self, read_number, read_id, start_time, duration, mux, median_before): """ Add a new read to the file. :param read_number: The read number to assign to the read. :param read_id: The unique read-id for the read. :param start_time: The start time (in samples) of the read. :param duration: The duration (in samples) of the read. :param mux: The mux set at the time of the read. :param median_before: The median level of the data before the read. Note that most tools assume a file contains only one read. Putting multiple reads into a file severely limits the ability to operate on those reads with standard tools. """ self.assert_writeable() read_info = ReadInfo(read_number, read_id, start_time, duration, mux, median_before) self.status.read_info.append(read_info) n = len(self.status.read_info) - 1 self.status.read_number_map[read_number] = n self.status.read_id_map[read_id] = n group_name = 'Raw/Reads/Read_{}'.format(read_number) attrs = { 'read_number': read_number, 'read_id': read_id, 'start_time': start_time, 'duration': duration, 'start_mux': mux, 'median_before': median_before } self._add_group(group_name, attrs)
def test_write_vbz_using_api_single_read(self): input_data = list(range(5)) read_id = "0a1b2c3d" read_number = 0 with Fast5File(self.generate_temp_filename(), 'w') as fast5: fast5.status.read_number_map[read_number] = read_number fast5.status.read_info = [ ReadInfo(read_number=read_number, read_id=read_id, start_time=0, duration=len(input_data)) ] fast5.add_raw_data(data=input_data, attrs={}, compression=VBZ) raw = fast5.get_raw_data() # First check the data comes back in an appropriate form self.assertEqual(input_data, list(raw)) # Then check the types are as they should be under the hood filters = fast5.raw_compression_filters self.assertTrue(str(VBZ.compression) in filters) self.assertEqual(VBZ.compression_opts, filters[str(VBZ.compression)])