GNU parallel将多个文件的输出合并为一个。为什么?

问题描述 投票:2回答:1

我正在运行GNU并行。与我在其他分析中的输出不同,这个输出很奇怪。

我的代码:

# set the path of the required program
samtools=/usr/local/apps/samtools/0.1.19-gcc412/samtools
TempDir=/gpfs_common/share03/uncg/bkgiri/apps/temp_files/


# run the process for 4 samples in 4 different cores
parallel --tmpdir ${TempDir} --jobs 4 ${samtools} view -b -q 40 realigned_{}.bam -L DNA_Samples.Passed_Variants.Final.bed > realigned_{}Filtered.bam ::: ms01e ms02g ms03g ms04h
  • 我期待每个输入有4个不同的输出文件,每个输入文件名为realigned_ms01eFiltered.bam,realigned_ms02gFiltered.bam等。
  • 但是,我得到一个名为realigned_{}Filtered.bam的大文件。我之前从未遇到过这个问题。

我也尝试过:

parallel --tmpdir ${TempDir} --jobs 4 '${samtools} view -b -q 40 realigned_{}.bam -L DNA_Samples.Passed_Variants.Final.bed > realigned_{}Filtered.bam' ::: ms01e ms02g ms03g ms04h

# which now gives me another type of error

有什么建议 ?

bash ubuntu gnu gnu-parallel
1个回答
2
投票

正如@choroba所提到的那样:>即使在并行可以看到它之前,它也会被shell解释为重定向。

所以,我找到了最终解决这个问题的两种方法。

  1. 方法A:我们可以解释" "中的整个命令,我认为它在功能上更有效率。 parallel --tmpdir ${TempDir} --jobs 4 "${samtools} view -b -q 40 realigned_{}.bam -L DNA_Samples.Passed_Variants.Final.bed > realigned_{}Filtered.bam" ::: ms01e ms02g ms03g ms04h
  2. 方法B:或者,我们可以解释" "中的输出。这允许>被解释为文本,当pipedin作为stdin工作作为输出而不是重定向时。 parallel --tmpdir ${TempDir} --jobs 4 ${samtools} view -b -q 40 realigned_{}.bam -L DNA_Samples.Passed_Variants.Final.bed ">" realigned_{}Filtered.bam ::: ms01e ms02g ms03g ms04h

我测试了两种方法,两种方法都给出了完全相同的结果。所以,任何一个都可以安全地打电话。

谢谢,

© www.soinside.com 2019 - 2024. All rights reserved.