Question: Multiple fastq alignment with bowtie2
0
gravatar for martyferr90
2.0 years ago by
martyferr9030
martyferr9030 wrote:

Hi! I'm trying to perform a multiple alignment with bowtie2. In particular I'm looking for a cycle that can execute the alignment of more fastq files into sam files.

I try this shell code

for i in $(path_to_my_fastq_file/*.fastq)
do 
bowtie2 -p4- -x hg19 path_to_my_fastq_file/*.fastq ${i}.fastq -S $i.sam
done

but I receive this error

bash: path_to_my_fastq_file.file.fistq permission denied

How can I resolve this?

Thanks in advance

alignment fastq bowtie2 • 2.3k views
ADD COMMENTlink modified 2.0 years ago by Devon Ryan93k • written 2.0 years ago by martyferr9030

......... -q $i -S $i.sam instead of:

path_to_my_fastq_file/*.fastq ${i}.fastq
ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by Buffo1.7k
3
gravatar for Devon Ryan
2.0 years ago by
Devon Ryan93k
Freiburg, Germany
Devon Ryan93k wrote:

Doing stuff like this in bash is somewhat annoying, that's why things like snakemake are around:

rule bowtie2:
    input: "path/{sample}.fastq"
    output: "{sample}.bam"
    threads: 4
    shell: """
        bowtie2 -p {threads} -x hg19 {input} | samtools view -bo {output} -
        """

Having said that, you presumably wanted something like:

for i in $(path_to_my_fastq_file/*.fastq)
do
bowtie2 -p 4 -x hg19 ${i} | samtools view -bo ${i%%.fastq}.bam -
done

I've taken the liberty of removing the SAM intermediate.

ADD COMMENTlink written 2.0 years ago by Devon Ryan93k
2

While we're at it, let's produce a sorted bam:

for i in $(path_to_my_fastq_file/*.fastq)
do
bowtie2 -p 4 -x hg19 ${i} | samtools sort -o ${i%%.fastq}.bam -
done
ADD REPLYlink written 2.0 years ago by WouterDeCoster42k

Hi! I tryed your code, but my error is still: permission denied. Any idea?

ADD REPLYlink written 2.0 years ago by martyferr9030

Does the file exist and do you have read access to it?

ADD REPLYlink written 2.0 years ago by WouterDeCoster42k

-rw-r--r-- this are the permission of my 31 files in the directory of the path that I use in $(path_to_my_fastq_file).

If I type the command with only one file it works (simple bowtie 2 -x hg19 in.fastq | samtools sort -o out.bam), with a for instruction doesn't work anymore .-.

ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by martyferr9030

Check if the command looks okay by adding "echo":

for i in $(path_to_my_fastq_file/*.fastq)
do
echo bowtie2 -p 4 -x hg19 ${i} | samtools sort -o ${i%%.fastq}.bam -
done
ADD REPLYlink modified 2.0 years ago • written 2.0 years ago by WouterDeCoster42k

the output is still pemission denied .-.

ADD REPLYlink written 2.0 years ago by martyferr9030

The echo should just print the commands without executing them. So you shouldn't get output nor "permission denied".

ADD REPLYlink written 2.0 years ago by WouterDeCoster42k

I think there needs to be a quote around the command after echo. As is, echo is piping to samtools and that should then be written to disk.

ADD REPLYlink written 2.0 years ago by Devon Ryan93k

Yes, it appears you're right.

for i in $(path_to_my_fastq_file/*.fastq)
do
echo "bowtie2 -p 4 -x hg19 ${i} | samtools sort -o ${i%%.fastq}.bam -"
done
ADD REPLYlink written 2.0 years ago by WouterDeCoster42k

It's still permission denied. Where I'm wrong? ç_ç

ADD REPLYlink written 2.0 years ago by martyferr9030

could you do a ls -l on the directory where you want to output your data please ?

ADD REPLYlink written 2.0 years ago by Nicolas Rosewick8.5k
-rw-rw-rw- 1 utente utente 1716298636 dic 11 11:18 bam012.fastq
-rw-rw-rw- 1 utente utente 1694712150 dic 11 11:19 bam004.fastq

I tried with -r--r--r- permission too and still the same error!

ADD REPLYlink written 2.0 years ago by martyferr9030

could you do the ls -l on the directory not on the fastq please

ADD REPLYlink written 2.0 years ago by Nicolas Rosewick8.5k
drwxr-xr-x 2 utente utente       4096 dic 11 11:19 test_fastq

This is the output directory (the same of the input files)

ADD REPLYlink written 2.0 years ago by martyferr9030

Try to chmod the directory. chmod 755 output_dir. Then retry the alignment

ADD REPLYlink written 2.0 years ago by Nicolas Rosewick8.5k

I done:

chmod 755 out/
drwxr-xr-x 2 utente utente       4096 dic 11 11:59 out

Then

for i in $(/home/utente/test/test_fastq/*.fastq)
> do
> bowtie2 -p 4 -x /home/utente/bowtie2/hg19 ${i} | samtools sort -o ${i%%.fastq}.bam -
> done

and

Permission denied

Why ? ç_ç

ADD REPLYlink written 2.0 years ago by martyferr9030

How does this look like?

for i in $(/home/utente/test/test_fastq/*.fastq)
do
echo ${i}
echo ${i%%.fastq}.bam
done

What about ls - l /home/utente/test/test_fastq/*.fastq?
Perhaps you don't have reading permissions to those? Would be odd.

ADD REPLYlink written 2.0 years ago by WouterDeCoster42k

This is the output of ls -l /home/utente/test/test_fastq/*.fastq

drwxr-xr-x 2 utente utente       4096 dic 11 11:59 out
-rw-rw-rw- 1 utente utente 1716298636 dic 11 11:18 bam012.fastq
-rw-rw-rw- 1 utente utente 1694712150 dic 11 11:19 bam004.fastq

where out is the output directory.

And this is the code:

for i in $(/home/utente/test/test_fastq/*.fastq)
> do
> echo ${i}
> echo ${i%%.fastq}.bam
> done
bash: /home/utente/test/test_fastq bam012.fastq: Permission denied

The same output if I use echo "${i}" and echo "${i%%.fastq}.bam"

ADD REPLYlink written 2.0 years ago by martyferr9030

Did you find a solution to this "permission denied" problem? I am facing similar problem while trying to run multiple alignment in server

Here is my script

#!/bin/bash
#BATCH --job-name=ERR1135336.clean.reads.Assembly
#SBATCH -N 1                    # Number of nodes, not cores
#SBATCH -t 2-00:00:00           # Walltime
#SBATCH --ntasks-per-node 40    # Number of cores
#SBATCH --output=out-%j.log     # Output (console)
#SBATCH --partition=test       # Queue

module use /gpfs/shared/modulefiles_local
module use /gpfs/shared/modulefiles_local/bio
module load bio/bowtie2/2.3.4

for i in $(path/to/*.fastq)
do
bowtie2 -x PC_805 --threads 40 -U ${i} -S path/to/${i%%.fastq}.sam
done

Any help will be much appreciated

ADD REPLYlink modified 7 months ago • written 7 months ago by chayan.roy930
0
gravatar for Nicolas Rosewick
2.0 years ago by
Belgium, Brussels
Nicolas Rosewick8.5k wrote:

Maybe with xargs (not tested)

ls path_to_my_fastq_files/*.fastq | xargs -I fastq bowtie2 -p4 -x hg19 fastq -S fastq.sam
ADD COMMENTlink written 2.0 years ago by Nicolas Rosewick8.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 769 users visited in the last hour