Samtools depth error in bash script
0
0
Entering edit mode
3.1 years ago
kamanovae ▴ 100

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 • 974 views
ADD COMMENT
0
Entering edit mode
brca12_bed=`realpath brca12_uniq.bed`

not

brca12_bed=realpath brca12_uniq.bed
ADD REPLY
0
Entering edit mode

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"
ADD REPLY

Login before adding your answer.

Traffic: 2737 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6