【问题标题】:parallel gnu command in conjunction with piping并行 gnu 命令与管道一起使用
【发布时间】:2017-02-27 00:24:39
【问题描述】:

我对信息学比较陌生,并且刚刚发现了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 转换?

【问题讨论】:

    标签: linux parallel-processing gnu


    【解决方案1】:

    你需要引用管道和重定向:

    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 吗?您的命令行会因此而爱上您。

    【讨论】:

    • 这仍然不适合我,抱歉...应该 > 有一个'>'?我会看教程的,干杯
    • 不,但是试试 --dry-run。
    猜你喜欢
    • 2017-01-14
    • 2021-07-15
    • 2017-09-09
    • 1970-01-01
    • 1970-01-01
    • 2014-03-11
    • 2020-12-14
    • 2020-03-08
    • 2017-09-27
    相关资源
    最近更新 更多