-
Notifications
You must be signed in to change notification settings - Fork 17
/
active-passive-to-ambig.py
executable file
·85 lines (66 loc) · 2.42 KB
/
active-passive-to-ambig.py
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
#!/usr/bin/env python
"""
Python script to convert a list of active and passive residues into
ambiguous interaction restraints for HADDOCK
"""
import os, sys, time
import subprocess
import tempfile
def active_passive_to_ambig(active1, passive1, active2, passive2,
segid1='A', segid2='B'):
"""Convert active and passive residues to Ambiguous Interaction Restraints
Parameters
----------
active1 : list
List of active residue numbers of the first segid
passive1 : list
List of passive residue numbers of the first segid
active2 : list
List of active residue numbers of the second segid
active2 : list
List of passive residue numbers of the second segid
segid1 : string
Segid to use for the first model
segid2 : string
Segid to use for the second model
"""
all1 = active1 + passive1
all2 = active2 + passive2
for resi1 in active1:
print('assign (resi {:d} and segid {:s})'.format(resi1, segid1))
print('(')
lines = []
c = 0
for resi2 in all2:
print(' (resi {:d} and segid {:s})'.format(resi2, segid2))
c += 1
if c != len(all2):
print(' or')
# for line in lines:
# print(line)
print(') 2.0 2.0 0.0\n')
for resi2 in active2:
print('assign (resi {:d} and segid {:s})'.format(resi2, segid2))
print('(\n')
lines = []
c = 0
for resi1 in all1:
print(' (resi {:d} and segid {:s})'.format(resi1, segid1))
c += 1
if c != len(all1):
print(' or\n')
# for line in lines:
# print(line)
print(') 2.0 2.0 0.0\n')
def main():
import sys
if len(sys.argv) != 3:
print '\nUsage:\n python active-passive_to_ambig.py <active-passive-file1> <active-passive-file2>\n\n' +\
'where <active-passive-file> is a file consisting of two space-delimited lines with\n' +\
'the first line active residues numbers and the second line passive residue numbers\n'
sys.exit()
active1, passive1 = [[int(x) for x in line.split()] for line in open(sys.argv[1])]
active2, passive2 = [[int(x) for x in line.split()] for line in open(sys.argv[2])]
active_passive_to_ambig(active1, passive1, active2, passive2)
if __name__ == '__main__':
main()