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

Source Code for Module test_suite.system_tests.unit_vectors

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2013 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   
 25  # relax module imports. 
 26  from data import Relax_data_store; ds = Relax_data_store() 
 27  import dep_check 
 28  from status import Status; status = Status() 
 29  from test_suite.system_tests.base_classes import SystemTestCase 
 30   
 31   
32 -class Unit_vectors(SystemTestCase):
33 """Class for testing the calculation of unit vectors.""" 34
35 - def __init__(self, methodName='runTest'):
36 """Skip scientific Python tests if not installed. 37 38 @keyword methodName: The name of the test. 39 @type methodName: str 40 """ 41 42 # Execute the base class method. 43 super(Unit_vectors, self).__init__(methodName)
44 45
46 - def setUp(self):
47 """Set up for all the functional tests.""" 48 49 # Create the data pipe. 50 self.interpreter.pipe.create('mf', 'mf')
51 52
53 - def test_calc_unit_vectors1(self):
54 """Load the PDB file using the Scientific parser and calculate the XH unit vectors.""" 55 56 # Read the PDB file. 57 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='scientific') 58 59 # Load the spins. 60 self.interpreter.structure.load_spins(spin_id='@N') 61 self.interpreter.structure.load_spins(spin_id='@H') 62 63 # Calculate the unit vectors. 64 self.interpreter.dipole_pair.define(spin_id1='@N', spin_id2='@H', direct_bond=True) 65 self.interpreter.dipole_pair.unit_vectors() 66 67 # Leu 3. 68 self.assertEqual(cdp.mol[0].res[2].spin[0].num, 24) 69 self.assertEqual(cdp.mol[0].res[2].spin[0].name, 'N') 70 self.assert_(hasattr(cdp.interatomic[0], 'vector')) 71 self.assertNotEqual(cdp.interatomic[0].vector, None) 72 self.assertAlmostEqual(cdp.interatomic[0].vector[0], 0.40899187) 73 self.assertAlmostEqual(cdp.interatomic[0].vector[1], -0.80574458) 74 self.assertAlmostEqual(cdp.interatomic[0].vector[2], 0.42837054)
75 76
77 - def test_calc_unit_vectors2(self):
78 """Load the PDB file using the Scientific parser and calculate the XH unit vectors (with spin numbers removed).""" 79 80 # Read the PDB file. 81 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='scientific') 82 83 # Load the spins. 84 self.interpreter.structure.load_spins(spin_id='@N') 85 self.interpreter.structure.load_spins(spin_id='@H') 86 87 # Remove the spin numbers. 88 self.interpreter.spin.number(force=True) 89 90 # Calculate the unit vectors. 91 self.interpreter.dipole_pair.define(spin_id1='@N', spin_id2='@H', direct_bond=True) 92 self.interpreter.dipole_pair.unit_vectors() 93 94 # Leu 3. 95 self.assertEqual(cdp.mol[0].res[2].spin[0].num, None) 96 self.assertEqual(cdp.mol[0].res[2].spin[0].name, 'N') 97 self.assert_(hasattr(cdp.interatomic[0], 'vector')) 98 self.assertNotEqual(cdp.interatomic[0].vector, None) 99 self.assertAlmostEqual(cdp.interatomic[0].vector[0], 0.40899187) 100 self.assertAlmostEqual(cdp.interatomic[0].vector[1], -0.80574458) 101 self.assertAlmostEqual(cdp.interatomic[0].vector[2], 0.42837054)
102 103
104 - def test_calc_unit_vectors3(self):
105 """Load the PDB file using the internal parser and calculate the XH unit vectors.""" 106 107 # Read the PDB file. 108 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='internal') 109 110 # Load the spins. 111 self.interpreter.structure.load_spins(spin_id='@N') 112 self.interpreter.structure.load_spins(spin_id='@H') 113 114 # Calculate the unit vectors. 115 self.interpreter.dipole_pair.define(spin_id1='@N', spin_id2='@H', direct_bond=True) 116 self.interpreter.dipole_pair.unit_vectors() 117 118 # Leu 3. 119 self.assertEqual(cdp.mol[0].res[2].spin[0].num, 24) 120 self.assertEqual(cdp.mol[0].res[2].spin[0].name, 'N') 121 self.assert_(hasattr(cdp.interatomic[0], 'vector')) 122 self.assertNotEqual(cdp.interatomic[0].vector, None) 123 self.assertAlmostEqual(cdp.interatomic[0].vector[0], 0.40899187) 124 self.assertAlmostEqual(cdp.interatomic[0].vector[1], -0.80574458) 125 self.assertAlmostEqual(cdp.interatomic[0].vector[2], 0.42837054)
126 127
128 - def test_calc_unit_vectors4(self):
129 """Load the PDB file using the internal parser and calculate the XH unit vectors from it (with spin numbers removed).""" 130 131 # Read the PDB file. 132 self.interpreter.structure.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='internal') 133 134 # Load the spins. 135 self.interpreter.structure.load_spins(spin_id='@N') 136 self.interpreter.structure.load_spins(spin_id='@H') 137 138 # Remove the spin numbers. 139 self.interpreter.spin.number(force=True) 140 141 # Calculate the unit vectors. 142 self.interpreter.dipole_pair.define(spin_id1='@N', spin_id2='@H', direct_bond=True) 143 self.interpreter.dipole_pair.unit_vectors() 144 145 # Leu 3. 146 self.assertEqual(cdp.mol[0].res[2].spin[0].num, None) 147 self.assertEqual(cdp.mol[0].res[2].spin[0].name, 'N') 148 self.assert_(hasattr(cdp.interatomic[0], 'vector')) 149 self.assertNotEqual(cdp.interatomic[0].vector, None) 150 self.assertAlmostEqual(cdp.interatomic[0].vector[0], 0.40899187) 151 self.assertAlmostEqual(cdp.interatomic[0].vector[1], -0.80574458) 152 self.assertAlmostEqual(cdp.interatomic[0].vector[2], 0.42837054)
153