Repository navigation
Expand file tree
/
Copy pathcompare_CASP7_native.py
More file actions
executable file
·121 lines (97 loc) · 3.3 KB
/
Copy pathcompare_CASP7_native.py
File metadata and controls
executable file
·121 lines (97 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/python
from sys import argv,exit
from os import system,popen
from os.path import basename
import string
def Help():
print
print argv[0],' <native pdb> <outfile 1> <outfile 2> ... [<align_extended file>]'
print
print
exit()
if len( argv ) < 2: Help()
trimN = 0
trimC = 0
for i in range(len(argv)):
try:
trimN = int( argv[i] )
del( argv[i] )
break
except:
continue
for i in range(len(argv)):
try:
trimC = int( argv[i] )
del( argv[i] )
break
except:
continue
use_align_file = 0
for i in range(len(argv)):
if argv[i].find( 'align_extended')>0:
align_file = argv[i]
use_align_file = 1
del( argv[i] )
break
maxsubtag ='-ms' # Don't calculate pseudomaxsubs
if argv.count('-maxsub'):
i = argv.index('-maxsub')
del( argv[i] )
maxsubtag = ''
chaintag ='A' # Don't calculate pseudomaxsubs
if argv.count('-chain'):
i = argv.index('-chain')
del( argv[i] )
chaintag = argv[i]
del( argv[i] )
nativepdb = argv[1]
outfiles = argv[2:]
for outfile in outfiles:
if not use_align_file:
nativecoords = nativepdb.replace('.pdb','') + '.coords'
command = 'make_coords_file.py %s %s %s > %s' % (nativepdb,chaintag,outfile,nativecoords)
print(command)
system(command)
command = 'cluster_info_silent.out %s %s %s %s -trimN %d -trimC %d 0,0,0,0 0,0' % (outfile,nativecoords,basename(outfile),maxsubtag,trimN,trimC)
print(command)
system(command)
else: #Oh man this is a pain in the ass....
nativecoords = nativepdb.replace('.pdb','') + '.coords'
if align_file[-3:] == '.gz':
lines = popen('zcat '+align_file).readlines()
else:
lines = open(align_file).readlines()
fastafile = 'temp.'+basename(outfile)+'.fasta'
fid = open(fastafile,'w')
fid.write('>blah\n')
targetsequence = string.split(lines[0])[1]
fid.write( targetsequence+'\n' )
fid.close()
command = 'make_coords_file.py %s A %s > %s' % (nativepdb,fastafile,nativecoords)
print(command)
system(command)
temp_align_file = 'temp.'+basename(outfile)+'.align_extended'
fid = open(temp_align_file,'w')
fid.write('ALIGN '+targetsequence+' NATIVE\n' )
outfile_seq = string.split(popen('head -n 1 '+outfile).readlines()[0]) [-1]
print outfile_seq
for line in lines:
seq = ''
seq_with_dashes = string.split(line)[1]
for char in seq_with_dashes:
if not char == '-': seq+=char
print seq
if seq == outfile_seq:
fid.write( 'ALIGN ' + seq_with_dashes + ' ' + outfile + '\n')
break
fid.close()
command = 'cluster_info_silent.out %s %s %s %s -trimN %d -trimC %d 0,0,0,0 0,0' % (temp_align_file,nativecoords,maxsubtag,basename(outfile),trimN,trimC)
print(command)
system(command)
command = 'rm %s %s ' % (temp_align_file, fastafile)
print(command)
system(command)
if len(maxsubtag) < 1: #Maxsubs were calculated.
command = '/users/rhiju/python/make_new_plot.py %s.contacts -e -nopath' % (basename(outfile))
print(command)
system(command)