명령 줄에서 작동하지만 쉘 스크립트에서는 작동하지 않습니다.

StackOverflow https://stackoverflow.com/questions/9525768

  •  15-11-2019
  •  | 
  •  

문제

나는이 선을 가지고있다

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

-S와 -B 사이의 대시는 STDIN으로 인한 프로그램에 표시되어야합니다.명령 줄에서 Perl 스크립트에서 실행할 수 있지만 쉘 스크립트로 이동하려고하면 데이터를 출력하지 않고 파일을 만듭니다.어떤 아이디어가 크게 감사 할 것입니다.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top