How to make a compressed file directly usable as a regular file?

我的梦境 提交于 2020-01-05 06:44:29

问题


We have a custom compressor for genomic data called CRAM, and althogugh it provides superior compression people are afraid to use it, because it is not-so-easy to handle with bioinformatic tools as "regular" files. We would like to allow compressed file to be used for example as parameters to scripts, be opened in GUIs, etc. just like classic files.

Like a named pipe or block device file that automatically executes the unzip command whenever it is read from. If it is easy to copy from system to system (to email, sftp, etc. it), it would be even better.

Our current solution:

  1. let's say we have two commands, cram and uncram (you can substitute gzip and gunzip here), and an input file fileX.

  2. we compress:

    cram < fileX > fileX.cram

  3. we create self extracting archive for cram:

    echo "uncram < fileX.cram" > fileX.cram.sex
    chmod +x fileX.cram.sex

  4. we use it as a parameter(s) in tools:

    mytool <(fileX.cram.sex)

now it is almost easy-to-use except for the "<()" notation, and the fact that you cannot immediately open it in a GUI.

Any ideas how to make the process transparent?


回答1:


You could try providing a simple wrapper around each command that processes your files:

$ mytool () {
>  command mytool <( "$1" )
> }
$ mytool fileX.cram.sex

The command builtin allows you run the original command, rather than the function that shadows it.

Note that fileX.cram.sex isn't a self-extracting archive; it's just a shell script that has a hard-coded input file.



来源:https://stackoverflow.com/questions/16020461/how-to-make-a-compressed-file-directly-usable-as-a-regular-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!