linnarsson-lab / loompy

Python implementation of the Loom file format - http://loompy.org
BSD 2-Clause "Simplified" License
137 stars 36 forks source link

Issue while combining loom files #136

Closed sidrahmaryam closed 3 years ago

sidrahmaryam commented 3 years ago

Hello @slinnarsson and all,

I am facing an issue while combining the loom files I have. I used the combine function, but i am getting the following error:

Traceback (most recent call last): File "combineloom.py", line 12, in loompy.combine(sorted_file_list, dirName+"/"+"final_loom.loom", key = "Accession") File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/loompy/loompy.py", line 1264, in combine ds.add_loom(f, key, batch_size=batch_size, convert_attrs=convert_attrs) File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/loompy/loompy.py", line 426, in add_loom with loompy.connect(other_file) as other: File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/loompy/loompy.py", line 1389, in connect return LoomConnection(filename, mode, validate=validate) File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/loompy/loompy.py", line 81, in init if not lv.validate(filename): File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/loompy/loom_validator.py", line 48, in validate with h5py.File(path, mode="r") as f: File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/h5py/_hl/files.py", line 394, in init swmr=swmr) File "/home/gaurav.ahuja/anaconda2/envs/velocyto/lib/python3.6/site-packages/h5py/_hl/files.py", line 170, in make_fid fid = h5f.open(name, flags, fapl=fapl) File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py/h5f.pyx", line 85, in h5py.h5f.open OSError: Unable to open file (file signature not found)

Being new at handling loom files, I am stuck at this for a day now. Any help is highly appreciated. Thank you in advance.

slinnarsson commented 3 years ago

Take a look at this answer: https://stackoverflow.com/questions/38089950/error-opening-file-in-h5py-file-signature-not-found

One of the input files is most likely corrupted, or it's not a loom file. If you downloaded the file, maybe the download did not complete?

In order to avoid corrupting files when working with them, it's important to wrap your code in with blocks:

with loompy.connect(file) as ds:
    # do something

That way, if you code crashes, the file is closed properly.

sidrahmaryam commented 3 years ago

@slinnarsson Thank you for your response. Actually I had generated the loom files by velocyto. I will try by the method you suggested.

Thanks a lot