Thank you so much!!! Changing the version of python worked! I really appreciate it, this had me stuck for a whole day.
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
2 answers
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
This is the section of code giving me issues:
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)
Hi bryce.kirby ,
This information belongs in your original post, and should be added there, not as an answer. Answers should only be added when they answer the top-level question. You can move this information by following the steps below:
- Copy the contents of this answer (you can edit this answer (link opens in a new tab) and do a
Select All->Copy) Edityour post (link opens in a new tab)- Paste the copied text in an appropriate spot. Add an "EDIT:" if required to mark that you've added this information as a follow up.
- Click on the blue
Submitbutton - Click on
moderateback in your answer here: A: Stringtie prepDE.py Error line 32 - Choose
Delete Post Click on the blue
Submitbutton.Thank you!
Log in to answer this question.
Please use the formatting bar (especially the
codeoption) to present your post better. I've done it for you this time.What is the full path to
/SH-11/SH-11.gtf?