diff --git a/bin/CPC2.py b/bin/CPC2.py index 2f01605..1ba9a75 100755 --- a/bin/CPC2.py +++ b/bin/CPC2.py @@ -5,14 +5,13 @@ import sys import os import re -import commands +import subprocess import time from optparse import OptionParser,OptionGroup - +import six import numpy as np from Bio.Seq import Seq from Bio.SeqUtils import ProtParam - import seqio def __main(): @@ -85,7 +84,7 @@ def find_longest_in_one(self,myframe,direction,start_codon,stop_codon): ''' while True: try: - codon,index = triplet_got.next() + codon,index = next(triplet_got) except StopIteration: break 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): end_extension = False while True: try: - codon,index = triplet_got.next() + codon,index = next(triplet_got) except StopIteration: end_extension = True integrity = -1 @@ -252,9 +251,12 @@ def calculate_potential(fasta,strand,output_orf,outfile): ''' strinfoAmbiguous = re.compile("X|B|Z|J|U",re.I) ptU = re.compile("U",re.I) - ftmp_feat = file(outfile + ".feat","w") - ftmp_svm = file(outfile + ".tmp.1","w") - ftmp_result = file(outfile,"w") +## merged by Yang Ding on 2019-11-23 +## 1. all python 2-"file"'s are replaced with python 3-"open"'s +## 2. keep kangyj's check on output_orf + ftmp_feat = open(outfile + ".feat","w") + ftmp_svm = open(outfile + ".tmp.1","w") + ftmp_result = open(outfile,"w") if output_orf == 1: my_header = ["#ID","transcript_length","peptide_length","Fickett_score","pI","ORF_integrity","ORF_Start","coding_probability","label"] else: @@ -315,7 +317,7 @@ 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) = commands.getstatusoutput(cmd) + (exitstatus, outtext) = subprocess.getstatusoutput(cmd) '''deal with the output''' #print outfile + '.tmp.out' @@ -352,7 +354,7 @@ 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' - commands.getstatusoutput(rm_cmd) + subprocess.getstatusoutput(rm_cmd) sys.stderr.write("[INFO] Running Done!\n") return 0 else: diff --git a/bin/compress.py b/bin/compress.py index cc63d33..76127fe 100644 --- a/bin/compress.py +++ b/bin/compress.py @@ -11,7 +11,7 @@ def gz_file(fq_file,mode,level=6): fq_fp = gzip.open(fq_file,mode+"b",level) else: sys.stderr.write("[INFO] read file '%s'\n"%fq_file) - fq_fp = file(fq_file,mode) + fq_fp = open(fq_file,mode) except: sys.stderr.write("Error: Fail to IO file: %s\n"%(fq_file)) sys.exit(1) diff --git a/bin/seqio.py b/bin/seqio.py index 88a920f..d5f9097 100644 --- a/bin/seqio.py +++ b/bin/seqio.py @@ -162,8 +162,8 @@ def gtf_parse(fn,add="chr"): if __name__ == "__main__": a = [[1,10],[17,22],[40,44],[42,47],[46,100],[101,408]] - print a - print merge_region(a) + print (a) + print (merge_region(a))