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 Edward d'Auvergne                                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from os import sep 
 25   
 26  # relax module imports. 
 27  from base_classes import SystemTestCase 
 28  from generic_fns.mol_res_spin import spin_loop 
 29  from status import Status; status = Status() 
 30   
 31   
32 -class Relax_data(SystemTestCase):
33 """Class for testing various aspects specific to relaxation data back calculation.""" 34
35 - def test_back_calc(self):
36 """Test the back calculation of relaxation data from model-free results.""" 37 38 # Load the original state. 39 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') 40 41 # Back calculate the relaxation data. 42 self.interpreter.relax_data.back_calc() 43 44 # The actual data. 45 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}, 46 {'R2_600': 4.7211287713315739, 'R1_500': 2.5267468751446214, 'NOE_500': 0.57703969243842634, 'R2_500': 4.6185111669453738, 'R1_600': 2.2320234021052801, 'NOE_600': 0.66505178335932991}] 47 48 # Loop over the spins. 49 index = 0 50 for spin in spin_loop(): 51 # Check the back calculated data. 52 self.assertEqual(spin.ri_data_bc, ri_data_bc[index]) 53 54 # Increment. 55 index += 1
56 57
58 - def test_back_calc_specific(self):
59 """Test the back calculation of specific relaxation data from model-free results.""" 60 61 # Load the original state. 62 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') 63 64 # Back calculate the relaxation data. 65 self.interpreter.relax_data.back_calc('NOE_500') 66 67 # The actual data. 68 ri_data_bc = [{'NOE_500': 0.51989421750722165}, 69 {'NOE_500': 0.57703969243842634}] 70 71 # Loop over the spins. 72 index = 0 73 for spin in spin_loop(): 74 # Check the back calculated data. 75 self.assertEqual(spin.ri_data_bc, ri_data_bc[index]) 76 77 # Increment. 78 index += 1
79 80
81 - def test_back_calc_new(self):
82 """Test the back calculation of new relaxation data from model-free results.""" 83 84 # Load the original state. 85 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') 86 87 # Back calculate the relaxation data. 88 self.interpreter.relax_data.back_calc('NOE_500.001', ri_type='NOE', frq=500.001e6) 89 90 # The actual data. 91 ri_data_bc = [{'NOE_500.001': 0.52064607759431081}, 92 {'NOE_500.001': 0.57759452179767434}] 93 94 # Loop over the spins. 95 index = 0 96 for spin in spin_loop(): 97 # Check the back calculated data. 98 self.assertEqual(spin.ri_data_bc, ri_data_bc[index]) 99 100 # Increment. 101 index += 1
102 103
104 - def test_delete(self):
105 """Test the relax_data.delete user function, replicating bug #19785.""" 106 107 # Execute the script. 108 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'bug_19785_relax_data_delete.py') 109 110 # Switch to the first pipe. 111 self.interpreter.pipe.switch('delete 1') 112 113 # Checks. 114 self.assertEqual(cdp.ri_ids, ['R1_900', 'NOE_900', 'R1_500', 'R2_500', 'NOE_500']) 115 self.assert_(not cdp.frq.has_key('R2_900')) 116 self.assert_(not cdp.ri_type.has_key('R2_900')) 117 for spin in spin_loop(): 118 self.assert_(not spin.ri_data.has_key('R2_900')) 119 self.assert_(not spin.ri_data_err.has_key('R2_900')) 120 121 # Switch to the second pipe. 122 self.interpreter.pipe.switch('delete 2') 123 124 # Checks. 125 self.assert_(not hasattr(cdp, 'ri_ids')) 126 self.assert_(not hasattr(cdp, 'frq')) 127 self.assert_(not hasattr(cdp, 'ri_type')) 128 for spin in spin_loop(): 129 self.assert_(not hasattr(spin, 'ri_data')) 130 self.assert_(not hasattr(spin, 'ri_data_err'))
131 132
133 - def test_reset(self):
134 """Test the relax_data.frq and relax_data.type user functions to reset the data.""" 135 136 # Execute the script. 137 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'relax_data_reset.py') 138 139 # The data, as it should be. 140 ids = ['R1_900', 'R2_900', 'NOE_900', 'R1_500', 'R2_500', 'NOE_500'] 141 frqs = [900100000, 900100000, 900100000, 400100000, 500*1e6, 500*1e6] 142 types = ['R1', 'R2', 'R2', 'R1', 'R2', 'R2'] 143 144 # Checks. 145 for i in range(len(ids)): 146 self.assertEqual(cdp.ri_ids[i], ids[i]) 147 self.assertAlmostEqual(cdp.frq[ids[i]], frqs[i]) 148 self.assertEqual(cdp.ri_type[ids[i]], types[i])
149