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-2013 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  from tempfile import mkdtemp 
 27   
 28  # relax module imports. 
 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 # Execute the base class method. 49 super(Dasha, self).__init__(methodName) 50 51 # Missing module. 52 if not dep_check.subprocess_module: 53 # Store in the status object. 54 status.skipped_tests.append([methodName, 'subprocess', self._skip_type])
55 56
57 - def setUp(self):
58 """Set up for all the functional tests.""" 59 60 # Create the data pipe. 61 self.interpreter.pipe.create('dasha', 'mf') 62 63 # Create a temporary directory for Dasha outputs. 64 ds.tmpdir = mkdtemp()
65 66
67 - def test_dasha(self):
68 """Test a complete model-free analysis using the program 'Dasha'.""" 69 70 # Test for the presence of the Dasha binary (skip the test if not present). 71 try: 72 test_binary('dasha') 73 except: 74 return 75 76 # Execute the script. 77 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'dasha.py') 78 79 # Check the global data. 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 # The spin data. 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 # Check the spin data. 115 i = 0 116 for spin in spin_loop(): 117 # Protons. 118 if spin.isotope == '1H': 119 self.assertEqual(spin.select, False) 120 continue 121 122 # Check the data. 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.assert_(not hasattr(spin, 'ri_data')) 141 else: 142 for ri_id in cdp.ri_ids: 143 if ri_id in ri_data[i].keys(): 144 self.assertEqual(spin.ri_data[ri_id], ri_data[i][ri_id]) 145 146 # Increment the spin index. 147 i += 1 148 149 # Check the interatomic data. 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