Question: Stringtie prepDE.py Error line 32
0
gravatar for bryce.kirby
13 months ago by
bryce.kirby0 wrote:

Hello,

I am working on inputting my data from stringtie -e-B to then perform differential expression on my samples using Deseq. I am running the command 'python prepDE.py -i sample_list.txt' but keep getting this error :

python ./prepDE.py -i /scratch/exp_radonc/bkirby/scratch/mazur_lab_scratch/mazur_lab/SH-ERK5_RNA480/ballgown/sample_list.txt 
  File "./prepDE.py", line 32
    print "Error: Text file with sample ID and path invalid (%s)" % (line.strip())
                                                                ^
SyntaxError: invalid syntax

my sample_list file looks like this :

[bkirby@cnode241 ballgown]$ head sample_list.txt 
sample1 /SH-11/SH-11.gtf
sample2 /SH-12/SH-12.gtf
sample3 /SH-13/SH-13.gtf
sample4 /SH-14/SH-14.gtf
sample5 /SH-15/SH-15.gtf
sample6 /SH-16/SH-16.gtf
sample7 /SH-17/SH-17.gtf
sample8 /SH-18/SH-18.gtf
sample9 /SH-19/SH-19.gtf

and subsequent directories containing the .gtf files in my working directory like this:

[bkirby@cnode241 ballgown]$ ls
SH-11  SH-12  SH-13  SH-14  SH-15  SH-16  SH-17  SH-18  SH-19  prepDE.py  prepDE_multi.py  sample_list.txt  sample_lst.txt

Here is what each "SH" directory contains inside it:

[bkirby@cnode241 SH-11]$ ls
SH-11.gtf  e2t.ctab  e_data.ctab  i2t.ctab  i_data.ctab  t_data.ctab

Has anyone come across this issue or know any quick fixes? Am I missing something here with the way I'm setting up the command?

Here is the section of code that is giving me an error:

samples = [] # List of tuples. If sample list, (first column, path). Else, (subdirectory name, path to gtf file in subdirectory)
    if (os.path.isfile(opts.input)):
        # gtfList = True
        try:
            fin = open(opts.input, 'r')
            for line in fin:
                if line[0] != '#':
                    lineLst = tuple(line.strip().split())
                    if (len(lineLst) != 2):
                        print "Error: Text file with sample ID and path invalid (%s)" % (line.strip())
                        exit(1)

Any help is appreciated!

Thanks so much,

Bryce

ADD COMMENTlink modified 11 months ago by Biostar ♦♦ 20 • written 13 months ago by bryce.kirby0
1

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time. Formatting bar

ADD REPLYlink written 13 months ago by RamRS21k
1

What is the full path to /SH-11/SH-11.gtf?

ADD REPLYlink written 13 months ago by cpak1981100
3
gravatar for cpad0112
13 months ago by
cpad011211k
India
cpad011211k wrote:

did you check your python version? I guess prep_de is in python2.7. Try python2.7 and add "." (eg. ./SH-12/SH-12.gtf instead of /SH-12/SH-12.gtf) before gtf path if you are in current directory or add correct path to gtf file.

This worked for me (execution copy/pasted):

$ python2.7 ./prepDE.py -i sample.txt 
0 sample2
1 sample3
2 sample4
3 sample5
4 sample6
5 sample7
6 sample8
7 sample9

with python 3.6:

$ python ./prepDE.py -i sample.txt 
  File "./prepDE.py", line 32
    print "Error: Text file with sample ID and path invalid (%s)" % (line.strip())
                                                                ^
SyntaxError: invalid syntax

input:

$ ls
    prepDE.py  sample.txt  SH-12  SH-13  SH-14  SH-15  SH-16  SH-17  SH-18  SH-19

sample list:

$ cat sample.txt 
sample2 ./SH-12/SH-12.gtf
sample3 ./SH-13/SH-13.gtf
sample4 ./SH-14/SH-14.gtf
sample5 ./SH-15/SH-15.gtf
sample6 ./SH-16/SH-16.gtf
sample7 ./SH-17/SH-17.gtf
sample8 ./SH-18/SH-18.gtf
sample9 ./SH-19/SH-19.gtf

directory structure post execution:

$ tree .
.
├── gene_count_matrix.csv
├── prepDE.py
├── sample.txt
├── SH-12
│   └── SH-12.gtf
├── SH-13
│   └── SH-13.gtf
├── SH-14
│   └── SH-14.gtf
├── SH-15
│   └── SH-15.gtf
├── SH-16
│   └── SH-16.gtf
├── SH-17
│   └── SH-17.gtf
├── SH-18
│   └── SH-18.gtf
├── SH-19
│   └── SH-19.gtf
└── transcript_count_matrix.csv

8 directories, 12 files
ADD COMMENTlink modified 13 months ago • written 13 months ago by cpad011211k

Thank you so much!!! Changing the version of python worked! I really appreciate it, this had me stuck for a whole day.

ADD REPLYlink written 13 months ago by bryce.kirby0
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: 1361 users visited in the last hour