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-2011 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.interpreter.run(script_file=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.interpreter.run(script_file=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 print spin 77 # The data. 78 if res_num == 1501: 79 index = 0 80 elif res_num == 1504: 81 index = 1 82 83 # No data. 84 else: 85 # There should be no intensity data. 86 self.assert_(not hasattr(spin, 'intensities')) 87 88 # Do not perform the height checks. 89 continue 90 91 # Check the data. 92 self.assert_(hasattr(spin, 'intensities')) 93 94 # Check the values. 95 for i in range(len(times)): 96 self.assertEqual(spin.intensities[names[i]], heights[index][i])
97 98
100 """Test the reading of a generic peak intensity list.""" 101 102 # Create the sequence data, and name the spins. 103 self.interpreter.residue.create(20, 'GLY') 104 self.interpreter.residue.create(23, 'ALA') 105 self.interpreter.residue.create(34, 'CYS') 106 self.interpreter.residue.create(35, 'MET') 107 self.interpreter.residue.create(36, 'LYS') 108 self.interpreter.spin.name(name='N') 109 110 # Relaxation delays. 111 delays = [0.0109016, 112 0.0218032, 113 0.0436064, 114 0.0436064, 115 0.0872128, 116 0.1744260, 117 0.3488510, 118 0.6977020, 119 1.3954000, 120 1.9949900] 121 122 # Load the data. 123 for i in range(10): 124 # Read the peak intensities. 125 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) 126 127 # Set the relaxation times. 128 self.interpreter.relax_fit.relax_time(time=delays[i], spectrum_id=repr(i)) 129 130 # The actual intensities. 131 heights = [[1.0000, 0.9714, 0.9602, 0.9626, 0.8839, 0.8327, 0.7088, 0.5098, 0.2410, 0.1116], 132 [1.0000, 0.9789, 0.9751, 0.9762, 0.9074, 0.8532, 0.7089, 0.5170, 0.2444, 0.1537], 133 [1.0000, 0.9659, 0.9580, 0.9559, 0.9325, 0.8460, 0.7187, 0.5303, 0.2954, 0.1683], 134 [1.0000, 0.9657, 0.9389, 0.9366, 0.9331, 0.8683, 0.7169, 0.5357, 0.2769, 0.1625], 135 [1.0000, 1.0060, 0.9556, 0.9456, 0.9077, 0.8411, 0.6788, 0.4558, 0.2448, 0.1569] 136 ] 137 138 # Test the data. 139 for i in range(10): 140 for j in range(5): 141 self.assertEqual(cdp.mol[0].res[j].spin[0].intensities[repr(i)], heights[j][i])
142 143
145 """Test the reading of an NMRView peak list.""" 146 147 # Create the sequence data, and name the spins. 148 self.interpreter.residue.create(70) 149 self.interpreter.residue.create(72) 150 self.interpreter.spin.name(name='N') 151 152 # Read the peak list. 153 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') 154 155 # Test the data. 156 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], -0.1694) 157 self.assertEqual(cdp.mol[0].res[1].spin[0].intensities.values()[0], -0.1142)
158 159
161 """Test the reading of an Sparky peak list.""" 162 163 # Create the sequence data, and name the spins. 164 self.interpreter.residue.create(3) 165 self.interpreter.residue.create(4) 166 self.interpreter.residue.create(5) 167 self.interpreter.residue.create(6) 168 self.interpreter.spin.name(name='N') 169 170 # Read the peak list. 171 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') 172 173 # Test the data. 174 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 6262) 175 self.assertEqual(cdp.mol[0].res[1].spin[0].intensities.values()[0], 148614) 176 self.assertEqual(cdp.mol[0].res[2].spin[0].intensities.values()[0], 166842) 177 self.assertEqual(cdp.mol[0].res[3].spin[0].intensities.values()[0], 128690)
178 179
181 """Test the reading of an XEasy peak list.""" 182 183 # Create the sequence data, and name the spins. 184 self.interpreter.residue.create(15) 185 self.interpreter.residue.create(21) 186 self.interpreter.residue.create(22) 187 self.interpreter.residue.create(29) 188 self.interpreter.residue.create(52) 189 self.interpreter.residue.create(69) 190 self.interpreter.residue.create(70) 191 self.interpreter.residue.create(73) 192 self.interpreter.residue.create(79) 193 self.interpreter.residue.create(84) 194 self.interpreter.residue.create(87) 195 self.interpreter.residue.create(95) 196 self.interpreter.residue.create(96) 197 self.interpreter.residue.create(100) 198 self.interpreter.residue.create(104) 199 self.interpreter.residue.create(107) 200 self.interpreter.residue.create(110) 201 self.interpreter.residue.create(112) 202 self.interpreter.residue.create(120) 203 self.interpreter.residue.create(141) 204 self.interpreter.residue.create(165) 205 self.interpreter.spin.name(name='N') 206 207 # Read the peak list. 208 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') 209 210 # Test the data. 211 self.assertEqual(cdp.mol[0].res[ 0].spin[0].intensities.values()[0], 9.714e+03) 212 self.assertEqual(cdp.mol[0].res[ 1].spin[0].intensities.values()[0], 7.919e+03) 213 self.assertEqual(cdp.mol[0].res[ 2].spin[0].intensities.values()[0], 1.356e+04) 214 self.assertEqual(cdp.mol[0].res[ 3].spin[0].intensities.values()[0], 9.884e+03) 215 self.assertEqual(cdp.mol[0].res[ 4].spin[0].intensities.values()[0], 2.041e+04) 216 self.assertEqual(cdp.mol[0].res[ 5].spin[0].intensities.values()[0], 9.305e+03) 217 self.assertEqual(cdp.mol[0].res[ 6].spin[0].intensities.values()[0], 3.154e+04) 218 self.assertEqual(cdp.mol[0].res[ 7].spin[0].intensities.values()[0], 9.180e+03) 219 self.assertEqual(cdp.mol[0].res[ 9].spin[0].intensities.values()[0], 1.104e+04) 220 self.assertEqual(cdp.mol[0].res[10].spin[0].intensities.values()[0], 7.680e+03) 221 self.assertEqual(cdp.mol[0].res[11].spin[0].intensities.values()[0], 5.206e+03) 222 self.assertEqual(cdp.mol[0].res[12].spin[0].intensities.values()[0], 2.863e+04) 223 self.assertEqual(cdp.mol[0].res[14].spin[0].intensities.values()[0], 9.271e+03) 224 self.assertEqual(cdp.mol[0].res[15].spin[0].intensities.values()[0], 7.919e+03) 225 self.assertEqual(cdp.mol[0].res[16].spin[0].intensities.values()[0], 9.962e+03) 226 self.assertEqual(cdp.mol[0].res[17].spin[0].intensities.values()[0], 1.260e+04) 227 self.assertEqual(cdp.mol[0].res[18].spin[0].intensities.values()[0], 1.545e+04) 228 self.assertEqual(cdp.mol[0].res[19].spin[0].intensities.values()[0], 1.963e+04) 229 self.assertEqual(cdp.mol[0].res[20].spin[0].intensities.values()[0], 1.918e+04)
230 231
233 """Test the reading of an XEasy peak list (2).""" 234 235 # Create the sequence data, and name the spins. 236 self.interpreter.residue.create(79) 237 self.interpreter.spin.name(name='NE1') 238 239 # Read the peak list. 240 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') 241 242 # Test the data. 243 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 1.532e+04)
244 245
247 """Test the reading of an XEasy peak list (3).""" 248 249 # Create the sequence data, and name the spins. 250 self.interpreter.residue.create(100) 251 self.interpreter.spin.name(name='C') 252 253 # Read the peak list. 254 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') 255 256 # Test the data. 257 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 6.877e+03)
258 259
261 """Test the reading of an XEasy peak list (4).""" 262 263 # Create the sequence data, and name the spins. 264 self.interpreter.residue.create(107) 265 self.interpreter.spin.name(name='C') 266 267 # Read the peak list. 268 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') 269 270 # Test the data. 271 self.assertEqual(cdp.mol[0].res[0].spin[0].intensities.values()[0], 7.123e+03)
272