55import sys
66import os
77import re
8- import commands
8+ import subprocess
99import time
1010from optparse import OptionParser ,OptionGroup
11-
11+ import six
1212import numpy as np
1313from Bio .Seq import Seq
1414from Bio .SeqUtils import ProtParam
15-
1615import seqio
1716
1817def __main ():
@@ -85,7 +84,7 @@ def find_longest_in_one(self,myframe,direction,start_codon,stop_codon):
8584 '''
8685 while True :
8786 try :
88- codon ,index = triplet_got . next ()
87+ codon ,index = next (triplet_got )
8988 except StopIteration :
9089 break
9190 if codon in starts and codon not in stops :
@@ -96,7 +95,7 @@ def find_longest_in_one(self,myframe,direction,start_codon,stop_codon):
9695 end_extension = False
9796 while True :
9897 try :
99- codon ,index = triplet_got . next ()
98+ codon ,index = next (triplet_got )
10099 except StopIteration :
101100 end_extension = True
102101 integrity = - 1
@@ -252,9 +251,12 @@ def calculate_potential(fasta,strand,output_orf,outfile):
252251 '''
253252 strinfoAmbiguous = re .compile ("X|B|Z|J|U" ,re .I )
254253 ptU = re .compile ("U" ,re .I )
255- ftmp_feat = file (outfile + ".feat" ,"w" )
256- ftmp_svm = file (outfile + ".tmp.1" ,"w" )
257- ftmp_result = file (outfile ,"w" )
254+ ## merged by Yang Ding on 2019-11-23
255+ ## 1. all python 2-"file"'s are replaced with python 3-"open"'s
256+ ## 2. keep kangyj's check on output_orf
257+ ftmp_feat = open (outfile + ".feat" ,"w" )
258+ ftmp_svm = open (outfile + ".tmp.1" ,"w" )
259+ ftmp_result = open (outfile ,"w" )
258260 if output_orf == 1 :
259261 my_header = ["#ID" ,"transcript_length" ,"peptide_length" ,"Fickett_score" ,"pI" ,"ORF_integrity" ,"ORF_Start" ,"coding_probability" ,"label" ]
260262 else :
@@ -315,7 +317,7 @@ def calculate_potential(fasta,strand,output_orf,outfile):
315317 cmd = cmd + app_svm_predict + ' -b 1 -q ' + outfile + '.tmp.2 ' + data_dir + 'cpc2.model ' + outfile + '.tmp.out'
316318 #cmd = cmd + 'awk -vOFS="\\t" \'{if ($1 == 1){print $2,"coding"} else if ($1 == 0){print $2,"noncoding"}}\' ' + outfile + '.tmp.1 > ' + outfile + '.tmp.2 &&'
317319 #cmd = cmd + 'paste ' + outfile + '.feat ' + outfile + '.tmp.2 >>' + outfile
318- (exitstatus , outtext ) = commands .getstatusoutput (cmd )
320+ (exitstatus , outtext ) = subprocess .getstatusoutput (cmd )
319321
320322 '''deal with the output'''
321323 #print outfile + '.tmp.out'
@@ -352,7 +354,7 @@ def calculate_potential(fasta,strand,output_orf,outfile):
352354 if exitstatus == 0 :
353355 os .system ('rm -f ' + outfile + '.tmp.1 ' + outfile + '.tmp.2 ' + outfile + '.tmp.out ' + outfile )
354356 rm_cmd = "rm -f " + outfile + '.feat'
355- commands .getstatusoutput (rm_cmd )
357+ subprocess .getstatusoutput (rm_cmd )
356358 sys .stderr .write ("[INFO] Running Done!\n " )
357359 return 0
358360 else :
0 commit comments