我是信息学的新手,刚刚发现了 parallel
命令的优点。但是,我在将它与管道和输出结合使用时遇到了麻烦。
我正在使用这个命令:
parallel -j 2 echo ./hisat2 --dta -p 32 -x path/to/index -U {} | ./samtools view -b - > /path/to/storage/folder/{/.}.bam :::: fs1 > executable.sh
fs1
包含我要运行的所有文件的列表。 executable.sh
是可执行命令列表。我希望 fs1 中列出的每个文件都由一个程序(称为 hisat2
)单独处理,并使用 samtools 将输出的 sam 文件转换为 bam 格式。但是,它似乎不喜欢管道 - 它提示以下内容:
bash: /path/to/storage/folder/{/.}.bam: No such file or directory
parallel: Warning: Input is read from the terminal. Only experts do this on purpose. Press CTRL-D to exit.
我该如何克服这个问题?解决这个问题的唯一方法是首先将所有文件处理为 sam,然后并行 bam 转换吗?
最佳答案
您需要引用管道和重定向:
parallel -j 2 "./hisat2 --dta -p 32 -x path/to/index -U {} | ./samtools view -b - > /path/to/storage/folder/{/.}.bam" :::: fs1
使用 --dry-run
查看将运行什么:
parallel --dry-run -j 2 "./hisat2 --dta -p 32 -x path/to/index -U {} | ./samtools view -b - > /path/to/storage/folder/{/.}.bam" :::: fs1
(您确定 samtools
在当前目录中吗?通常是为更广泛的受众安装的。)
我可以建议您花一个小时浏览 man parallel_tutorial
吗?您的命令行会因此爱上您。
关于linux - 并行 gnu 命令与管道结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42475983/