Question: to run bowtie on multiple fastq file
2
gravatar for Kritika
3.5 years ago by
Kritika260
India
Kritika260 wrote:

Hello all Currently i am running bowtie to align my 4 pairend reads to reference genome . I am running shell script but its showing error

for i in $(path_to_my_fastqfiles/*.fastq)
do
    /opt/bowtie2-2.2.6/bowtie2 -p4 -x path_to_my_reference genome/ref/  path_to_my_fastqfile -1 ${i}.fastq -2 ${i}.fastq -S $i.sam
done

i am getting error permission denied even if i do with sudo still its showing same error.

also if i change the first line for i in $(ls *.fastq) this error i get

Warning: Same mate file "ls" appears as argument to both -1 and -2 Extra parameter(s) specified: "path_to_my_fastqfiles", ".fastq", ".fastq", "*.fastq.sam" Note that if <mates> files are specified using -1/-2, a <singles> file cannot also be specified. Please run bowtie separately for mates and singles. Error: Encountered internal Bowtie 2 exception (#1) Command: /opt/bowtie2-2.2.6/bowtie2-align-s --wrapper basic-0 -p4 -x /path_to_my_ref/ -S ls -1 ls -2 ls path_to_my_fastqfile *.fastq *.fastq *.fastq.sam (ERR): bowtie2-align exited with value 1

ADD COMMENTlink modified 2.3 years ago by Biostar ♦♦ 20 • written 3.5 years ago by Kritika260
1

Can you post exact error ? Permission denied to read the files or execute the command or create sam file ?

Irrespective of permissions error, I do not know why it should work if you use -1 ${i}.fastq -2 ${i}.fastq essentially both R1 and R2 are same files ?

check bash loop for alignment RNA-seq data

ADD REPLYlink modified 3.5 years ago • written 3.5 years ago by geek_y9.8k
1

I changed my script : -1 ${i}A_R1.fasta -2 ${i}A_R2.fasta

My files are 1A_R1.fastq 1A_R2.fastq 2A_R1.fastq 2A_R2.fastq ....

/media/74BE94C7BE948372/sample/to_run_all_file.sh: 1: /media/74BE94C7BE948372/sample/to_run_all_file.sh: /media/74BE94C7BE948372/sample/fastq_file/1A_R1.fastq: Permission denied

ADD REPLYlink written 3.5 years ago by Kritika260
1

It should be pretty simple if you exactly show us how your files are named. can you show us the output of the command ls path_to_my_fastqfiles/*.fastq

ADD REPLYlink modified 3.5 years ago • written 3.5 years ago by geek_y9.8k

1A_R1.fastq 2A_R1.fastq 3A_R1.fastq 4A_R1.fastq
1A_R2.fastq 2A_R2.fastq 3A_R2.fastq 4A_R2.fastq

this are my file names this are stored in media/sample/fastqfiles folder

ADD REPLYlink written 3.5 years ago by Kritika260

for i in $(path_to_my_fastqfiles/*.fastq) is going to return the full path of your fastqs, so $iA_R2.fasta will become /path/to/1A_R1.fastqA_R1.fasta

This is not what you wanted I guess?

First off - are you using fasta or fastq because you change between the two...? Second off (is that a thing?) - you want to target ONLY THE R1s when assigning $i, and then cut off the last 8 characters. Do that with:

for i in $(path_to_my_fastqfiles/*R1.fastq)
do
    yolo=$(echo "$i" | rev | cut -c 9- | rev) # dumb way of cutting off the last 8 chars
    /opt/bowtie2-2.2.6/bowtie2 -p4 -x path_to_my_reference genome/ref/ -1 {$yolo}R1.fastq -2 {$yolo}R2.fastq -S {$yolo}.sam
done

Also I suck at bash so theres a good chance you need to quote things or remove those {brackets} or something, but try it and see :)

Also also, this is why i hate defining what to run and running it at the same time. Although others may disagree, you should write a script that generates a list of commands to execute, so 1) you have it on record, 2) you can see what your doing as you iteratively create the list of commands to run.

ADD REPLYlink written 3.5 years ago by John12k

sorry its fastq file only showing same error

ADD REPLYlink written 3.5 years ago by Kritika260

OK. Did you try the script above?

ADD REPLYlink written 3.5 years ago by John12k

If you paste the full filepath of both your -1 and -2, we can help you write a bash loop that works :)

ADD REPLYlink written 3.5 years ago by John12k

Dont surround the path with $(). That is a process substitution and the shell will try and execute the file path as a command.

If you need a list of files try:

for i in path/to/file/*.fastq ;

or

for i in $(ls /path/to/files) ;

ADD REPLYlink written 2.3 years ago by jrj.healey13k
5
gravatar for geek_y
3.5 years ago by
geek_y9.8k
Barcelona
geek_y9.8k wrote:

There are multiple ways but this should also work. You can specify a output directory where you want to save sam files.

for sample in `ls /media/sample/fastqfiles/*R1.fastq`
do
dir="/media/sample/fastqfiles"
base=$(basename $sample "_R1.fastq")
bowtie2 -x path_to_my_index -1 ${dir}/${base}_R1.fastq -2 ${dir}/${base}_R2.fastq -S ${dir}/${base}.sam
done

Always crosscheck what is doing with echo statement.

echo "bowtie2 -x path_to_my_index -1 ${dir}/${base}_R1.fastq -2 ${dir}/${base}_R2.fastq -S ${dir}/${base}.sam"
ADD COMMENTlink modified 3.5 years ago • written 3.5 years ago by geek_y9.8k
1

Oooh, basename takes a second parameter? Awesome :D Thanks Goutham :)

ADD REPLYlink written 3.5 years ago by John12k
2
gravatar for surendra
3.5 years ago by
surendra30
South Africa
surendra30 wrote:

Hi

You can run the bowtie2 with the following command

bowtie2 -x refernce_file -1 Forward_read_file_A_1, Forward_read_file_B_1 -2 Reverse_read_file_A_2, Reverse_read_file_B_2

I think it will solve your problem.

ADD COMMENTlink written 3.5 years ago by surendra30
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: 1332 users visited in the last hour