Package test_suite :: Package system_tests :: Module dasha
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.dasha

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008 Sebastien Morin                                          # 
  4  # Copyright (C) 2010-2012 Edward d'Auvergne                                   # 
  5  #                                                                             # 
  6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  7  #                                                                             # 
  8  # This program is free software: you can redistribute it and/or modify        # 
  9  # it under the terms of the GNU General Public License as published by        # 
 10  # the Free Software Foundation, either version 3 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # This program is distributed in the hope that it will be useful,             # 
 14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 16  # GNU General Public License for more details.                                # 
 17  #                                                                             # 
 18  # You should have received a copy of the GNU General Public License           # 
 19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from math import pi 
 25  from os import sep 
 26  import sys 
 27  from tempfile import mkdtemp 
 28   
 29  # relax module imports. 
 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 # Execute the base class method. 50 super(Dasha, self).__init__(methodName) 51 52 # Missing module. 53 if not dep_check.subprocess_module: 54 # Store in the status object. 55 status.skipped_tests.append([methodName, 'subprocess', self._skip_type])
56 57
58 - def setUp(self):
59 """Set up for all the functional tests.""" 60 61 # Create the data pipe. 62 self.interpreter.pipe.create('dasha', 'mf') 63 64 # Create a temporary directory for Dasha outputs. 65 ds.tmpdir = mkdtemp()
66 67
68 - def test_dasha(self):
69 """Test a complete model-free analysis using the program 'Dasha'.""" 70 71 # Test for the presence of the Dasha binary (skip the test if not present). 72 try: 73 test_binary('dasha') 74 except: 75 return 76 77 # Execute the script. 78 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'dasha.py') 79 80 # Check the global data. 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 # The spin data. 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 # Check the spin data. 116 i = 0 117 for spin in spin_loop(): 118 # Protons. 119 if spin.isotope == '1H': 120 self.assertEqual(spin.select, False) 121 continue 122 123 # Check the data. 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 # Increment the spin index. 148 i += 1 149 150 # Check the interatomic data. 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