问题
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:
let's say we have two commands, cram and uncram (you can substitute gzip and gunzip here), and an input file fileX.
we compress:
cram < fileX > fileX.cram
we create self extracting archive for cram:
echo "uncram < fileX.cram" > fileX.cram.sex
chmod +x fileX.cram.sexwe 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