1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from math import pi
25 from os import sep
26 import sys
27 from tempfile import mkdtemp
28
29
30 from data import Relax_data_store; ds = Relax_data_store()
31 import dep_check
32 from generic_fns.interatomic import interatomic_loop
33 from generic_fns.mol_res_spin import spin_loop
34 from relax_io import test_binary
35 from status import Status; status = Status()
36 from test_suite.system_tests.base_classes import SystemTestCase
37
38
39 -class Dasha(SystemTestCase):
40 """Class for testing various aspects specific to model-free analysis using the program 'Dasha'."""
41
42 - def __init__(self, methodName='runTest'):
43 """Skip the tests if the subprocess module is not available (Python 2.3 and earlier).
44
45 @keyword methodName: The name of the test.
46 @type methodName: str
47 """
48
49
50 super(Dasha, self).__init__(methodName)
51
52
53 if not dep_check.subprocess_module:
54
55 status.skipped_tests.append([methodName, 'subprocess', self._skip_type])
56
57
59 """Set up for all the functional tests."""
60
61
62 self.interpreter.pipe.create('dasha', 'mf')
63
64
65 ds.tmpdir = mkdtemp()
66
67
69 """Test a complete model-free analysis using the program 'Dasha'."""
70
71
72 try:
73 test_binary('dasha')
74 except:
75 return
76
77
78 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'dasha.py')
79
80
81 self.assertEqual(len(cdp.ri_ids), 3)
82 for ri_id in cdp.ri_ids:
83 self.assertEqual(cdp.frq[ri_id], 600000000.0)
84 self.assertEqual(cdp.ri_type['R1_600'], 'R1')
85 self.assertEqual(cdp.ri_type['R2_600'], 'R2')
86 self.assertEqual(cdp.ri_type['NOE_600'], 'NOE')
87
88
89 select = [True, True, False, False]
90 fixed = [False, False, False, False]
91 isotope = ['15N', '15N', '15N', '15N']
92 model = ['m3', 'm3', 'm3', 'm3']
93 equation = ['mf_orig', 'mf_orig', 'mf_orig', 'mf_orig']
94 params = [['s2', 'rex'], ['s2', 'rex'], ['s2', 'rex'], ['s2', 'rex']]
95 s2 = [0.71510, 0.64359, None, None]
96 s2f = [None, None, None, None]
97 s2s = [None, None, None, None]
98 local_tm = [None, None, None, None]
99 te = [None, None, None, None]
100 tf = [None, None, None, None]
101 ts = [None, None, None, None]
102 rex_scale = 1.0 / (2.0 * pi * cdp.frq[cdp.ri_ids[0]]) ** 2
103 rex = [4.32701*rex_scale, 4.29432*rex_scale, None, None]
104 csa = [-172e-6, -172e-6, -172e-6, -172e-6]
105 chi2 = [1.9657, 0.63673, None, None]
106 ri_data = [{'R1_600': 1.0, 'R2_600': 15.0, 'NOE_600': 0.9},
107 {'R1_600': 0.9, 'R2_600': 13.9, 'NOE_600': 0.79},
108 {'R2_600': 12.0, 'NOE_600': 0.6},
109 None]
110 ri_data_err = [{'R1_600': 0.05, 'R2_600': 0.5, 'NOE_600': 0.05},
111 {'R1_600': 0.05, 'R2_600': 0.8, 'NOE_600': 0.05},
112 {'R2_600': 0.5, 'NOE_600': 0.05},
113 None]
114
115
116 i = 0
117 for spin in spin_loop():
118
119 if spin.isotope == '1H':
120 self.assertEqual(spin.select, False)
121 continue
122
123
124 self.assertEqual(spin.select, select[i])
125 self.assertEqual(spin.fixed, fixed[i])
126 self.assertEqual(spin.isotope, isotope[i])
127 self.assertEqual(spin.model, model[i])
128 self.assertEqual(spin.equation, equation[i])
129 self.assertEqual(spin.params, params[i])
130 self.assertEqual(spin.s2, s2[i])
131 self.assertEqual(spin.s2f, s2f[i])
132 self.assertEqual(spin.s2s, s2s[i])
133 self.assertEqual(spin.local_tm, local_tm[i])
134 self.assertEqual(spin.te, te[i])
135 self.assertEqual(spin.tf, tf[i])
136 self.assertEqual(spin.ts, ts[i])
137 self.assertEqual(spin.rex, rex[i])
138 self.assertAlmostEqual(spin.csa, csa[i])
139 self.assertEqual(spin.chi2, chi2[i])
140 if ri_data[i] == None:
141 self.assert_(not hasattr(spin, 'ri_data'))
142 else:
143 for ri_id in cdp.ri_ids:
144 if ri_id in ri_data[i].keys():
145 self.assertEqual(spin.ri_data[ri_id], ri_data[i][ri_id])
146
147
148 i += 1
149
150
151 r = [1.02e-10, 1.02e-10, 1.02e-10, 1.02e-10]
152 i = 0
153 for interatom in interatomic_loop():
154 self.assertAlmostEqual(interatom.r, r[i])
155 i += 1
156