Hello,
I have a script to run samtools pileup for multiple files. The script worked if I ran one file at a time without loop, but it gave me error saying "Illegal variable name" with the loop. So, I think it is something wrong with the loop. I have to use the old version of samtools with the pileup for the downstream analysis. Please anyone help me out with the issue.
#! /bin/csh
cd /share/gwascotton/GBS_data/pileup_trial/
source /usr/local/apps/samtools/samtools017a.csh
for i in $(ls *.bam);do
samtools pileup -c -l /share/gwascotton/GBS_data/merged_files.sorted.bam.pileup -f /share/gwascotton/GBS_data/Ghirsutum_458_v1.0.fa /share/gwascotton/GBS_data/pileup_trial/"$i" > /share/gwascotton/GBS_data/new/"$i".pileup
done ;
Thank you.
fhzh
Thank you for the code. I think I have to use csh because I have to submit my job to high performance computing (HPC) server and using the old version of samtools which the source code give the path to it. I modified your code a little bit as attached below, but I got error "while: Expression Syntax". Any ideas? Thanks
Every modern computing environment will support
bash
. So you should be able to use it. You will need to figure out what/usr/local/apps/samtools/samtools017a.csh
is doing and replace that with equivalent bash commands/script.Oh dear, I noticed the old version of SAMtools as judged by the fact that you are using pileup, which has been replaced with mpileup.
If you really need to use the c-shell, then try:
NB -
cat BAM.list
is surrounded by backticks (not single quotes).