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