This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools view: failed to open for reading , samtools sort :can't open file

Hello,

I'm trying to align fastq files to a reference genome. I am very new to this work. And I got these errors. I don't understand what the problem is.

Can some one please help me to resolve this?Thank you

Code:

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

SAM="/home/users/maria/project_data/maria/SAM/Precapture_fullSS.sam";
BAM="/home/users/maria/project_data/maria/BAM/";
BED="/home/users/maria/project_data/maria/BED/";

#conda activate samtools

############################### to tmerge without chimeric, unmapped and secondary

samtools view -h -F 2308 ${SAM}Precapture_fullSS.sam > ${SAM}Precapture_fullSS_uniq.sam

samtools view -Sb  ${SAM}Precapture_fullSS_uniq.sam > ${BAM}Precapture_fullSS_uniq_notsorted.bam

samtools sort ${BAM}Precapture_fullSS_uniq_notsorted.bam -o ${BAM}Precapture_fullSS_uniq_sorted.bam

module load bedtools/2.30.0

bedtools bamtobed -bed12 -i ${BAM}Precapture_fullSS_uniq_sorted.bam > ${BED}Precapture_fullSS_uniq.bed12

Error message:

[E::hts_open_format] Failed to open file "/home/users/maria/project_data/maria/SAM/Precapture_fullSS.samPrecapture_fullSS.sam" : No such file or directory
samtools view: failed to open "/home/users/maria/project_data/maria/SAM/Precapture_fullSS.samPrecapture_fullSS.sam" for reading: No such file or directory
/var/lib/slurm-llnl/slurmd/job24798250/slurm_script: line 22: /home/users/maria/grant_566/project_data/maria/BAM/Precapture_fullSS_uniq_notsorted.bam :No such file or directory
[E::hts_open_format] Failed to open file "/home/users/maria/project_data/maria/BAM/Precapture_fullSS_uniq_notsorted.bam" : No such file or directory
samtools sort: can't open "/home/users/maria/project_data/maria/BAM/Precapture_fullSS_uniq_notsorted.bam": No such file or directory
gcc/8.2.0 load complete.
bedtools/2.30.0 load complete.
/var/lib/slurm-llnl/slurmd/job24798250/slurm_script: line 28: /home/users/maria/project_data/maria/BED/Precapture_fullSS_uniq.bed12 No such file or directory
bam sam samtools

/home/users/maria/project_data/maria/SAM/Precapture_fullSS.samPrecapture_fullSS.sam" : No such file or directory

the message is quite clear to me. Did you check there is a file here ?

Hello thank you for answering and yes I check there is a file.

1 answer

change the line

SAM="/home/users/maria/project_data/maria/SAM/Precapture_fullSS.sam"

to

SAM="/home/users/maria/project_data/maria/SAM/"

and try again.

Log in to answer this question.