يعمل على سطر الأوامر ولكن ليس في برنامج نصي شل

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

  •  15-11-2019
  •  | 
  •  

سؤال

لدي هذا الخط giveacodicetagpre.

من المفترض أن يشير الاندفاعة بين -S و -.b إلى البرنامج الذي هو من Stdin.يمكنني تشغيله من برنامج نصي بيرل في سطر الأوامر ولكن بمجرد أن أحاول نقله إلى برنامج نصي شل، فقط ينشئ الملف دون إخراج أي بيانات.سيتم تقدير أي أفكار إلى حد كبير.

هل كانت مفيدة؟

المحلول

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