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

Source Code for Module test_suite.system_tests.chemical_shift

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2013 Edward d'Auvergne                                        # 
  4  # Copyright (C) 2013 Troels E. Linnet                                         # 
  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  # Module docstring. 
 24  """The module for the system tests for chemical shift support in relax.""" 
 25   
 26   
 27  # Python module imports. 
 28  from os import sep 
 29   
 30  # relax module imports. 
 31  from pipe_control.mol_res_spin import spin_loop 
 32  from status import Status; status = Status() 
 33  from test_suite.system_tests.base_classes import SystemTestCase 
 34   
 35   
36 -class Chemical_shift(SystemTestCase):
37 """System test class for checking the handling of chemical shifts.""" 38 39
40 - def setUp(self):
41 """Set up for all the system tests.""" 42 43 # Create the data pipe. 44 self.interpreter.pipe.create('cs', 'mf')
45 46
48 """Test the reading of chemical shifts from an NMRPipe seriesTab peak list.""" 49 50 # Read the spins from peak list. 51 self.interpreter.spectrum.read_spins(file="seriesTab.ser", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists') 52 53 # Read the chemical shift from the list. 54 self.interpreter.chemical_shift.read(file="seriesTab.ser", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists') 55 56 # Test the data. 57 cs = [128.374, 127.066, 124.523] 58 i = 0 59 for spin in spin_loop(): 60 # Check the shift. 61 self.assertEqual(spin.chemical_shift, cs[i]) 62 63 # Increment the index. 64 i += 1
65 66
68 """Test the reading of chemical shifts from an NMRPipe seriesTab peak list with multi columns.""" 69 70 # Read the spins from peak list. 71 self.interpreter.spectrum.read_spins(file="seriesTab_multi.ser", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists') 72 73 # Read the chemical shift from the list. 74 self.interpreter.chemical_shift.read(file="seriesTab_multi.ser", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists') 75 76 # Test the data. 77 cs = [115.994, 125.899, 123.001, 120.839, 128.998] 78 i = 0 79 for spin in spin_loop(): 80 # Check the shift. 81 self.assertEqual(spin.chemical_shift, cs[i]) 82 83 # Increment the index. 84 i += 1
85 86
87 - def test_read_nmrview(self):
88 """Test the reading of chemical shifts from an NMRView peak list.""" 89 90 # Create the sequence data, and name the spins. 91 self.interpreter.spin.create(res_num=70, spin_name='N') 92 self.interpreter.spin.create(res_num=70, spin_name='HN') 93 self.interpreter.spin.create(res_num=72, spin_name='N') 94 self.interpreter.spin.create(res_num=72, spin_name='HN') 95 96 # Read the peak list. 97 self.interpreter.chemical_shift.read(file="cNTnC.xpk", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists') 98 99 # Test the data. 100 cs = [116.37241, 10.75274, 126.41302, 9.67752] 101 i = 0 102 for spin in spin_loop(): 103 # Check the shift. 104 self.assertEqual(spin.chemical_shift, cs[i]) 105 106 # Increment the index. 107 i += 1
108 109
110 - def test_read_sparky(self):
111 """Test the reading of chemical shifts from a Sparky peak list.""" 112 113 # Create the sequence data, and name the spins. 114 for res_num in [3, 4, 5, 6, 40]: 115 self.interpreter.spin.create(res_num=res_num, spin_name='N') 116 self.interpreter.spin.create(res_num=res_num, spin_name='HN') 117 self.interpreter.spin.create(res_num=40, spin_name='NE1') 118 self.interpreter.spin.create(res_num=40, spin_name='HE1') 119 120 # Load the peak list. 121 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists' 122 self.interpreter.chemical_shift.read(file='ref_ave.list', dir=path) 123 124 # Test the data. 125 cs = [122.454, 8.397, 111.978, 8.720, 115.069, 8.177, 120.910, 8.813, 123.335, 8.005, 130.204, 10.294] 126 i = 0 127 for spin in spin_loop(): 128 # No data. 129 if i > 12: 130 self.assert_(not hasattr(spin, 'chemical_shift')) 131 132 # Check the shift. 133 self.assertEqual(spin.chemical_shift, cs[i]) 134 135 # Increment the index. 136 i += 1
137 138
139 - def test_read_xeasy(self):
140 """Test the reading of chemical shifts from a XEasy peak list.""" 141 142 # Create the sequence data, and name the spins. 143 for res_num in [21, 96, 104, 110]: 144 self.interpreter.spin.create(res_num=res_num, spin_name='N') 145 self.interpreter.spin.create(res_num=res_num, spin_name='HN') 146 self.interpreter.spin.create(res_num=79, spin_name='NE1') 147 self.interpreter.spin.create(res_num=79, spin_name='HE1') 148 149 # Load the peak list. 150 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists' 151 self.interpreter.chemical_shift.read(file='xeasy_r1_20ms.text', dir=path) 152 153 # Test the data. 154 cs = [134.221, 10.014, 118.450, 8.364, 127.582, 9.211, 129.041, 9.882, 132.592, 10.481] 155 i = 0 156 for spin in spin_loop(): 157 # No data. 158 if i > 10: 159 self.assert_(not hasattr(spin, 'chemical_shift')) 160 161 # Check the shift. 162 self.assertEqual(spin.chemical_shift, cs[i]) 163 164 # Increment the index. 165 i += 1
166