This is a test version of Biostars. For the public version, visit https://www.biostars.org.
hisat SyntaxError: invalid syntax

Hi all,

I am really struggling with hisat2 recently and getting confused. I'm trying to run hisat2

python2 /home/yun/Downloads/hisat2-2.2.0/hisat2 -t -p 2 -x shiryn\ RNAseq\ data/reference/grch38_genome/grch38 -1 shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_1.trim.fq.gz shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_2.trim.fq.gz -S shiryn\ RNAseq\ data/alighed/ly1.sam

Heie is my error:

File "/home/yun/Downloads/hisat2-2.2.0/hisat2", line 31
use strict;
         ^
SyntaxError: invalid syntax

Any help is appreciated.

hisat2 running erroe

This was already indirectly answered in your other thread. Try typing python3 instead of python2.

I see the problem actually, amusing

hisat2 runs via perl

hisat2-build runs via python

Serves me right for trying to answer the question in general without knowing the inner workings of the program. Xiaoyun, please ignore my response.

2 answers

hisat2 is a wrapper script. You need to run it simply as is. Do not run it using python2.

$ hisat2 -h
HISAT2 version 2.2.0 by Daehwan Kim (infphilo@gmail.com, www.ccb.jhu.edu/people/infphilo)
Usage: 
  hisat2 [options]* -x <ht2-idx> {-1 <m1> -2 <m2> | -U <r> | --sra-acc <SRA accession number>} [-S <sam>]

After I run the command

hisat2 -t -p 2 -x shiryn\ RNAseq\ data/reference/grch38_genome/grch38 -1 shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_1.trim.fq.gz shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_2.trim.fq.gz -S shiryn\ RNAseq\ data/alighed/ly1.sam

The output is

/usr/bin/env: ‘python’: No such file or directory
Extra parameter(s) specified: "data/reference/grch38_genome/grch38", "shiryn", "RNAseq", "data/trimmed", "data/ly1_paired_2.trim.fq.gz", "RNAseq", "data/alighed/ly1.sam"
Overall time: 00:00:00
Error: Encountered internal HISAT2 exception (#1)
Command: /home/yun/Downloads/hisat2-2.2.0/hisat2-align-s --wrapper basic-0 -t -p 2 -x shiryn -S shiryn RNAseq data/reference/grch38_genome/grch38 shiryn RNAseq data/trimmed data/ly1_paired_2.trim.fq.gz RNAseq data/alighed/ly1.sam 
(ERR): hisat2-align exited with value 1

It may be much simpler to re-install hisat2 using conda. Please use the directions here: Creating workflows with snakemake and conda (use the conda part of this tutorial). It should, I think, install all necessary dependencies in your user space.

Please do NOT use spaces in folder/file names (shiryn\ RNAseq\). While it may work it would cause strange issues with programs like what you are seeing here.

It have worked. Thanks for your help.

Don't run hisat2 through Python, it is not written in Python.

You could run it via Perl, but there should be no need to do so.

Invoke it directly as

hisat2

Edit: now I see that you also had a problem here

hisat2 /usr/bin/env: ‘python’: No such file or directory

as it turns out the two programs were written in different languages

  • hisat2 runs via perl
  • hisat2-build runs via python

So how should I do? After I run the command

hisat2 -t -p 2 -x shiryn\ RNAseq\ data/reference/grch38_genome/grch38 -1 shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_1.trim.fq.gz shiryn\ RNAseq\ data/trimmed\ data/ly1_paired_2.trim.fq.gz -S shiryn\ RNAseq\ data/alighed/ly1.sam

The output is

    /usr/bin/env: ‘python’: No such file or directory
Extra parameter(s) specified: "data/reference/grch38_genome/grch38", "shiryn", "RNAseq", "data/trimmed", "data/ly1_paired_2.trim.fq.gz", "RNAseq", "data/alighed/ly1.sam"
Overall time: 00:00:00
Error: Encountered internal HISAT2 exception (#1)
Command: /home/yun/Downloads/hisat2-2.2.0/hisat2-align-s --wrapper basic-0 -t -p 2 -x shiryn -S shiryn RNAseq data/reference/grch38_genome/grch38 shiryn RNAseq data/trimmed data/ly1_paired_2.trim.fq.gz RNAseq data/alighed/ly1.sam 
(ERR): hisat2-align exited with value 1

I have installed python2 and python3. But it desn't work at all.

Check if soft linking python2 to python works. Do you have admin or sudo privileges on your system? Please do not use spaces, dots and other special characters in folder or file names.

Log in to answer this question.