コマンドの引用符と平行

コマンドの引用符と平行

Linux端末の元の入力は次のとおりです。


bcftools filter -e 'TYPE="snp"' input1.vcf -O v -o output1.filter.vcf
bcftools filter -e 'TYPE="snp"' input2.vcf -O v -o output2.filter.vcf    
bcftools filter -e 'TYPE="snp"' input3.vcf -O v -o output3.filter.vcf    
bcftools filter -e 'TYPE="snp"' input4.vcf -O v -o output4.filter.vcf    
bcftools filter -e 'TYPE="snp"' input5.vcf -O v -o output5.filter.vcf

すでに以下を含む parallel.input というファイルがあります。


[***@dev1 raw_reads]$ cat parallel.input

input1.vcf
output1.filter.vcf
input2.vcf
output2.filter.vcf
input3.vcf
output3.filter.vcf
input4.vcf
output4.filter.vcf
input5.vcf
output5.filter.vcf

このコマンドを並列に使用する場合

cat parallel.input | parallel -j 3 -k --max-args=2 --joblog parallel.log "bcftools filter -e 'TYPE="snp"' {1} -O v -o {2}"

このエラーが発生しました

[filter.c:2278 filters_init1] Error: the tag "snp" is not defined in the VCF header
[filter.c:2278 filters_init1] Error: the tag "snp" is not defined in the VCF header
[filter.c:2278 filters_init1] Error: the tag "snp" is not defined in the VCF header
[filter.c:2278 filters_init1] Error: the tag "snp" is not defined in the VCF header
[filter.c:2278 filters_init1] Error: the tag "snp" is not defined in the VCF header

bcftoolsコマンドで参照されたためだと思います。しかし、入力として参照が必要です。

並列化を実行する方法をご存知ですか?

ありがとう

ベストアンサー1

関数を使用してください:

myfunc() {
  bcftools filter -e 'TYPE="snp"' "$1" -O v -o "$2"
}
export -f myfunc

cat parallel.input |
  parallel -j 3 -k --max-args=2 --joblog parallel.log myfunc

おすすめ記事