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

Source Code for Module test_suite.system_tests.relax_data

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2011-2013 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from os import sep 
 24   
 25  # relax module imports. 
 26  from pipe_control.mol_res_spin import spin_loop 
 27  from status import Status; status = Status() 
 28  from test_suite.system_tests.base_classes import SystemTestCase 
 29   
 30   
31 -class Relax_data(SystemTestCase):
32 """Class for testing various aspects specific to relaxation data back calculation.""" 33
34 - def test_back_calc(self):
35 """Test the back calculation of relaxation data from model-free results (U{bug #14941<https://web.archive.org/web/https://gna.org/bugs/?14941>}).""" 36 37 # Load the original state. 38 self.interpreter.state.load(state='sphere_trunc', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'bug_14941_local_tm_global_selection') 39 40 # Back calculate the relaxation data. 41 self.interpreter.relax_data.back_calc() 42 43 # The actual data. 44 ri_data_bc = [{'R2_600': 4.7159538829340821, 'R1_500': 2.4779663389365068, 'NOE_500': 0.51989421750722165, 'R2_500': 4.3440970032224548, 'R1_600': 2.2831801922968129, 'NOE_600': 0.63592506242171432}, 45 {'R2_600': 4.7211287713315739, 'R1_500': 2.5267468751446214, 'NOE_500': 0.57703969243842634, 'R2_500': 4.6185111669453738, 'R1_600': 2.2320234021052801, 'NOE_600': 0.66505178335932991}] 46 47 # Loop over the spins. 48 index = 0 49 for spin in spin_loop(): 50 # Skip deselected protons. 51 if not spin.select: 52 continue 53 54 # Check the back calculated data. 55 self.assertEqual(spin.ri_data_bc, ri_data_bc[index]) 56 57 # Increment. 58 index += 1
59 60
61 - def test_back_calc_specific(self):
62 """Test the back calculation of specific relaxation data from model-free results (U{bug #14941<https://web.archive.org/web/https://gna.org/bugs/?14941>}).""" 63 64 # Load the original state. 65 self.interpreter.state.load(state='sphere_trunc', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'bug_14941_local_tm_global_selection') 66 67 # Back calculate the relaxation data. 68 self.interpreter.relax_data.back_calc('NOE_500') 69 70 # The actual data. 71 ri_data_bc = [{'NOE_500': 0.51989421750722165}, 72 {'NOE_500': 0.57703969243842634}] 73 74 # Loop over the spins. 75 index = 0 76 for spin in spin_loop(): 77 # Skip deselected protons. 78 if not spin.select: 79 continue 80 81 # Check the back calculated data. 82 self.assertEqual(spin.ri_data_bc, ri_data_bc[index]) 83 84 # Increment. 85 index += 1
86 87
88 - def test_back_calc_new(self):
89 """Test the back calculation of new relaxation data from model-free results (U{bug #14941<https://web.archive.org/web/https://gna.org/bugs/?14941>}).""" 90 91 # Load the original state. 92 self.interpreter.state.load(state='sphere_trunc', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'bug_14941_local_tm_global_selection') 93 94 # Back calculate the relaxation data. 95 self.interpreter.relax_data.back_calc('NOE_500.001', ri_type='NOE', frq=500.001e6) 96 97 # The actual data. 98 ri_data_bc = [{'NOE_500.001': 0.52064607759431081}, 99 {'NOE_500.001': 0.57759452179767434}] 100 101 # Loop over the spins. 102 index = 0 103 for spin in spin_loop(): 104 # Skip deselected protons. 105 if not spin.select: 106 continue 107 108 # Check the back calculated data. 109 self.assertEqual(spin.ri_data_bc, ri_data_bc[index]) 110 111 # Increment. 112 index += 1
113 114
115 - def test_delete(self):
116 """Test the relax_data.delete user function, replicating U{bug #19785<https://web.archive.org/web/https://gna.org/bugs/?19785>}.""" 117 118 # Execute the script. 119 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'bug_19785_relax_data_delete.py') 120 121 # Switch to the first pipe. 122 self.interpreter.pipe.switch('delete 1') 123 124 # Checks. 125 self.assertEqual(cdp.ri_ids, ['R1_900', 'NOE_900', 'R1_500', 'R2_500', 'NOE_500']) 126 self.assert_(not 'R2_900' in cdp.spectrometer_frq) 127 self.assert_(not 'R2_900' in cdp.ri_type) 128 for spin in spin_loop(): 129 # Protons. 130 if spin.name in ['H', 'HE1']: 131 self.assert_(not hasattr(spin, 'ri_data')) 132 133 # Nitrogens. 134 else: 135 self.assert_(not 'R2_900' in spin.ri_data) 136 self.assert_(not 'R2_900' in spin.ri_data_err) 137 138 # Switch to the second pipe. 139 self.interpreter.pipe.switch('delete 2') 140 141 # Checks. 142 self.assert_(not hasattr(cdp, 'ri_ids')) 143 self.assert_(not hasattr(cdp, 'spectrometer_frq')) 144 self.assert_(not hasattr(cdp, 'ri_type')) 145 for spin in spin_loop(): 146 self.assert_(not hasattr(spin, 'ri_data')) 147 self.assert_(not hasattr(spin, 'ri_data_err'))
148 149
150 - def test_reset(self):
151 """Test the relax_data.frq and relax_data.type user functions to reset the data.""" 152 153 # Execute the script. 154 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_data_reset.py') 155 156 # The data, as it should be. 157 ids = ['R1_900', 'R2_900', 'NOE_900', 'R1_500', 'R2_500', 'NOE_500'] 158 frqs = [900100000, 900100000, 900100000, 400100000, 500*1e6, 500*1e6] 159 types = ['R1', 'R2', 'R2', 'R1', 'R2', 'R2'] 160 161 # Checks. 162 for i in range(len(ids)): 163 self.assertEqual(cdp.ri_ids[i], ids[i]) 164 self.assertAlmostEqual(cdp.spectrometer_frq[ids[i]], frqs[i]) 165 self.assertEqual(cdp.ri_type[ids[i]], types[i])
166