Im a bioinformatics student and new with bash and programming stuff. i wanna calculate genome coverage. #this is my script, I switch real parameter with xx but im sure xxs are not problematic, other students already execute this script with no error.
filename=$1
reference=/xx
filebase=$(basename $filename .bam)
samtools view ${filename} -F 4 -q 30 -b > ${filebase}.f.bam
genomeCoverageBed -ibam -g ${filebase}.f.bam ${reference} > /mnt/ABC/projects/abc/def/${filebase}.cov
coverage=$(grep genome /mnt/ABC/projects/abc/def/${filebase}.cov | awk '{NUM+=$2*$3; DEN+=$3} END {print NUM/DEN}')
echo -e "${filename},${coverage}" >> coverages.txt
when I execute this script with sh ./coverage.sh /mnt/XYZ/share/sdf_rawdata/hsa/mergedbams/ghj_merged_200203.hs37d5.cons.90perc.bam
it doesn't work and give me awk: cmd. line:1: fatal: division by zero attempted and unrecognized parameter:/mnt/XYZ/share/sdf_rawdata/hsa/mergedbams/ghj_merged_200203.hs37d5.cons.90perc.bam error and in the coverages.txt file is only has this line -e /mnt/NEOGENE2/share/compevo_rawdata/hsa/mergedbams/Ash128_all.merged.hs37d5.fa.cons.90perc.bam, nothing more . thanks for helping