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

Source Code for Module test_suite.system_tests.noe

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from os import sep 
 24  from tempfile import mktemp 
 25   
 26  # relax module imports. 
 27  from data_store import Relax_data_store; ds = Relax_data_store() 
 28  from pipe_control.mol_res_spin import spin_loop 
 29  from status import Status; status = Status() 
 30  from test_suite.system_tests.base_classes import SystemTestCase 
 31   
 32   
33 -class Noe(SystemTestCase):
34 """Class for testing various aspects specific to the NOE analysis.""" 35
36 - def setUp(self):
37 """Set up for all the functional tests.""" 38 39 # Create the data pipe. 40 self.interpreter.pipe.create('noe', 'noe') 41 42 # Create a temporary file. 43 ds.tmpfile = mktemp()
44 45
47 """Catch U{bug #21562<https://web.archive.org/web/https://gna.org/bugs/?21562>}, the failure of the NOE analysis when replicated spectra are used.""" 48 49 # Execute the script. 50 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'noe'+sep+'bug_21562_noe_replicate_fail.py') 51 52 # Open the NOE output file. 53 file = open(ds.tmpfile) 54 lines = file.readlines() 55 file.close() 56 57 # How the file should look like. 58 data = [ 59 "# Parameter description: The NOE.\n", 60 "#\n", 61 "# mol_name res_num res_name spin_num spin_name value error \n", 62 "2AT7_fmf_mol1 12 PHE 150 N 0.803029108487728 0.0199040298831904 \n", 63 "2AT7_fmf_mol1 13 ASN 170 N 0.829415981681132 0.0339996453012768 \n", 64 "2AT7_fmf_mol1 14 LYS 184 N 0.755789564728523 0.0250941717735858 \n" 65 ] 66 67 # Printout of the real and generated data. 68 print("\n\nThe real data:") 69 for i in range(len(lines)): 70 print(repr(data[i])) 71 print("\nThe generated data:") 72 for i in range(len(lines)): 73 print(repr(lines[i])) 74 print("\n") 75 76 # Check each line. 77 for i in range(len(lines)): 78 self.assertEqual(data[i], lines[i])
79 80
82 """Catch U{bug #21591<https://web.archive.org/web/https://gna.org/bugs/?21591>}, the failure of the NOE analysis.""" 83 84 # Generate the sequence. 85 self.interpreter.spin.create(mol_name='XYZ_mol1', res_num=120, res_name='GLY', spin_num=1865, spin_name='N') 86 87 # Load the reference spectrum and saturated spectrum peak intensities. 88 path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists' 89 self.interpreter.spectrum.read_intensities(file='noe.140109.8.001.list', dir=path, spectrum_id='ref_ave') 90 self.interpreter.spectrum.read_intensities(file='noe.140109.8.002.list', dir=path, spectrum_id='sat_ave') 91 92 # Set the spectrum types. 93 self.interpreter.noe.spectrum_type('ref', 'ref_ave') 94 self.interpreter.noe.spectrum_type('sat', 'sat_ave') 95 96 # Set the errors. 97 self.interpreter.spectrum.baseplane_rmsd(error=1.3e06, spectrum_id='ref_ave') 98 self.interpreter.spectrum.baseplane_rmsd(error=1.4e06, spectrum_id='sat_ave') 99 100 # Peak intensity error analysis. 101 self.interpreter.spectrum.error_analysis() 102 103 # Calculate the NOEs. 104 self.interpreter.calc() 105 106 # Save the NOEs. 107 self.interpreter.value.write(param='noe', file=ds.tmpfile) 108 109 # Open the NOE output file. 110 file = open(ds.tmpfile) 111 lines = file.readlines() 112 file.close() 113 114 # How the file should look like. 115 data = [ 116 "# Parameter description: The NOE.\n", 117 "#\n", 118 "# mol_name res_num res_name spin_num spin_name value error \n", 119 "XYZ_mol1 120 GLY 1865 N 0.520373965716017 0.208104738641507 \n", 120 ] 121 122 # Printout of the real and generated data. 123 print("\n\nThe real data:") 124 for i in range(len(lines)): 125 print(repr(data[i])) 126 print("\nThe generated data:") 127 for i in range(len(lines)): 128 print(repr(lines[i])) 129 print("\n") 130 131 # Check each line. 132 for i in range(len(lines)): 133 self.assertEqual(data[i], lines[i])
134 135
136 - def test_noe_analysis(self):
137 """Test the NOE analysis.""" 138 139 # Execute the script. 140 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'noe'+sep+'noe.py') 141 142 # The real data. 143 sat = [5050.0, 51643.0, 53663.0, -65111.0, -181131.0, -105322.0] 144 ref = [148614.0, 166842.0, 128690.0, 99566.0, 270047.0, 130959.0] 145 noe = [0.033980647852826784, 0.30953237194471417, 0.4169943274535706, -0.6539481349054899, -0.6707387973204665, -0.8042364404126482] 146 noe_err = [0.02020329903276632, 0.2320024671657343, 0.026067523940084526, 0.038300618865378507, 0.014260663438353431, 0.03183614777183591] 147 148 # Check the data. 149 i = 0 150 for spin in spin_loop(): 151 # Skip deselected spins. 152 if not spin.select: 153 continue 154 155 # Check the intensity data. 156 self.assertEqual(sat[i], spin.intensities['sat_ave']) 157 self.assertEqual(ref[i], spin.intensities['ref_ave']) 158 159 # Check the NOE data. 160 self.assertEqual(noe[i], spin.noe) 161 self.assertAlmostEqual(noe_err[i], spin.noe_err) 162 163 # Increment the spin index. 164 i += 1 165 166 # The real Grace file data. 167 data = [ 168 '@version 50121\n', 169 '@page size 842, 595\n', 170 '@with g0\n', 171 '@ view 0.15, 0.15, 1.28, 0.85\n', 172 '@ xaxis label "Residue number"\n', 173 '@ xaxis label char size 1.00\n', 174 '@ xaxis tick major size 0.50\n', 175 '@ xaxis tick major linewidth 0.5\n', 176 '@ xaxis tick minor linewidth 0.5\n', 177 '@ xaxis tick minor size 0.25\n', 178 '@ xaxis ticklabel char size 0.70\n', 179 '@ yaxis label "\\qNOE\\Q"\n', 180 '@ yaxis label char size 1.00\n', 181 '@ yaxis tick major size 0.50\n', 182 '@ yaxis tick major linewidth 0.5\n', 183 '@ yaxis tick minor linewidth 0.5\n', 184 '@ yaxis tick minor size 0.25\n', 185 '@ yaxis ticklabel char size 0.70\n', 186 '@ legend off\n', 187 '@ legend box fill pattern 1\n', 188 '@ legend char size 1.0\n', 189 '@ frame linewidth 0.5\n', 190 '@ s0 symbol 1\n', 191 '@ s0 symbol size 0.45\n', 192 '@ s0 symbol linewidth 0.5\n', 193 '@ s0 errorbar size 0.5\n', 194 '@ s0 errorbar linewidth 0.5\n', 195 '@ s0 errorbar riser linewidth 0.5\n', 196 '@ s0 legend "N spins"\n', 197 '@ s1 symbol 2\n', 198 '@ s1 symbol size 0.45\n', 199 '@ s1 symbol linewidth 0.5\n', 200 '@ s1 errorbar size 0.5\n', 201 '@ s1 errorbar linewidth 0.5\n', 202 '@ s1 errorbar riser linewidth 0.5\n', 203 '@ s1 legend "NE1 spins"\n', 204 '@target G0.S0\n', 205 '@type xydy\n', 206 '4 0.033980647852827 0.020203299032766 \n', 207 '5 0.309532371944714 0.232002467165734 \n', 208 '6 0.416994327453571 0.026067523940085 \n', 209 '40 -0.653948134905490 0.038300618865379 \n', 210 '55 -0.804236440412648 0.031836147771836 \n', 211 '&\n', 212 '@target G0.S1\n', 213 '@type xydy\n', 214 '40 -0.670738797320466 0.014260663438353 \n', 215 '&\n', 216 '@with g0\n', 217 '@autoscale\n' 218 ] 219 220 # Check the Grace file. 221 file = open(ds.tmpfile) 222 lines = file.readlines() 223 file.close() 224 for i in range(len(lines)): 225 print(" '%s\\n'," % lines[i][:-1].replace('"', "\\\"")) 226 for i in range(len(lines)): 227 self.assertEqual(data[i], lines[i])
228