to run bowtie on multiple fastq file
2
2
Entering edit mode
8.1 years ago
Kritika ▴ 260

Hello all

Currently I am running bowtie to align my 4 pairend reads to reference genome . I am running shell script but it's 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 it's showing same error.

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

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
bowtie RNA-Seq • 20k views
ADD COMMENT
1
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode

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 REPLY
0
Entering edit mode

sorry its fastq file only showing same error

ADD REPLY
0
Entering edit mode

OK. Did you try the script above?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
7
Entering edit mode
8.1 years ago

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 COMMENT
1
Entering edit mode

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

ADD REPLY
2
Entering edit mode
8.1 years ago
surendra ▴ 30

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 COMMENT

Login before adding your answer.

Traffic: 2630 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