def create_read(self, read_id, run_id): group_name = "read_" + read_id if group_name not in self.handle: try: self.handle.create_group(group_name) except ValueError as e: raise_from(ValueError("Could not create group '{}' in file: {}" .format(group_name, self.filename)), e) self.handle[group_name].attrs["run_id"] = run_id else: raise ValueError("Read '{}' already exists in: {}".format(group_name, self.filename)) return Fast5Read(self, read_id)
def create_empty_read(self, read_id, run_id): group_name = "read_" + read_id if group_name not in self.handle: try: self.handle.create_group(group_name) except ValueError as e: raise ValueError("Could not create group '{}' in file: {}".format(group_name, self.filename)) from e try: for shared_group in HARDLINK_GROUPS: self.handle["{}/{}".format(group_name, shared_group)] = \ self.handle["read_{}/{}".format(self.run_id_map[run_id], shared_group)] except KeyError: # If we can't hardlink to existing groups then continue as normal # registering this read as the new source of metadata for this run_id_map self.run_id_map[run_id] = read_id self.handle[group_name].attrs["run_id"] = run_id else: raise ValueError("Read '{}' already exists in: {}".format(group_name, self.filename)) return Fast5Read(self, read_id)
def get_read(self, read_id): group_name = "read_" + read_id if group_name not in self.handle: raise KeyError("Read '{}' not in: {}".format(group_name, self.filename)) return Fast5Read(self, read_id)
def get_reads(self): for group_name in self.handle: if group_name.startswith('read_'): yield Fast5Read(self, group_name[5:])