题
我有这条线
samtools view -h file | awk '$3=="chr$a" || /^@/' | samtools view -S - -b -o output
.
-s和-b之间的短划线应该向其指示它来自stdin的程序。我可以从命令行的Perl脚本运行它,但一旦我尝试将其移动到shell脚本中,它只需在不输出任何数据的情况下创建文件。任何想法都将受到极大地感谢。
解决方案
In a shell script the $a inside single quotes will not be expanded:
for a in {1..22} do
samtools view -h AD3.sorted.bam | awk '$3=="chr$a" || /^@/' | samtools view -S - -b -o chr$a.bam
done
其他提示
If you haven't already, have a look at the samtools FAQ. This has examples for doing similar things to what you want to do with your pipeline.
Its been a while since I used samtools, but I would've written your command like this:
samtools view -h file | awk '$3=="chr$a" || /^@/' | samtools view -S -b - > output.bam
Also you mentioned you had moved the command to a shell script. Is the shell script doing anything else? If it still doesn't work, I would post that for us to look at.
不隶属于 StackOverflow