Skip to content

Commit

Permalink
Add python2 backward compatibility and update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdingyangding committed Nov 23, 2019
1 parent 0775c76 commit 8dcd868
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
CPC2 standalone
====

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

1 Pre-requisite:
----
Expand Down
15 changes: 12 additions & 3 deletions bin/CPC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import sys
import os
import re
import subprocess
if (sys.version_info[0] == 2):
import commands
else:
import subprocess
import time
from optparse import OptionParser,OptionGroup
import six
Expand Down Expand Up @@ -317,7 +320,10 @@ def calculate_potential(fasta,strand,output_orf,outfile):
cmd = cmd + app_svm_predict + ' -b 1 -q ' + outfile + '.tmp.2 ' + data_dir + 'cpc2.model ' + outfile + '.tmp.out'
#cmd = cmd + 'awk -vOFS="\\t" \'{if ($1 == 1){print $2,"coding"} else if ($1 == 0){print $2,"noncoding"}}\' ' + outfile + '.tmp.1 > ' + outfile + '.tmp.2 &&'
#cmd = cmd + 'paste ' + outfile + '.feat ' + outfile + '.tmp.2 >>' + outfile
(exitstatus, outtext) = subprocess.getstatusoutput(cmd)
if (sys.version_info[0] == 2):
(exitstatus, outtext) = commands.getstatusoutput(cmd)
else:
(exitstatus, outtext) = subprocess.getstatusoutput(cmd)

'''deal with the output'''
#print outfile + '.tmp.out'
Expand Down Expand Up @@ -354,7 +360,10 @@ def calculate_potential(fasta,strand,output_orf,outfile):
if exitstatus == 0:
os.system('rm -f ' + outfile + '.tmp.1 ' + outfile + '.tmp.2 ' + outfile + '.tmp.out ' + outfile)
rm_cmd = "rm -f " + outfile + '.feat'
subprocess.getstatusoutput(rm_cmd)
if (sys.version_info[0] == 2):
commands.getstatusoutput(rm_cmd)
else:
subprocess.getstatusoutput(rm_cmd)
sys.stderr.write("[INFO] Running Done!\n")
return 0
else:
Expand Down

0 comments on commit 8dcd868

Please sign in to comment.