1
|
4
|
import logging
|
2
|
|
|
3
|
4
|
from paprika.restraints.utils import get_restraint_values, parse_window
|
4
|
|
|
5
|
4
|
logger = logging.getLogger(__name__)
|
6
|
|
|
7
|
|
|
8
|
4
|
def amber_restraint_line(restraint, window):
|
9
|
|
"""Writes an AMBER NMR-style restraint line for a specific window.
|
10
|
|
|
11
|
|
Parameters
|
12
|
|
----------
|
13
|
|
restraint: :class:`paprika.restraints.DAT_restraint`
|
14
|
|
The pAPRika restraint to be used.
|
15
|
|
window: str
|
16
|
|
The calculation window that will be used to index the restraint values.
|
17
|
|
|
18
|
|
Returns
|
19
|
|
-------
|
20
|
|
string: str
|
21
|
|
A string that can be written to a file that can be read by AMBER.
|
22
|
|
|
23
|
|
Examples
|
24
|
|
--------
|
25
|
|
|
26
|
|
.. code-block::
|
27
|
|
|
28
|
|
&rst iat= 3,109, r1= 0.0000, r2= 6.9665, r3= 6.9665, r4= 999.0000,
|
29
|
|
rk2= 5.0000000, rk3= 5.0000000, &end
|
30
|
|
|
31
|
|
Or:
|
32
|
|
|
33
|
|
.. code-block::
|
34
|
|
|
35
|
|
&rst iat= -1,-1, igr1=3,4,7,8,21,22,25,26,39,40,43,44,57,58,61,62,75,76,79,
|
36
|
|
80,93,94,97,98, igr2=109,113,115,119,
|
37
|
|
r1= 0.0000, r2= 5.9665, r3= 5.9665, r4= 999.0000,
|
38
|
|
rk2= 5.0000000, rk3= 5.0000000, &end
|
39
|
|
|
40
|
|
"""
|
41
|
|
|
42
|
4
|
window, phase = parse_window(window)
|
43
|
4
|
if (
|
44
|
|
restraint.phase[phase]["force_constants"] is None
|
45
|
|
and restraint.phase[phase]["targets"] is None
|
46
|
|
):
|
47
|
0
|
return ""
|
48
|
|
|
49
|
4
|
if not restraint.group1:
|
50
|
4
|
iat1 = "{},".format(restraint.index1[0])
|
51
|
|
else:
|
52
|
0
|
iat1 = "-1,"
|
53
|
0
|
igr1 = ""
|
54
|
0
|
for index in restraint.index1:
|
55
|
0
|
igr1 += "{},".format(index)
|
56
|
|
|
57
|
4
|
if not restraint.group2:
|
58
|
4
|
iat2 = "{},".format(restraint.index2[0])
|
59
|
|
else:
|
60
|
0
|
iat2 = "-1,"
|
61
|
0
|
igr2 = ""
|
62
|
0
|
for index in restraint.index2:
|
63
|
0
|
igr2 += "{},".format(index)
|
64
|
|
|
65
|
4
|
iat3 = ""
|
66
|
4
|
if restraint.index3 and not restraint.group3:
|
67
|
0
|
iat3 = "{},".format(restraint.index3[0])
|
68
|
4
|
elif restraint.group3:
|
69
|
0
|
iat3 = "-1,"
|
70
|
0
|
igr3 = ""
|
71
|
0
|
for index in restraint.index3:
|
72
|
0
|
igr3 += "{},".format(index)
|
73
|
|
|
74
|
4
|
iat4 = ""
|
75
|
4
|
if restraint.index4 and not restraint.group4:
|
76
|
0
|
iat4 = "{},".format(restraint.index4[0])
|
77
|
4
|
elif restraint.group4:
|
78
|
0
|
iat4 = "-1,"
|
79
|
0
|
igr4 = ""
|
80
|
0
|
for index in restraint.index4:
|
81
|
0
|
igr4 += "{},".format(index)
|
82
|
|
|
83
|
|
# Restraint values - Amber NMR-style
|
84
|
4
|
amber_restraint_values = get_restraint_values(restraint, phase, window)
|
85
|
|
|
86
|
|
# Prepare AMBER NMR-style restraint
|
87
|
4
|
atoms = "".join([iat1, iat2, iat3, iat4])
|
88
|
4
|
string = "&rst iat= {:16s} ".format(atoms)
|
89
|
4
|
string += (
|
90
|
|
" r1= {0:10.5f},".format(amber_restraint_values["r1"])
|
91
|
|
+ " r2= {0:10.5f},".format(amber_restraint_values["r2"])
|
92
|
|
+ " r3= {0:10.5f},".format(amber_restraint_values["r3"])
|
93
|
|
+ " r4= {0:10.5f},".format(amber_restraint_values["r4"])
|
94
|
|
+ " rk2= {0:10.5f},".format(amber_restraint_values["rk2"])
|
95
|
|
+ " rk3= {0:10.5f},".format(amber_restraint_values["rk3"])
|
96
|
|
)
|
97
|
|
|
98
|
4
|
if any([restraint.group1, restraint.group2, restraint.group3, restraint.group4]):
|
99
|
0
|
string += "\n "
|
100
|
0
|
if restraint.group1:
|
101
|
0
|
string += " igr1= {}".format(igr1)
|
102
|
0
|
if restraint.group2:
|
103
|
0
|
string += " igr2= {}".format(igr2)
|
104
|
0
|
if restraint.group3:
|
105
|
0
|
string += " igr3= {}".format(igr3)
|
106
|
0
|
if restraint.group4:
|
107
|
0
|
string += " igr4= {}".format(igr4)
|
108
|
|
|
109
|
4
|
string += " &end\n"
|
110
|
4
|
return string
|