Skip to content

Commit 8dcd868

Browse files
Add python2 backward compatibility and update README.md
1 parent 0775c76 commit 8dcd868

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
CPC2 standalone
22
====
33

4-
* 2019-11-19 16:50, Yu-jian Kang
4+
* 2019-11-23 15:30, Yang Ding
5+
- Now CPC2 supports both Python 2 and Python 3 (thanks for help from HyperOdin)
56

67
1 Pre-requisite:
78
----

bin/CPC2.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import sys
66
import os
77
import re
8-
import subprocess
8+
if (sys.version_info[0] == 2):
9+
import commands
10+
else:
11+
import subprocess
912
import time
1013
from optparse import OptionParser,OptionGroup
1114
import six
@@ -317,7 +320,10 @@ def calculate_potential(fasta,strand,output_orf,outfile):
317320
cmd = cmd + app_svm_predict + ' -b 1 -q ' + outfile + '.tmp.2 ' + data_dir + 'cpc2.model ' + outfile + '.tmp.out'
318321
#cmd = cmd + 'awk -vOFS="\\t" \'{if ($1 == 1){print $2,"coding"} else if ($1 == 0){print $2,"noncoding"}}\' ' + outfile + '.tmp.1 > ' + outfile + '.tmp.2 &&'
319322
#cmd = cmd + 'paste ' + outfile + '.feat ' + outfile + '.tmp.2 >>' + outfile
320-
(exitstatus, outtext) = subprocess.getstatusoutput(cmd)
323+
if (sys.version_info[0] == 2):
324+
(exitstatus, outtext) = commands.getstatusoutput(cmd)
325+
else:
326+
(exitstatus, outtext) = subprocess.getstatusoutput(cmd)
321327

322328
'''deal with the output'''
323329
#print outfile + '.tmp.out'
@@ -354,7 +360,10 @@ def calculate_potential(fasta,strand,output_orf,outfile):
354360
if exitstatus == 0:
355361
os.system('rm -f ' + outfile + '.tmp.1 ' + outfile + '.tmp.2 ' + outfile + '.tmp.out ' + outfile)
356362
rm_cmd = "rm -f " + outfile + '.feat'
357-
subprocess.getstatusoutput(rm_cmd)
363+
if (sys.version_info[0] == 2):
364+
commands.getstatusoutput(rm_cmd)
365+
else:
366+
subprocess.getstatusoutput(rm_cmd)
358367
sys.stderr.write("[INFO] Running Done!\n")
359368
return 0
360369
else:

0 commit comments

Comments
 (0)