我的脚本是批处理序列的脚本,统计cutoff:
import re
import os
filename = 'test.fas'
directory = '/home/huangle/signalp-4.1/'
filepath = directory + filename
wfilepath = directory + filename+'.out'
pfilepath =directory + filename + '.short_out'
seq ={}#key: 'cazyme_name' value: seq
cutoff ={}#key: 'cazyme_name' value: cutoff
#shell exec
os.system('./signalp -t euk -f short '+ filename +' > ' + pfilepath)
#calculate the length of cazyme
f = open(filepath)
line = f.readline()
lenn = 0
line1 = re.split('\s',line)
line1 = line1[0].split('>')
key = line1[1]
tag =0
while line:
line = f.readline()
if line and line[0] == '>':
seq[key] = lenn
lenn=0
line1 = re.split('\s',line)
line1 = line1[0].split('>')
key = line1[1]
else:
if line:
lenn += len(line)-1
seq[key] = lenn
#print seq
f.close()
#calculate cutoff
f = open(pfilepath)
line = f.readline()
line = f.readline()
line = f.readline()
while line:
line = re.split('\s\s+',line)
key = line[0]
n1 = int(line[2])
n2 = int(line[4])
n3 = int(line[6])
MAX = -1
if(n1>n2):
if(n1>n3):
MAX = n1
else:
MAX = n3
else:
if(n2>n3):
MAX = n2
else:
MAX = n3
cutoff[key] = MAX-1
line = f.readline()
#print cutoff
f.close()
#output
fw =open(wfilepath,'w')
title = "#cazyme_name cayzme_length Cleavage Site\n"
fw.write(title)
for (key,value) in seq.items():
fw.write(key + ' ' + str(value) + ' ' + str(cutoff[key]) + '\n')
fw.close()
print "success"
os.system('gedit ' + wfilepath) |