This is a test version of Biostars. For the public version, visit https://www.biostars.org.
TopHat error: IOError [errno 2] No such file or directory: '-o'

Hello everyone.

I'm now running tophat in our server. First, I just simply tried "tophat -p 8 -G <gtf_file> <ref_genome> <fa1><fa2>" and it worked. Then I wrote a for loop scripts but It reported error:

[2019-04-03 10:49:16] Beginning TopHat run (v2.1.0)

-----------------------------------------------

[2019-04-03 10:49:16] Checking for Bowtie

                  Bowtie version:        2.2.9.0

[2019-04-03 10:49:16] Checking for Bowtie index files (genome)..

[2019-04-03 10:49:16] Checking for reference FASTA file

Warning: Could not find FASTA file mouse/bowtie2_index_mouse/mouse_ref.fa

[2019-04-03 10:49:16] Reconstituting reference FASTA file from Bowtie index

Executing: /opt/sw/packages/gcc-4.8/bowtie2/2.2.9/bin/bowtie2-inspect 
mouse/bowtie2_index_mouse/mouse_ref > ./tophat_out/tmp/mouse_ref.fa

[2019-04-03 10:51:05] Generating SAM header for mouse/bowtie2_index_mouse/mouse_ref

Traceback (most recent call last):

File "/opt/sw/packages/gcc-4.8.3/mvapich2-2.1/boost-1.59.0/tophat2/2.1.0/bin/tophat", line 4095, in <module>

sys.exit(main())

File "/opt/sw/packages/gcc-4.8.3/mvapich2-2.1/boost-1.59.0/tophat2/2.1.0/bin/tophat", line 3949, in main
    params.read_params = check_reads_format(params, reads_list)

File "/opt/sw/packages/gcc-4.8.3/mvapich2-2.1/boost-1.59.0/tophat2/2.1.0/bin/tophat", line 1844, in check_reads_format
    zf = ZReader(f_name, params)

File "/opt/sw/packages/gcc-4.8.3/mvapich2-2.1/boost-1.59.0/tophat2/2.1.0/bin/tophat", line 1797, in __init__
    self.file=open(filename)

IOError: [Errno 2] No such file or directory: '-o'

My for loop code is shown as below:

for name1 in R1/*_R1_001.fastq.trimmed_val.fq; 
do 
name2="R2/$(basename "$name1" _R1_001.fastq.trimmed_val.fq)_R2_001.fastq.trimmed_val.fq"; 

if [ ! -f "$name2" ]; then printf 'Missing "%s"\n' "$name2"; 
continue; 
fi;
tophat -p 8 mouse/bowtie2_index_mouse/mouse_ref -o tophat_out/ -G mouse/ensembl_gtf/Mus_musculus.GRCm38.95.chr_patch_hapl_scaff.gtf $name1 $name2; 
done

It looks like the directory path problem but I have changed the path several times it still report this error. I wonder if anyone could help me about this?

Thank you!

rna-seq rna-seq alignment software error

Does the tophat_out directory already exist before you run the program?

Can you share one file name belonging to the same sample from R1 and R2 directory?

2 answers

Its probably safer to list your options like -o and -G before you give the path to the genome Notice how in your first working example, -G is before you specified the path to the genome.

Usage: tophat [options]* <genome_index_base> <reads1_1[,...,readsn_1]&gt; [reads1_2,...readsn_2]<="" p="">

https://ccb.jhu.edu/software/tophat/manual.shtml

I think the software thinks it's looking for a fastq file called -o when you put that right after the path to your genome.

Most likely, the problem is that you're using a relative file path to open the file.

An absolute path is a path that starts with your computer's root directory, for example 'C:\Python\scripts..' if you're on Windows.

A relative path is a python path that does not start with your computer's root directory, and is instead relative to something called the working directory. You can view Python's current working directory by calling os.getcwd().

Use an absolute path to open the file:

file = open(r'C:\path\to\your\file.ext')

Log in to answer this question.