Package test_suite :: Module jw_mapping
[hide private]
[frames] | no frames]

Source Code for Module test_suite.jw_mapping

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006 Chris MacRaild                                           # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  import sys 
 24   
 25   
26 -class Jw:
27 - def __init__(self, relax, test_name):
28 """Class for testing various aspects specific to reduced spectral density mapping.""" 29 30 self.relax = relax 31 32 # Results reading test. 33 if test_name == 'set': 34 35 # The name of the test. 36 self.name = "The user function value.set()" 37 38 # The test. 39 self.test = self.set_value 40 41 # Spectral density calculation test. 42 if test_name == 'calc': 43 44 # The name of the test. 45 self.name = "Spectral density calculation" 46 47 # The test. 48 self.test = self.calc
49 50
51 - def calc(self, run):
52 """The spectral density calculation test.""" 53 54 # Arguments. 55 self.run = run 56 57 # Setup. 58 self.calc_setup() 59 60 # Try the reduced spectral density mapping. 61 self.relax.interpreter._Minimisation.calc(self.run) 62 63 # Success. 64 return self.calc_integrity()
65 66
67 - def calc_integrity(self):
68 69 # Correct jw values: 70 j0 = [4.0703318681008998e-09, 3.7739393907014834e-09] 71 jwx = [1.8456254300773903e-10, 1.6347516082378241e-10] 72 jwh = [1.5598167512718012e-12, 2.9480536599037041e-12] 73 74 # Loop over residues. 75 for index,residue in enumerate(self.relax.data.res[self.run]): 76 # Residues -2 and -1 have data. 77 if index == 0 or index == 1: 78 if not self.relax.data.res[self.run][index].select: 79 print 'Residue', self.relax.data.res[self.run][index].num, 'unexpectedly not selected' 80 return 81 82 if abs(self.relax.data.res[self.run][index].j0 - j0[index]) > j0[index]/1e6: 83 print 'Error in residue', self.relax.data.res[self.run][index].num, 'j0 calculated value' 84 return 85 if abs(self.relax.data.res[self.run][index].jwh - jwh[index]) > jwh[index]/1e6: 86 print 'Error in residue', self.relax.data.res[self.run][index].num, 'jwh calculated value' 87 return 88 if abs(self.relax.data.res[self.run][index].jwx - jwx[index]) > jwx[index]/1e6: 89 print 'Error in residue', self.relax.data.res[self.run][index].num, 'jwx calculated value' 90 return 91 92 # Other residues have insufficient data. 93 else: 94 if self.relax.data.res[self.run][index].select: 95 print 'Residue', self.relax.data.res[self.run][index].num, 'unexpectedly selected' 96 return 97 98 # Success. 99 return 1
100 101
102 - def calc_setup(self):
103 """Setup for the calculation test.""" 104 105 dir = sys.path[-1] + '/test_suite/data/jw_mapping/' 106 107 dataPaths = [dir + 'noe.dat', 108 dir + 'R1.dat', 109 dir + 'R2.dat'] 110 111 dataTypes = [('NOE', '600', 600.0e6), 112 ('R1', '600', 600.0e6), 113 ('R2', '600', 600.0e6)] 114 115 # Create the run. 116 self.relax.generic.runs.create(self.run, 'jw') 117 118 # Read the sequence. 119 self.relax.interpreter._Sequence.read(self.run, file='test_seq', dir=sys.path[-1] + '/test_suite/data') 120 121 # Read the data. 122 for dataSet in xrange(len(dataPaths)): 123 self.relax.interpreter._Relax_data.read(self.run, dataTypes[dataSet][0], dataTypes[dataSet][1], dataTypes[dataSet][2], dataPaths[dataSet]) 124 125 # Nuclei type. 126 self.relax.interpreter._Nuclei.nuclei('N') 127 128 # Set r and csa. 129 self.relax.interpreter._Value.set(self.run, 1.02 * 1e-10, 'bond_length') 130 self.relax.interpreter._Value.set(self.run, -172 * 1e-6, 'csa') 131 132 # Select the frequency. 133 self.relax.interpreter._Jw_mapping.set_frq(self.run, frq=600.0 * 1e6)
134 135
136 - def set_value(self, run):
137 """The value.set test.""" 138 139 # Arguments. 140 self.run = run 141 142 # Create the run. 143 self.relax.generic.runs.create(self.run, 'jw') 144 145 # Read the sequence. 146 self.relax.interpreter._Sequence.read(self.run, file='test_seq', dir=sys.path[-1] + '/test_suite/data') 147 148 # Try to set the values. 149 bond_length = 1.02 * 1e-10 150 csa = -172 * 1e-6 151 self.relax.interpreter._Value.set(self.run, bond_length, 'bond_length') 152 self.relax.interpreter._Value.set(self.run, csa, 'csa') 153 154 # Test values. 155 for i in xrange( len(self.relax.data.res[self.run]) ): 156 if self.relax.data.res[self.run][i].r != bond_length: 157 print 'Value of bond_length has not been set correctly' 158 return 159 if self.relax.data.res[self.run][i].csa != csa: 160 print 'Value of csa has not been set correctly' 161 return 162 163 # Success. 164 return 1
165