usegalaxy-eu / galaxy

Data intensive science for everyone.
https://galaxyproject.org/
Other
2 stars 11 forks source link

Extension fix #228

Closed Marie59 closed 6 months ago

Marie59 commented 6 months ago

Hello hello, I added multiple fixes to get the extension of the outputs in interactive tools. Plus I modified the outputs of ODV and Divand to make an easier workflow. During this I noticed that Galaxy does not associate the extension .nc with the datatype netcdf. I'd like to change that. Do you think it's possible ?

How to test the changes?

(Select all options that apply)

License

Marie59 commented 6 months ago

@bgruening could we also make an update to detect the file with a .nc extension as a netcdf in the binary.py in the datatypes: ` @build_sniff_from_prefix class NetCDF(Binary): """Binary data in netCDF format"""

file_ext = "netcdf"
edam_format = "format_3650"
edam_data = "data_0943"

def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
    if not dataset.dataset.purged:
        dataset.peek = "Binary netCDF file"
        dataset.blurb = nice_size(dataset.get_size())
    else:
        dataset.peek = "file does not exist"
        dataset.blurb = "file purged from disk"

def display_peek(self, dataset: DatasetProtocol) -> str:
    try:
        return dataset.peek
    except Exception:
        return f"Binary netCDF file ({nice_size(dataset.get_size())})"

def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
    return file_prefix.startswith_bytes(b"CDF")

`

bgruening commented 6 months ago

I don't know, but can you try to change file_ext = "netcdf" to file_ext = "nc" locally and see if this works?

Marie59 commented 6 months ago

So, after some investigations I think the issue is not really coming from galaxy. From what I understand the netcdf sniffer was build to detect CDF in the first byte of the file. And some (almost all) of the netcdf I use (or produce from interactive tools) are not identified as netcdf so I guess the netcdf is not formatted as galaxy expect. So, I think something need to be add in the sniffer. I'll keep investigating what needs to be changed. In the meantime I think this PR is ready ;)