-
Notifications
You must be signed in to change notification settings - Fork 667
/
Copy pathtest_nuclinfo.py
241 lines (209 loc) · 6.41 KB
/
test_nuclinfo.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8
#
# MDAnalysis --- https://www.mdanalysis.org
# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors
# (see the file AUTHORS for the full list of names)
#
# Released under the Lesser GNU Public Licence, v2.1 or any higher version
#
# Please cite your use of MDAnalysis in published work:
#
# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler,
# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein.
# MDAnalysis: A Python package for the rapid analysis of molecular dynamics
# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th
# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy.
# doi: 10.25080/majora-629e541a-00e
#
# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein.
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations.
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
import MDAnalysis as mda
import pytest
from MDAnalysis.analysis import nuclinfo
from MDAnalysisTests.datafiles import RNA_PSF, RNA_PDB
from numpy.testing import (
assert_almost_equal,
assert_allclose,
)
@pytest.fixture(scope="module")
def u():
return mda.Universe(RNA_PSF, RNA_PDB)
@pytest.mark.parametrize(
"i, bp, seg1, seg2, expected_value",
(
(1, 2, "RNAA", "RNAA", 4.3874702),
(22, 23, "RNAA", "RNAA", 4.1716404),
),
)
def test_wc_pair(u, i, bp, seg1, seg2, expected_value):
val = nuclinfo.wc_pair(u, i, bp, seg1=seg1, seg2=seg2)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"i, bp, seg1, seg2, expected_value",
(
(3, 17, "RNAA", "RNAA", 15.06506),
(20, 5, "RNAA", "RNAA", 3.219116),
),
)
def test_minor_pair(u, i, bp, seg1, seg2, expected_value):
val = nuclinfo.minor_pair(u, i, bp, seg1=seg1, seg2=seg2)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"i, bp, seg1, seg2, expected_value",
(
(2, 12, "RNAA", "RNAA", 26.884272),
(5, 9, "RNAA", "RNAA", 13.578535),
),
)
def test_major_pair(u, i, bp, seg1, seg2, expected_value):
val = nuclinfo.major_pair(u, i, bp, seg1=seg1, seg2=seg2)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 9, 3.16497),
("RNAA", 21, 22.07721),
),
)
def test_phase_cp(u, seg, i, expected_value):
val = nuclinfo.phase_cp(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 1, 359.57580),
("RNAA", 11, 171.71645),
),
)
def test_phase_as(u, seg, i, expected_value):
val = nuclinfo.phase_as(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
(
"RNAA",
5,
[
302.203802,
179.043077,
35.271411,
79.499729,
201.000393,
282.14321,
210.709327,
],
),
(
"RNAA",
21,
[
280.388619,
185.12919,
56.616215,
64.87354,
187.153367,
279.340915,
215.332144,
],
),
),
)
def test_tors(u, seg, i, expected_value):
val = nuclinfo.tors(u, seg=seg, i=i)
assert_allclose(val, expected_value, rtol=1e-03)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 6, 279.15103),
("RNAA", 18, 298.09936),
),
)
def test_tors_alpha(u, seg, i, expected_value):
val = nuclinfo.tors_alpha(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 7, 184.20501),
("RNAA", 15, 169.70042),
),
)
def test_tors_beta(u, seg, i, expected_value):
val = nuclinfo.tors_beta(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 7, 52.72022),
("RNAA", 15, 54.59684),
),
)
def test_tors_gamma(u, seg, i, expected_value):
val = nuclinfo.tors_gamma(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 7, 84.80554),
("RNAA", 15, 82.00043),
),
)
def test_tors_delta(u, seg, i, expected_value):
val = nuclinfo.tors_delta(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 7, 200.40990),
("RNAA", 15, 210.96953),
),
)
def test_tors_eps(u, seg, i, expected_value):
val = nuclinfo.tors_eps(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value", (("RNAA", 7, 297.84736), ("RNAA", 15, 330.24898))
)
def test_tors_zeta(u, seg, i, expected_value):
val = nuclinfo.tors_zeta(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 1, 178.37435),
("RNAA", 2, 202.03418),
("RNAA", 7, 200.91674),
("RNAA", 15, 209.32109),
),
)
def test_tors_chi(u, seg, i, expected_value):
val = nuclinfo.tors_chi(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"seg, i, expected_value",
(
("RNAA", 20, 103.07024),
("RNAA", 5, 156.62223),
("RNAA", 7, 77.94538),
("RNAA", 15, 130.18539),
),
)
def test_hydroxyl(u, seg, i, expected_value):
val = nuclinfo.hydroxyl(u, seg=seg, i=i)
assert_almost_equal(val, expected_value, decimal=3)
@pytest.mark.parametrize(
"bp1, bp2, i, seg1, seg2, seg3, expected_value",
(
(16, 2, 3, "RNAA", "RNAA", "RNAA", 314.69804),
(8, 9, 10, "RNAA", "RNAA", "RNAA", 34.50106),
),
)
def test_pseudo_dihe_baseflip(
u, bp1, bp2, i, seg1, seg2, seg3, expected_value
):
val = nuclinfo.pseudo_dihe_baseflip(u, bp1, bp2, i, seg1, seg2, seg3)
assert_almost_equal(val, expected_value, decimal=3)