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

Source Code for Module test_suite.system_tests.consistency_tests

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006 Chris MacRaild                                           # 
  4  # Copyright (C) 2007-2008 Sebastien Morin                                     # 
  5  # Copyright (C) 2010-2012 Edward d'Auvergne                                   # 
  6  #                                                                             # 
  7  # This file is part of the program relax.                                     # 
  8  #                                                                             # 
  9  # relax is free software; you can redistribute it and/or modify               # 
 10  # it under the terms of the GNU General Public License as published by        # 
 11  # the Free Software Foundation; either version 2 of the License, or           # 
 12  # (at your option) any later version.                                         # 
 13  #                                                                             # 
 14  # relax is distributed in the hope that it will be useful,                    # 
 15  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 16  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 17  # GNU General Public License for more details.                                # 
 18  #                                                                             # 
 19  # You should have received a copy of the GNU General Public License           # 
 20  # along with relax; if not, write to the Free Software                        # 
 21  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 22  #                                                                             # 
 23  ############################################################################### 
 24   
 25  # Python module imports. 
 26  from os import sep 
 27  import sys 
 28   
 29  # relax module imports. 
 30  from base_classes import SystemTestCase 
 31  from data import Relax_data_store; ds = Relax_data_store() 
 32  from generic_fns.mol_res_spin import residue_loop 
 33  from physical_constants import N15_CSA, NH_BOND_LENGTH 
 34  from status import Status; status = Status() 
 35   
 36   
37 -class Ct(SystemTestCase):
38 """Class for testing various aspects specific to consistency testing.""" 39 40
41 - def setUp(self):
42 """Set up for all the functional tests.""" 43 44 # Create the data pipe. 45 self.interpreter.pipe.create('ct', 'ct')
46 47
48 - def test_calc(self):
49 """The consistency testing calculation test.""" 50 51 # Data directory. 52 dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'jw_mapping'+sep 53 54 # The data. 55 ri_ids = ['NOE_600', 'R1_600', 'R2_600'] 56 ri_type = ['NOE', 'R1', 'R2'] 57 frq = [600e6]*3 58 data_paths = [dir + 'noe.dat', dir + 'R1.dat', dir + 'R2.dat'] 59 60 # Correct consistency functions values: 61 j0 = [4.0703318681008998e-09, 3.7739393907014834e-09] 62 f_eta = [0.20413244790407614, 0.18898977395296815] 63 f_r2 = [2.0482909381655862e-09, 1.8998154021753067e-09] 64 65 # Read the sequence. 66 self.interpreter.sequence.read(file='test_seq', dir=status.install_path + sep+'test_suite'+sep+'shared_data', res_num_col=1, res_name_col=2) 67 68 # Read the data. 69 for i in xrange(len(ri_ids)): 70 self.interpreter.relax_data.read(ri_id=ri_ids[i], ri_type=ri_type[i], frq=frq[i], file=data_paths[i], res_num_col=1, res_name_col=2, data_col=3, error_col=4) 71 72 # Set r, csa, heteronucleus type, and proton type. 73 self.interpreter.value.set(NH_BOND_LENGTH, 'r') 74 self.interpreter.value.set(N15_CSA, 'csa') 75 self.interpreter.value.set('15N', 'heteronuc_type') 76 self.interpreter.value.set('1H', 'proton_type') 77 78 # Set the angle between the 15N-1H vector and the principal axis of the 15N chemical shift tensor 79 self.interpreter.value.set(15.7, 'orientation') 80 81 # Set the approximate correlation time. 82 self.interpreter.value.set(13 * 1e-9, 'tc') 83 84 # Select the frequency. 85 self.interpreter.consistency_tests.set_frq(frq=600.0 * 1e6) 86 87 # Try the consistency testing. 88 self.interpreter.calc() 89 90 # Loop over residues. 91 index = 0 92 for res in residue_loop(): 93 # Residues -2 and -1 have data. 94 if res.num == -2 or res.num == -1: 95 self.assert_(res.spin[0].select) 96 self.assertAlmostEqual(res.spin[0].j0, j0[index]) 97 self.assertAlmostEqual(res.spin[0].f_eta, f_eta[index]) 98 self.assertAlmostEqual(res.spin[0].f_r2, f_r2[index]) 99 index = index + 1 100 101 # Other residues have insufficient data. 102 else: 103 self.assert_(not res.spin[0].select)
104 105
106 - def test_set_value(self):
107 """The user function value.set().""" 108 109 # Read the sequence. 110 self.interpreter.sequence.read(file='test_seq', dir=status.install_path + sep+'test_suite'+sep+'shared_data', res_num_col=1, res_name_col=2) 111 112 # Try to set the values. 113 bond_length = NH_BOND_LENGTH 114 csa = N15_CSA 115 self.interpreter.value.set(bond_length, 'r') 116 self.interpreter.value.set(csa, 'csa') 117 118 # Loop over residues. 119 for res in residue_loop(): 120 self.assertEqual(res.spin[0].r, NH_BOND_LENGTH) 121 self.assertEqual(res.spin[0].csa, N15_CSA)
122 123
124 - def test_consistency(self):
125 """Test a complete consistency tests run using a script.""" 126 127 # Execute the script. 128 self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'consistency_tests.py')
129