bash - How to give file input from a dir and produce the output in a different dir using GNU parallel?
问题描述
I am trying to use parallel
for bam to sort and index using samtools
and producing the output in a given output_dir
but facing some problems.
I tried so far the following, which is working but I don't want that dir name "1" within output_dir
and also getting results files within input_dir
.
parallel --results output_dir 'samtools sort -o {.}.sorted.bam {}' ::: input_dir/*.bam
This, from comments, is not working:
parallel 'samtools sort -o output_dir/{.}.sorted.bam {}' ::: input_dir/*.bam
I get the error
“[E::hts_open_format] Failed to open file output_dir/input_dir/A-8_20181222_0036.sorted.bam”
Note: This is just one tool (samtools
) I am asking but I will be using other tools that produce output using --output
/ -o
flag.
解决方案
If your question is "how can I add a different directory instead of the input directory", just put it verbatim before the {/.}
token. (You had {.}
but we also want to trim the directory name.)
parallel 'samtools sort -o output_dir/{/.}.sorted.bam {}' ::: input_dir/*.bam
See the manual for more ideas, there is a large number of transformations you can perform on the input token.
推荐阅读
- python - 在 Windows 上通过 Anaconda 安装 OpenCV for Python 时出现 UnsatisfiableError
- apache-spark - 通过 spark 优化缓存
- python - 如何在 Bigquery Python API 中使用 projection_fields 参数
- python - Logits 和标签具有不同的第一维
- c++ - long double 除法不能得到期望值
- reactjs - 使用钩子和标题功能反应导航 - 状态未更新
- git - 变基后将代码推送到 GIT 时出错
- r - 如何在 R 中找到列表中的最大值及其行和列索引?
- javascript - 移动菜单在奇数时间锁定
- knockout.js - Uncaught ReferenceError: Unable to process binding "if: function(){return (addressOptions.length > 1) }" 消息:addressOptions 未定义