This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bowtie2 simple alignment errors?

I'm new to Bowtie2 and have been trying to run some simple alignments in Bowtie2. My current bash script looks like this:

index_path= '/path/to/index/hg19_bt2'
read_path_1= 'path/to/read1.fastq.gz'
read_path_2= '/path/to/read2.fastq.gz'

module load gcc/6.2.0
module load bowtie2/2.3.4.3
bowtie2 -x $index_path -1 $read_path_1 -2 $read_path_2 -S bowtie2_test.sam

However, it gives me these errors: 1. For my compressed fastq files:

"cannot execute binary file"

2. For my command line input:

"-S" does not exist or is not a Bowtie 2 index

I'm not sure what is wrong with my script because I followed the Bowtie2 manual.

bowtie bowtie2 alignment

1 answer

The space between the variable name and the string you want to assign to it means bash will not interpret this as an assignment to a variable, it will interpret it as a command followed by a parameter to this command. See Spaces in variable assignments in shell scripts. Hence all variables are undefined and you command translates to:

bowtie2 -x  -1  -2  -S bowtie2_test.sam

I see, thank you. So I should have instead this?

index_path='/path/to/index/hg19_bt2'
read_path_1='path/to/read1.fastq.gz'
read_path_2='/path/to/read2.fastq.gz'

module load gcc/6.2.0
module load bowtie2/2.3.4.3
bowtie2 -x $index_path -1 $read_path_1 -2 $read_path_2 -S bowtie2_test.sam

Do you know why bowtie2 doesn't work with my -S flag to denote the output file?

Is that still not working after you fixed the variable assignment issue? Do you have permissions to write to the directory you are executing this script from? If you don't, then provide a different location in -S /path_to/*.sam in the command above.

I will double check, but here is the list of errors I am recieving now:

   Line 14: /path/to/index/hg19_bt2: No such file or directory
   Line 15: /path/to/read1.fastq.gz: cannot execute binary file
   Line 16: /path/to/read2.fastq.gz: cannot execute binary file
    (ERR): "-S" does not exist or is not a Bowtie 2 index
    Exiting now ...

You are using real/full paths to those files correct? /path/to/index/ is just place holder and needs to be replaced with actual file paths on your server.

Yes. And I do have write access, as I built a bowtie2 index in the same directory using another script.

Can you post the command you used to build the index? Is hg19_bt2 basename for your index files?

module load gcc/6.2.0
module load bowtie2/2.3.4.3
bowtie2-build -f '/path/referenceGenomes/hg19_ucsc.fa' 'hg19_ucsc'

Your basename for the index is hg19_ucsc. So you should set

index_path='/path/to/index/hg19_ucsc'

This is not the same index that I used in the previous script. Previously, I used a premade script from some one else; here, I am just making my own separately.

Based on the information you provided above hg19_ucsc should be the basename for the index you built. Can you show us output of du -sh hg19_ucsc or if that does not produce anything the a listing of directory where you think the index is present.

Are you sure the index creation worked without any errors?

Log in to answer this question.