This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Samtools depth error in bash script

Hi!

I wrote a bash script to run Samtools depth, but it gives the following error:

/storage1/kaman/onceta/cover/brca12_uniq.bed
/storage1/kaman/onceta/cover/ENIGMA_uniq.bed
/storage1/kaman/onceta/cover/bam/26m_s67_l001_r1_001_alignment
[bed_read] Parse error reading "26m_s67_l001_r1_001_alignment.bam" at line 1
samtools depth: Could not read file "26m_s67_l001_r1_001_alignment.bam"

The script looks like this

brca12_bed= realpath brca12_uniq.bed
enigma_bed= realpath ENIGMA_uniq.bed

cd bam
for file in *.bam
do
    dir="${file%.bam}"
    mkdir -- "$dir"
    mv -- "$file" "$dir"
    cd "$dir"
    pwd
    samtools depth -a -b $brca12_bed $file > test.depth
done

At first I thought that the reason was in the wrong directory, but in this case, the script gives a different error

/storage1/kaman/onceta/cover/brca12_uniq.bed
/storage1/kaman/onceta/cover/ENIGMA_uniq.bed
samtools depth: Could not read file "26m_s67_l001_r1_001_alignment.bam": No such file or directory

Please help me find the error

samtools depth
brca12_bed=`realpath brca12_uniq.bed`

not

brca12_bed=realpath brca12_uniq.bed

Unfortunately it didn't help. Plus, there were additional difficulties with "Permission denied"

./test.sh: line 1: /storage1/kaman/onceta/cover/brca12_uniq.bed: Permission denied
/storage1/kaman/onceta/cover/ENIGMA_uniq.bed
/storage1/kaman/onceta/cover/bam/26m_s67_l001_r1_001_alignment
[bed_read] Parse error reading "26m_s67_l001_r1_001_alignment.bam" at line 1
samtools depth: Could not read file "26m_s67_l001_r1_001_alignment.bam"

0 answers

No answers yet.

Log in to answer this question.