Author: bugman Date: Wed Apr 23 18:44:01 2008 New Revision: 5952 URL: http://svn.gna.org/viewcvs/relax?rev=5952&view=rev Log: Added a system test for the loading of spins from a small molecule. This uses the Scientific Python PDB data object. Added: 1.3/test_suite/system_tests/load_spins.py 1.3/test_suite/system_tests/scripts/load_spins_from_small_molecule.py Modified: 1.3/test_suite/system_tests/__init__.py Modified: 1.3/test_suite/system_tests/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/__init__.py?rev=5952&r1=5951&r2=5952&view=diff ============================================================================== --- 1.3/test_suite/system_tests/__init__.py (original) +++ 1.3/test_suite/system_tests/__init__.py Wed Apr 23 18:44:01 2008 @@ -36,6 +36,7 @@ from diffusion_tensor import Diffusion_tensor from generic import Generic from jw_mapping import Jw +from load_spins import Load_spins from model_free import Mf from model_selection import Modsel from n_state_model import N_state_model @@ -49,6 +50,7 @@ 'diffusion_tensor', 'generic', 'jw_mapping', + 'load_spins', 'model_free', 'model_selection', 'n_state_model', @@ -80,6 +82,7 @@ suite_array.append(TestLoader().loadTestsFromTestCase(Diffusion_tensor)) suite_array.append(TestLoader().loadTestsFromTestCase(Generic)) suite_array.append(TestLoader().loadTestsFromTestCase(Jw)) + suite_array.append(TestLoader().loadTestsFromTestCase(Load_spins)) suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) suite_array.append(TestLoader().loadTestsFromTestCase(Modsel)) suite_array.append(TestLoader().loadTestsFromTestCase(Relax_fit)) Added: 1.3/test_suite/system_tests/load_spins.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/load_spins.py?rev=5952&view=auto ============================================================================== --- 1.3/test_suite/system_tests/load_spins.py (added) +++ 1.3/test_suite/system_tests/load_spins.py Wed Apr 23 18:44:01 2008 @@ -1,0 +1,74 @@ +############################################################################### +# # +# Copyright (C) 2008 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + + +# Python module imports. +from unittest import TestCase + +# relax module imports. +from data import Data as relax_data_store + + +class Load_spins(TestCase): + """TestCase class for the loading of spins into the molecule/residue/spin data structure.""" + + def setUp(self): + """Set up for all the functional tests.""" + + # Create the data pipe. + self.relax.interpreter._Pipe.create('mf', 'mf') + + + def tearDown(self): + """Reset the relax data storage object.""" + + relax_data_store.__reset__() + + + def test_load_spins_from_small_molecule(self): + """Test the loading of spins from a small molecule using the Scientific Python PDB data object.""" + + # Execute a relax script. + self.relax.interpreter.run(script_file='test_suite/system_tests/scripts/load_spins_from_small_molecule.py') + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Test the molecule and residue data. + self.assertEqual(len(cdp.mol), 1) + self.assertEqual(cdp.mol[0].name, 'PYR') + self.assertEqual(len(cdp.mol[0].res), 1) + self.assertEqual(cdp.mol[0].res[0].num, 1) + self.assertEqual(cdp.mol[0].res[0].name, 'PYR') + + # Spin info. + nums = [4, 6, 8, 10, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 15, 16, 28, 30] + names = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12', 'H13', 'H14', 'H15', 'H16', 'H17', 'H18', 'H19', 'H20', 'H21', 'H22', 'H23', 'H24', 'H25', 'H26', 'H27', 'H28', 'C5', 'C6', 'C19', 'C23'] + elements = ['H']*28 + ['C']*4 + + # Loop over the spin containers, testing each. + self.assertEqual(len(cdp.mol[0].res[0].spin), 32) + for i in xrange(len(cdp.mol[0].res[0].spin)): + self.assertEqual(cdp.mol[0].res[0].spin[i].num, nums[i]) + self.assertEqual(cdp.mol[0].res[0].spin[i].name, names[i]) + self.assertEqual(cdp.mol[0].res[0].spin[i].element, elements[i]) + self.assert_(hasattr(cdp.mol[0].res[0].spin[i], 'pos')) Added: 1.3/test_suite/system_tests/scripts/load_spins_from_small_molecule.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/scripts/load_spins_from_small_molecule.py?rev=5952&view=auto ============================================================================== --- 1.3/test_suite/system_tests/scripts/load_spins_from_small_molecule.py (added) +++ 1.3/test_suite/system_tests/scripts/load_spins_from_small_molecule.py Wed Apr 23 18:44:01 2008 @@ -1,0 +1,16 @@ +"""Load a number of spin systems for a small molecule.""" + +import sys + + +# Read in the small molecule. +structure.read_pdb(file='gromacs_phthalic_acid.pdb', dir=sys.path[-1] + '/test_suite/shared_data/structures') + +# Load all protons. +structure.load_spins(spin_id='@*H*') + +# Load a few carbons. +structure.load_spins(spin_id='@C5') +structure.load_spins(spin_id='@C6') +structure.load_spins(spin_id='@C19') +structure.load_spins(spin_id='@C23')