Работает на командной строке, но не в скрипте оболочки

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