Is not an HDF5 file error when iterating over multi-resolution HDF5 files

84 Views Asked by At

I want to run cooler balance (from cooler) on each resolution of each file with .mcool extension.

 for mcool_file in input/*.mcool; do
  while IFS= read -r id; do # id=./../input/A001C007.hg38.nodups.pairs.mcool::/resolutions/200   
    cooler balance ${id}
  done < <(cooler ls "$mcool_file")

done

Traceback:

Traceback (most recent call last):
  File "/.local/bin/cooler", line 8, in <module>
    sys.exit(cli())
  File "/.local/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/.local/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/.local/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/.local/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/.local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/.local/lib/python3.9/site-packages/cooler/cli/fileops.py", line 24, in ls
    for group_path in fileops.list_coolers(cool_path):
  File "/.local/lib/python3.9/site-packages/cooler/fileops.py", line 186, in list_coolers
    raise OSError(f"'{filepath}' is not an HDF5 file.")
OSError: 'input/*.mcool' is not an HDF5 file.

The following Python code did not raise an error, suggesting that the .mcool files are in valid hdf5 format.

import h5py
if not h5py.is_hdf5('A001C007.hg38.nodups.pairs.mcool'):
    raise ValueError('Not an hdf5 file')

List of resolution for a .mcool file (e.g., A001C007.hg38.nodups.pairs.mcool) can be identified using:

cooler ls A001C007.hg38.nodups.pairs.mcool

which returns:

A001C007.hg38.nodups.pairs.mcool::/resolutions/200
A001C007.hg38.nodups.pairs.mcool::/resolutions/500
A001C007.hg38.nodups.pairs.mcool::/resolutions/1000
A001C007.hg38.nodups.pairs.mcool::/resolutions/2000
A001C007.hg38.nodups.pairs.mcool::/resolutions/5000
A001C007.hg38.nodups.pairs.mcool::/resolutions/10000
A001C007.hg38.nodups.pairs.mcool::/resolutions/20000
A001C007.hg38.nodups.pairs.mcool::/resolutions/50000
A001C007.hg38.nodups.pairs.mcool::/resolutions/100000
A001C007.hg38.nodups.pairs.mcool::/resolutions/250000
A001C007.hg38.nodups.pairs.mcool::/resolutions/500000
A001C007.hg38.nodups.pairs.mcool::/resolutions/1000000  

For a single resolution of a single file, it can be run as:

cooler balance [OPTIONS] COOL_PATH

0

There are 0 best solutions below