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

Source Code for Module test_suite.consistency_tests

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2006 Chris MacRaild                                           # 
  4  # Copyright (C) 2007 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  import sys 
 25   
 26   
27 -class Consistent:
28 - def __init__(self, relax, test_name):
29 """Class for testing various aspects specific to consistency tests.""" 30 31 self.relax = relax 32 33 # Results reading test. 34 if test_name == 'set': 35 36 # The name of the test. 37 self.name = "The user function value.set()" 38 39 # The test. 40 self.test = self.set_value 41 42 # Consistency tests calculation test. 43 if test_name == 'calc': 44 45 # The name of the test. 46 self.name = "Consistency tests calculation" 47 48 # The test. 49 self.test = self.calc
50 51
52 - def calc(self, run):
53 """The consistency tests calculation test.""" 54 55 # Arguments. 56 self.run = run 57 58 # Setup. 59 self.calc_setup() 60 61 # Try the consistency testing. 62 self.relax.interpreter._Minimisation.calc(self.run) 63 64 # Success. 65 return self.calc_integrity()
66 67
68 - def calc_integrity(self):
69 """The consistency tests calculation sub-routine.""" 70 71 # Correct consistency functions values: 72 j0 = [4.0958793960056238e-09, 3.7976266046729745e-09] 73 f_eta = [0.20302515844782615, 0.18796462392813956] 74 f_r2 = [2.0611470814962761e-09, 1.9117396355237641e-09] 75 76 # Loop over residues. 77 for index,residue in enumerate(self.relax.data.res[self.run]): 78 # Residues -2 and -1 have data. 79 if index == 0 or index == 1: 80 if not self.relax.data.res[self.run][index].select: 81 print 'Residue', self.relax.data.res[self.run][index].num, 'unexpectedly not selected' 82 return 83 84 if abs(self.relax.data.res[self.run][index].j0 - j0[index]) > j0[index]/1e6: 85 print 'Error in residue', self.relax.data.res[self.run][index].num, 'j0 calculated value' 86 return 87 if abs(self.relax.data.res[self.run][index].f_eta - f_eta[index]) > f_eta[index]/1e6: 88 print 'Error in residue', self.relax.data.res[self.run][index].num, 'f_eta calculated value' 89 return 90 if abs(self.relax.data.res[self.run][index].f_r2 - f_r2[index]) > f_r2[index]/1e6: 91 print 'Error in residue', self.relax.data.res[self.run][index].num, 'f_r2 calculated value' 92 return 93 94 # Other residues have insufficient data. 95 else: 96 if self.relax.data.res[self.run][index].select: 97 print 'Residue', self.relax.data.res[self.run][index].num, 'unexpectedly selected' 98 return 99 100 # Success. 101 return 1
102 103
104 - def calc_setup(self):
105 """Setup for the calculation test.""" 106 107 # Locate and describe the data. 108 dir = sys.path[-1] + '/test_suite/data/jw_mapping/' 109 110 dataPaths = [dir + 'noe.dat', 111 dir + 'R1.dat', 112 dir + 'R2.dat'] 113 114 dataTypes = [('NOE', '600', 600.0e6), 115 ('R1', '600', 600.0e6), 116 ('R2', '600', 600.0e6)] 117 118 # Create the run. 119 self.relax.generic.runs.create(self.run, 'ct') 120 121 # Read the sequence. 122 self.relax.interpreter._Sequence.read(self.run, file='test_seq', dir=sys.path[-1] + '/test_suite/data') 123 124 # Read the data. 125 for dataSet in xrange(len(dataPaths)): 126 self.relax.interpreter._Relax_data.read(self.run, dataTypes[dataSet][0], dataTypes[dataSet][1], dataTypes[dataSet][2], dataPaths[dataSet]) 127 128 # Nuclei type. 129 self.relax.interpreter._Nuclei.nuclei('N') 130 131 # Set r and csa. 132 self.relax.interpreter._Value.set(self.run, 1.02 * 1e-10, 'bond_length') 133 self.relax.interpreter._Value.set(self.run, -170 * 1e-6, 'csa') 134 135 # Set the angle between the 15N-1H vector and the principal axis of the 15N chemical shift tensor 136 self.relax.interpreter._Value.set(self.run, 15.7, 'orientation') 137 138 # Set the approximate correlation time. 139 self.relax.interpreter._Value.set(self.run, 13 * 1e-9, 'tc') 140 141 # Set the frequency. 142 self.relax.interpreter._Consistency_tests.set_frq(self.run, frq=600.0 * 1e6)
143 144
145 - def set_value(self, run):
146 """The value.set test.""" 147 148 # Arguments. 149 self.run = run 150 151 # Create the run. 152 self.relax.generic.runs.create(self.run, 'ct') 153 154 # Read the sequence. 155 self.relax.interpreter._Sequence.read(self.run, file='test_seq', dir=sys.path[-1] + '/test_suite/data') 156 157 # Try to set the values. 158 bond_length = 1.02 * 1e-10 159 csa = -170 * 1e-6 160 orientation = 15.7 161 tc = 13 * 1e-9 162 self.relax.interpreter._Value.set(self.run, bond_length, 'bond_length') 163 self.relax.interpreter._Value.set(self.run, csa, 'csa') 164 self.relax.interpreter._Value.set(self.run, orientation, 'orientation') 165 self.relax.interpreter._Value.set(self.run, tc, 'tc') 166 167 # Test values. 168 for i in xrange( len(self.relax.data.res[self.run]) ): 169 if self.relax.data.res[self.run][i].r != bond_length: 170 print 'Value of bond_length has not been set correctly' 171 return 172 if self.relax.data.res[self.run][i].csa != csa: 173 print 'Value of csa has not been set correctly' 174 return 175 if self.relax.data.res[self.run][i].orientation != orientation: 176 print 'Value of orientation has not been set correctly' 177 return 178 if self.relax.data.res[self.run][i].tc != tc: 179 print 'Value of tc has not been set correctly' 180 return 181 182 # Success. 183 return 1
184