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