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

Source Code for Module test_suite.system_tests.peak_lists

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2013 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2008 Sebastien Morin                                          # 
  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 os import sep 
 25   
 26  # relax module imports. 
 27  from data import Relax_data_store; ds = Relax_data_store() 
 28  import dep_check 
 29  from generic_fns.mol_res_spin import spin_loop 
 30  from status import Status; status = Status() 
 31  from test_suite.system_tests.base_classes import SystemTestCase 
 32   
 33   
34 -class Peak_lists(SystemTestCase):
35 """TestCase class for the functional tests for the support of different peak intensity files.""" 36
37 - def __init__(self, methodName='runTest'):
38 """Skip the tests if the C modules are non-functional. 39 40 @keyword methodName: The name of the test. 41 @type methodName: str 42 """ 43 44 # Execute the base class method. 45 super(Peak_lists, self).__init__(methodName) 46 47 # Missing module. 48 if not dep_check.C_module_exp_fn and methodName in ['test_bug_17276_peak_lists', 'test_ccpn_analysis']: 49 # Store in the status object. 50 status.skipped_tests.append([methodName, 'Relax curve-fitting C module', self._skip_type])
51 52
53 - def setUp(self):
54 """Set up for all the functional tests.""" 55 56 # Create a data pipe. 57 self.interpreter.pipe.create('mf', 'mf')
58 59
61 """Test catching U{bug #17276<https://web.archive.org/web/https://gna.org/bugs/?17276>}, the duplicated peak list reading failure submitted by Leanne Minall.""" 62 63 # Execute the script. 64 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'bug_17276_peak_lists.py')
65 66
67 - def test_ccpn_analysis(self):
68 """Test U{bug #17341<https://web.archive.org/web/https://gna.org/bugs/index.php?17341>}, the CCPN Analysis 2.1 peak list reading submitted by Madeleine Strickland.""" 69 70 # Execute the script. 71 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'peak_lists'+sep+'ccpn_analysis.py') 72 73 # Spectrum names. 74 names = ['T1A_0010', 'T1A_0020', 'T1A_0030', 'T1A_0050', 'T1A_0070', 'T1A_0100', 'T1A_0150', 'T1A_0200', 'T1A_0300', 'T1A_0400', 'T1A_0600', 'T1A_0800', 'T1A_1000', 'T1A_1200'] 75 76 # Relaxation times (in seconds). 77 times = [0.01, 0.02, 0.03, 0.05, 0.07, 0.1, 0.15, 0.2, 0.3, 0.4, 0.6, 0.8, 1.0, 1.2] 78 79 # Check the spectrum IDs and relaxation times. 80 for i in range(len(times)): 81 self.assertEqual(cdp.spectrum_ids[i], names[i]) 82 self.assertEqual(cdp.relax_times[names[i]], times[i]) 83 84 # The peak heights. 85 heights = [ 86 [1.41e06, 1.33e06, 1.31e06, 1.31e06, 1.28e06, 1.20e06, 1.18e06, 1.07e06, 9.70e05, 8.47e05, 7.00e05, 5.25e05, 4.23e05, 3.10e05], 87 [1.79e06, 1.76e06, 1.71e06, 1.70e06, 1.66e06, 1.56e06, 1.51e06, 1.41e06, 1.24e06, 1.11e06, 8.43e05, 6.79e05, 5.04e05, 4.18e05] 88 ] 89 90 # Check the heights. 91 for spin, mol_name, res_num, res_name in spin_loop(full_info=True): 92 # The data. 93 if res_num == 1501: 94 index = 0 95 elif res_num == 1504: 96 index = 1 97 98 # No data. 99 else: 100 # There should be no intensity data. 101 self.assert_(not hasattr(spin, 'intensities')) 102 103 # Do not perform the height checks. 104 continue 105 106 # Check the data. 107 self.assert_(hasattr(spin, 'intensities')) 108 109 # Check the values. 110 for i in range(len(times)): 111 self.assertEqual(spin.intensities[names[i]], heights[index][i])
112 113
115 """Test the reading of a generic peak intensity list.""" 116 117 # Create the sequence data, and name the spins. 118 self.interpreter.residue.create(20, 'GLY') 119 self.interpreter.residue.create(23, 'ALA') 120 self.interpreter.residue.create(34, 'CYS') 121 self.interpreter.residue.create(35, 'MET') 122 self.interpreter.residue.create(36, 'LYS') 123 self.interpreter.spin.name(name='N') 124 125 # Relaxation delays. 126 delays = [0.0109016, 127 0.0218032, 128 0.0436064, 129 0.0436064, 130 0.0872128, 131 0.1744260, 132 0.3488510, 133 0.6977020, 134 1.3954000, 135 1.9949900] 136 137 # Load the data. 138 for i in range(10): 139 # Read the peak intensities. 140 self.interpreter.spectrum.read_intensities(file="generic_intensity.txt", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id=repr(i), int_method='height', int_col=i+3, res_num_col=1, res_name_col=2) 141 142 # Set the relaxation times. 143 self.interpreter.relax_fit.relax_time(time=delays[i], spectrum_id=repr(i)) 144 145 # The actual intensities. 146 heights = [[1.0000, 0.9714, 0.9602, 0.9626, 0.8839, 0.8327, 0.7088, 0.5098, 0.2410, 0.1116], 147 [1.0000, 0.9789, 0.9751, 0.9762, 0.9074, 0.8532, 0.7089, 0.5170, 0.2444, 0.1537], 148 [1.0000, 0.9659, 0.9580, 0.9559, 0.9325, 0.8460, 0.7187, 0.5303, 0.2954, 0.1683], 149 [1.0000, 0.9657, 0.9389, 0.9366, 0.9331, 0.8683, 0.7169, 0.5357, 0.2769, 0.1625], 150 [1.0000, 1.0060, 0.9556, 0.9456, 0.9077, 0.8411, 0.6788, 0.4558, 0.2448, 0.1569] 151 ] 152 153 # Test the data. 154 for i in range(10): 155 for j in range(5): 156 self.assertEqual(cdp.mol[0].res[j].spin[0].intensities[repr(i)], heights[j][i])
157 158
160 """Test the reading of an NMRView peak list.""" 161 162 # Create the sequence data, and name the spins. 163 self.interpreter.residue.create(70) 164 self.interpreter.residue.create(72) 165 self.interpreter.spin.name(name='N') 166 167 # Read the peak list. 168 self.interpreter.spectrum.read_intensities(file="cNTnC.xpk", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id='test', int_method='height') 169 170 # Test the data. 171 self.assertEqual(list(cdp.mol[0].res[0].spin[0].intensities.values())[0], -0.1694) 172 self.assertEqual(list(cdp.mol[0].res[1].spin[0].intensities.values())[0], -0.1142)
173 174
176 """Test the reading of an Sparky peak list.""" 177 178 # Create the sequence data, and name the spins. 179 self.interpreter.residue.create(3) 180 self.interpreter.residue.create(4) 181 self.interpreter.residue.create(5) 182 self.interpreter.residue.create(6) 183 self.interpreter.spin.name(name='N') 184 185 # Read the peak list. 186 self.interpreter.spectrum.read_intensities(file="ref_ave.list", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id='test', int_method='height') 187 188 # Test the data. 189 self.assertEqual(list(cdp.mol[0].res[0].spin[0].intensities.values())[0], 6262) 190 self.assertEqual(list(cdp.mol[0].res[1].spin[0].intensities.values())[0], 148614) 191 self.assertEqual(list(cdp.mol[0].res[2].spin[0].intensities.values())[0], 166842) 192 self.assertEqual(list(cdp.mol[0].res[3].spin[0].intensities.values())[0], 128690)
193 194
196 """Test the reading of an XEasy peak list.""" 197 198 # Create the sequence data, and name the spins. 199 self.interpreter.residue.create(15) 200 self.interpreter.residue.create(21) 201 self.interpreter.residue.create(22) 202 self.interpreter.residue.create(29) 203 self.interpreter.residue.create(52) 204 self.interpreter.residue.create(69) 205 self.interpreter.residue.create(70) 206 self.interpreter.residue.create(73) 207 self.interpreter.residue.create(79) 208 self.interpreter.residue.create(84) 209 self.interpreter.residue.create(87) 210 self.interpreter.residue.create(95) 211 self.interpreter.residue.create(96) 212 self.interpreter.residue.create(100) 213 self.interpreter.residue.create(104) 214 self.interpreter.residue.create(107) 215 self.interpreter.residue.create(110) 216 self.interpreter.residue.create(112) 217 self.interpreter.residue.create(120) 218 self.interpreter.residue.create(141) 219 self.interpreter.residue.create(165) 220 self.interpreter.spin.name(name='N') 221 222 # Read the peak list. 223 self.interpreter.spectrum.read_intensities(file="xeasy_r1_20ms.text", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id='test', int_method='height') 224 225 # Test the data. 226 self.assertEqual(list(cdp.mol[0].res[ 0].spin[0].intensities.values())[0], 9.714e+03) 227 self.assertEqual(list(cdp.mol[0].res[ 1].spin[0].intensities.values())[0], 7.919e+03) 228 self.assertEqual(list(cdp.mol[0].res[ 2].spin[0].intensities.values())[0], 1.356e+04) 229 self.assertEqual(list(cdp.mol[0].res[ 3].spin[0].intensities.values())[0], 9.884e+03) 230 self.assertEqual(list(cdp.mol[0].res[ 4].spin[0].intensities.values())[0], 2.041e+04) 231 self.assertEqual(list(cdp.mol[0].res[ 5].spin[0].intensities.values())[0], 9.305e+03) 232 self.assertEqual(list(cdp.mol[0].res[ 6].spin[0].intensities.values())[0], 3.154e+04) 233 self.assertEqual(list(cdp.mol[0].res[ 7].spin[0].intensities.values())[0], 9.180e+03) 234 self.assertEqual(list(cdp.mol[0].res[ 9].spin[0].intensities.values())[0], 1.104e+04) 235 self.assertEqual(list(cdp.mol[0].res[10].spin[0].intensities.values())[0], 7.680e+03) 236 self.assertEqual(list(cdp.mol[0].res[11].spin[0].intensities.values())[0], 5.206e+03) 237 self.assertEqual(list(cdp.mol[0].res[12].spin[0].intensities.values())[0], 2.863e+04) 238 self.assertEqual(list(cdp.mol[0].res[14].spin[0].intensities.values())[0], 9.271e+03) 239 self.assertEqual(list(cdp.mol[0].res[15].spin[0].intensities.values())[0], 7.919e+03) 240 self.assertEqual(list(cdp.mol[0].res[16].spin[0].intensities.values())[0], 9.962e+03) 241 self.assertEqual(list(cdp.mol[0].res[17].spin[0].intensities.values())[0], 1.260e+04) 242 self.assertEqual(list(cdp.mol[0].res[18].spin[0].intensities.values())[0], 1.545e+04) 243 self.assertEqual(list(cdp.mol[0].res[19].spin[0].intensities.values())[0], 1.963e+04) 244 self.assertEqual(list(cdp.mol[0].res[20].spin[0].intensities.values())[0], 1.918e+04)
245 246
248 """Test the reading of an XEasy peak list (2).""" 249 250 # Create the sequence data, and name the spins. 251 self.interpreter.residue.create(79) 252 self.interpreter.spin.name(name='NE1') 253 254 # Read the peak list. 255 self.interpreter.spectrum.read_intensities(file="xeasy_r1_20ms.text", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id='test', heteronuc='NE1', proton='HE1', int_method='height') 256 257 # Test the data. 258 self.assertEqual(list(cdp.mol[0].res[0].spin[0].intensities.values())[0], 1.532e+04)
259 260
262 """Test the reading of an XEasy peak list (3).""" 263 264 # Create the sequence data, and name the spins. 265 self.interpreter.residue.create(100) 266 self.interpreter.spin.name(name='C') 267 268 # Read the peak list. 269 self.interpreter.spectrum.read_intensities(file="xeasy_r1_20ms.text", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id='test', heteronuc='C', int_method='height') 270 271 # Test the data. 272 self.assertEqual(list(cdp.mol[0].res[0].spin[0].intensities.values())[0], 6.877e+03)
273 274
276 """Test the reading of an XEasy peak list (4).""" 277 278 # Create the sequence data, and name the spins. 279 self.interpreter.residue.create(107) 280 self.interpreter.spin.name(name='C') 281 282 # Read the peak list. 283 self.interpreter.spectrum.read_intensities(file="xeasy_r1_20ms.text", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists', spectrum_id='test', heteronuc='C', proton='HE1', int_method='height') 284 285 # Test the data. 286 self.assertEqual(list(cdp.mol[0].res[0].spin[0].intensities.values())[0], 7.123e+03)
287