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-2012 Edward d'Auvergne                                   # 
  4  # Copyright (C) 2008 Sebastien Morin                                          # 
  5  #                                                                             # 
  6  # This file is part of the program relax.                                     # 
  7  #                                                                             # 
  8  # relax 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 2 of the License, or           # 
 11  # (at your option) any later version.                                         # 
 12  #                                                                             # 
 13  # relax 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 relax; if not, write to the Free Software                        # 
 20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 21  #                                                                             # 
 22  ############################################################################### 
 23   
 24  # Python module imports. 
 25  from os import sep 
 26   
 27  # relax module imports. 
 28  from base_classes import SystemTestCase 
 29  from data import Relax_data_store; ds = Relax_data_store() 
 30  from generic_fns.mol_res_spin import spin_loop 
 31  from status import Status; status = Status() 
 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 setUp(self):
38 """Set up for all the functional tests.""" 39 40 # Create a data pipe. 41 self.interpreter.pipe.create('mf', 'mf')
42 43
45 """Test catching bug #17276, the duplicated peak list reading failure submitted by Leanne Minall.""" 46 47 # Execute the script. 48 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'bug_17276_peak_lists.py')
49 50
51 - def test_ccpn_analysis(self):
52 """Test 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.""" 53 54 # Execute the script. 55 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'peak_lists'+sep+'ccpn_analysis.py') 56 57 # Spectrum names. 58 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'] 59 60 # Relaxation times (in seconds). 61 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] 62 63 # Check the spectrum IDs and relaxation times. 64 for i in range(len(times)): 65 self.assertEqual(cdp.spectrum_ids[i], names[i]) 66 self.assertEqual(cdp.relax_times[names[i]], times[i]) 67 68 # The peak heights. 69 heights = [ 70 [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], 71 [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] 72 ] 73 74 # Check the heights. 75 for spin, mol_name, res_num, res_name in spin_loop(full_info=True): 76 # The data. 77 if res_num == 1501: 78 index = 0 79 elif res_num == 1504: 80 index = 1 81 82 # No data. 83 else: 84 # There should be no intensity data. 85 self.assert_(not hasattr(spin, 'intensities')) 86 87 # Do not perform the height checks. 88 continue 89 90 # Check the data. 91 self.assert_(hasattr(spin, 'intensities')) 92 93 # Check the values. 94 for i in range(len(times)): 95 self.assertEqual(spin.intensities[names[i]], heights[index][i])
96 97
99 """Test the reading of a generic peak intensity list.""" 100 101 # Create the sequence data, and name the spins. 102 self.interpreter.residue.create(20, 'GLY') 103 self.interpreter.residue.create(23, 'ALA') 104 self.interpreter.residue.create(34, 'CYS') 105 self.interpreter.residue.create(35, 'MET') 106 self.interpreter.residue.create(36, 'LYS') 107 self.interpreter.spin.name(name='N') 108 109 # Relaxation delays. 110 delays = [0.0109016, 111 0.0218032, 112 0.0436064, 113 0.0436064, 114 0.0872128, 115 0.1744260, 116 0.3488510, 117 0.6977020, 118 1.3954000, 119 1.9949900] 120 121 # Load the data. 122 for i in range(10): 123 # Read the peak intensities. 124 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) 125 126 # Set the relaxation times. 127 self.interpreter.relax_fit.relax_time(time=delays[i], spectrum_id=repr(i)) 128 129 # The actual intensities. 130 heights = [[1.0000, 0.9714, 0.9602, 0.9626, 0.8839, 0.8327, 0.7088, 0.5098, 0.2410, 0.1116], 131 [1.0000, 0.9789, 0.9751, 0.9762, 0.9074, 0.8532, 0.7089, 0.5170, 0.2444, 0.1537], 132 [1.0000, 0.9659, 0.9580, 0.9559, 0.9325, 0.8460, 0.7187, 0.5303, 0.2954, 0.1683], 133 [1.0000, 0.9657, 0.9389, 0.9366, 0.9331, 0.8683, 0.7169, 0.5357, 0.2769, 0.1625], 134 [1.0000, 1.0060, 0.9556, 0.9456, 0.9077, 0.8411, 0.6788, 0.4558, 0.2448, 0.1569] 135 ] 136 137 # Test the data. 138 for i in range(10): 139 for j in range(5): 140 self.assertEqual(cdp.mol[0].res[j].spin[0].intensities[repr(i)], heights[j][i])
141 142
144 """Test the reading of an NMRView peak list.""" 145 146 # Create the sequence data, and name the spins. 147 self.interpreter.residue.create(70) 148 self.interpreter.residue.create(72) 149 self.interpreter.spin.name(name='N') 150 151 # Read the peak list. 152 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') 153 154 # Test the data. 155 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], -0.1694) 156 self.assertEqual(cdp.mol[0].res[1].spin[0].intensities.values()[0], -0.1142)
157 158
160 """Test the reading of an Sparky peak list.""" 161 162 # Create the sequence data, and name the spins. 163 self.interpreter.residue.create(3) 164 self.interpreter.residue.create(4) 165 self.interpreter.residue.create(5) 166 self.interpreter.residue.create(6) 167 self.interpreter.spin.name(name='N') 168 169 # Read the peak list. 170 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') 171 172 # Test the data. 173 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 6262) 174 self.assertEqual(cdp.mol[0].res[1].spin[0].intensities.values()[0], 148614) 175 self.assertEqual(cdp.mol[0].res[2].spin[0].intensities.values()[0], 166842) 176 self.assertEqual(cdp.mol[0].res[3].spin[0].intensities.values()[0], 128690)
177 178
180 """Test the reading of an XEasy peak list.""" 181 182 # Create the sequence data, and name the spins. 183 self.interpreter.residue.create(15) 184 self.interpreter.residue.create(21) 185 self.interpreter.residue.create(22) 186 self.interpreter.residue.create(29) 187 self.interpreter.residue.create(52) 188 self.interpreter.residue.create(69) 189 self.interpreter.residue.create(70) 190 self.interpreter.residue.create(73) 191 self.interpreter.residue.create(79) 192 self.interpreter.residue.create(84) 193 self.interpreter.residue.create(87) 194 self.interpreter.residue.create(95) 195 self.interpreter.residue.create(96) 196 self.interpreter.residue.create(100) 197 self.interpreter.residue.create(104) 198 self.interpreter.residue.create(107) 199 self.interpreter.residue.create(110) 200 self.interpreter.residue.create(112) 201 self.interpreter.residue.create(120) 202 self.interpreter.residue.create(141) 203 self.interpreter.residue.create(165) 204 self.interpreter.spin.name(name='N') 205 206 # Read the peak list. 207 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') 208 209 # Test the data. 210 self.assertEqual(cdp.mol[0].res[ 0].spin[0].intensities.values()[0], 9.714e+03) 211 self.assertEqual(cdp.mol[0].res[ 1].spin[0].intensities.values()[0], 7.919e+03) 212 self.assertEqual(cdp.mol[0].res[ 2].spin[0].intensities.values()[0], 1.356e+04) 213 self.assertEqual(cdp.mol[0].res[ 3].spin[0].intensities.values()[0], 9.884e+03) 214 self.assertEqual(cdp.mol[0].res[ 4].spin[0].intensities.values()[0], 2.041e+04) 215 self.assertEqual(cdp.mol[0].res[ 5].spin[0].intensities.values()[0], 9.305e+03) 216 self.assertEqual(cdp.mol[0].res[ 6].spin[0].intensities.values()[0], 3.154e+04) 217 self.assertEqual(cdp.mol[0].res[ 7].spin[0].intensities.values()[0], 9.180e+03) 218 self.assertEqual(cdp.mol[0].res[ 9].spin[0].intensities.values()[0], 1.104e+04) 219 self.assertEqual(cdp.mol[0].res[10].spin[0].intensities.values()[0], 7.680e+03) 220 self.assertEqual(cdp.mol[0].res[11].spin[0].intensities.values()[0], 5.206e+03) 221 self.assertEqual(cdp.mol[0].res[12].spin[0].intensities.values()[0], 2.863e+04) 222 self.assertEqual(cdp.mol[0].res[14].spin[0].intensities.values()[0], 9.271e+03) 223 self.assertEqual(cdp.mol[0].res[15].spin[0].intensities.values()[0], 7.919e+03) 224 self.assertEqual(cdp.mol[0].res[16].spin[0].intensities.values()[0], 9.962e+03) 225 self.assertEqual(cdp.mol[0].res[17].spin[0].intensities.values()[0], 1.260e+04) 226 self.assertEqual(cdp.mol[0].res[18].spin[0].intensities.values()[0], 1.545e+04) 227 self.assertEqual(cdp.mol[0].res[19].spin[0].intensities.values()[0], 1.963e+04) 228 self.assertEqual(cdp.mol[0].res[20].spin[0].intensities.values()[0], 1.918e+04)
229 230
232 """Test the reading of an XEasy peak list (2).""" 233 234 # Create the sequence data, and name the spins. 235 self.interpreter.residue.create(79) 236 self.interpreter.spin.name(name='NE1') 237 238 # Read the peak list. 239 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') 240 241 # Test the data. 242 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 1.532e+04)
243 244
246 """Test the reading of an XEasy peak list (3).""" 247 248 # Create the sequence data, and name the spins. 249 self.interpreter.residue.create(100) 250 self.interpreter.spin.name(name='C') 251 252 # Read the peak list. 253 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') 254 255 # Test the data. 256 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 6.877e+03)
257 258
260 """Test the reading of an XEasy peak list (4).""" 261 262 # Create the sequence data, and name the spins. 263 self.interpreter.residue.create(107) 264 self.interpreter.spin.name(name='C') 265 266 # Read the peak list. 267 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') 268 269 # Test the data. 270 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 7.123e+03)
271