0

I have this line

samtools view -h file | awk '$3=="chr$a" || /^@/' | samtools view -S - -b -o output

the dash between the -S and the -b is supposed to indicate to the program that it is from STDIN. I can run it from a perl script on the command line but as soon as I try to move it into a shell script it just creates the file without outputting any data. Any ideas would be greatly appreciated.

4

2 回答 2

0

如果您还没有,请查看samtools 常见问题解答。这有一些示例,用于执行与您想要对管道执行的操作类似的操作。

自从我使用 samtools 以来已经有一段时间了,但我会这样写你的命令:

samtools view -h file | awk '$3=="chr$a" || /^@/' | samtools view -S -b - > output.bam

您还提到您已将命令移至 shell 脚本。shell 脚本是否还在做其他事情?如果它仍然不起作用,我会发布给我们看看。

于 2012-03-02T12:57:17.677 回答
0

在 shell 脚本中,单引号内的 $a 不会被扩展:

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 
于 2012-03-03T16:04:23.463 回答