Author: bugman Date: Fri Jan 18 18:22:57 2013 New Revision: 18235 URL: http://svn.gna.org/viewcvs/relax?rev=18235&view=rev Log: Merged revisions 18224-18234 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r18224 | bugman | 2013-01-18 14:19:34 +0100 (Fri, 18 Jan 2013) | 3 lines The Pipes.test_change_type system test is skipped if the required scipy module is not installed. ........ r18225 | bugman | 2013-01-18 14:20:36 +0100 (Fri, 18 Jan 2013) | 5 lines Python 3 fix for the new pcs.structural_noise user function. There was a string/unicode problem in the Grace plot creation code. ........ r18226 | bugman | 2013-01-18 16:10:14 +0100 (Fri, 18 Jan 2013) | 6 lines Created the Pcs.test_load_multi_col_data system test to demonstrate a failure of PCS data loading. This is a problem when 15N data is in one column and 1H data is in another, and the spin_id argument is used to specify which is which. ........ r18227 | bugman | 2013-01-18 16:17:44 +0100 (Fri, 18 Jan 2013) | 3 lines Added some printouts to the Pcs.test_load_multi_col_data system test. ........ r18228 | bugman | 2013-01-18 16:44:15 +0100 (Fri, 18 Jan 2013) | 5 lines Bug fix for the loading of PCS data from a file with different spin types in different columns. This was caught by the Pcs.test_load_multi_col_data system test which now passes. ........ r18229 | bugman | 2013-01-18 17:01:52 +0100 (Fri, 18 Jan 2013) | 3 lines Created the Pcs.test_grace_plot system test to check the pcs.corr_plot user function. ........ r18230 | bugman | 2013-01-18 17:39:09 +0100 (Fri, 18 Jan 2013) | 6 lines Created the Pcs.test_load_multi_col_data2 system test to catch a bug with the molecule name. This is the same as the Pcs.test_load_multi_col_data system test but the spins have the molecule name set. ........ r18231 | bugman | 2013-01-18 17:50:16 +0100 (Fri, 18 Jan 2013) | 5 lines Created the Mol_res_spin.test_prune_metadata system test to catch a bug in the spin ID lookup table. Spin IDs appear not to be correctly removed from the lookup table. ........ r18232 | bugman | 2013-01-18 17:58:27 +0100 (Fri, 18 Jan 2013) | 5 lines Bug fix for generic_fns.mol_res_spin.metadata_prune(). Non-unique molecules and residues are now removed from the spin ID lookup table. ........ r18233 | bugman | 2013-01-18 18:05:41 +0100 (Fri, 18 Jan 2013) | 3 lines Added some more checks to the Mol_res_spin.test_prune_metadata system test to demonstrate more bugs. ........ r18234 | bugman | 2013-01-18 18:19:03 +0100 (Fri, 18 Jan 2013) | 7 lines Proper bug fix for the spin ID metadata lookup table pruning. The Mol_res_spin.test_prune_metadata system test now passes. The previous fix of r18232 was not complete, and it should have been in the spin_id_variants_elim() function rather than metadata_prune(). ........ Added: branches/frame_order_testing/test_suite/shared_data/align_data/pcs_dy_200911.txt - copied unchanged from r18234, trunk/test_suite/shared_data/align_data/pcs_dy_200911.txt Modified: branches/frame_order_testing/ (props changed) branches/frame_order_testing/generic_fns/mol_res_spin.py branches/frame_order_testing/generic_fns/pcs.py branches/frame_order_testing/test_suite/system_tests/mol_res_spin.py branches/frame_order_testing/test_suite/system_tests/pcs.py branches/frame_order_testing/test_suite/system_tests/pipes.py Propchange: branches/frame_order_testing/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Jan 18 18:22:57 2013 @@ -1,1 +1,1 @@ -/trunk:1-18220 +/trunk:1-18234 Modified: branches/frame_order_testing/generic_fns/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/mol_res_spin.py?rev=18235&r1=18234&r2=18235&view=diff ============================================================================== --- branches/frame_order_testing/generic_fns/mol_res_spin.py (original) +++ branches/frame_order_testing/generic_fns/mol_res_spin.py Fri Jan 18 18:22:57 2013 @@ -1964,6 +1964,7 @@ dp = pipes.get_pipe(pipe) # Loop over the molecules. + to_remove = [] for i in range(len(dp.mol)): # Molecule skipping. if mol_index != None and mol_index != i: @@ -1991,10 +1992,10 @@ spin = res.spin[k] # The list of IDs to remove. - spin_ids = spin_id_variants_elim(dp=dp, mol_index=i, res_index=j, spin_index=k) + to_remove = spin_id_variants_elim(dp=dp, mol_index=i, res_index=j, spin_index=k) # ID removal. - for spin_id in spin_ids: + for spin_id in to_remove: # Blank IDs. if spin_id == '': continue @@ -3271,13 +3272,18 @@ # The spin IDs without spin info. if spin_count > 1: spin_ids.append(generate_spin_id(mol_name=mol.name, res_num=res.num, res_name=res.name)) + spin_ids.append(generate_spin_id(res_num=res.num, res_name=res.name)) + spin_ids.append(generate_spin_id(mol_name=mol.name)) # The spin IDs without residue info. if res_count > 1: spin_ids.append(generate_spin_id(mol_name=mol.name, spin_num=spin.num, spin_name=spin.name)) + spin_ids.append(generate_spin_id(spin_num=spin.num, spin_name=spin.name)) + spin_ids.append(generate_spin_id(mol_name=mol.name)) # The spin IDs without molecule info. if mol_count > 1: + spin_ids.append(generate_spin_id(res_num=res.num, res_name=res.name)) spin_ids.append(generate_spin_id(res_num=res.num, res_name=res.name, spin_num=spin.num, spin_name=spin.name)) # The spin IDs without spin or residue info. Modified: branches/frame_order_testing/generic_fns/pcs.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/pcs.py?rev=18235&r1=18234&r2=18235&view=diff ============================================================================== --- branches/frame_order_testing/generic_fns/pcs.py (original) +++ branches/frame_order_testing/generic_fns/pcs.py Fri Jan 18 18:22:57 2013 @@ -613,6 +613,8 @@ # Get the corresponding spin container. id = generate_spin_id(mol_name=mol_name, res_num=res_num, res_name=res_name, spin_num=spin_num, spin_name=spin_name) spin = return_spin(id) + if spin == None and spin_id[0] == '@': # Allow spin IDs of atom names to be used to specify multi column data. + spin = return_spin(id+spin_id) if spin == None: warn(RelaxNoSpinWarning(id)) continue @@ -878,7 +880,7 @@ file = open_write_file(file, dir, force) # The header. - grace.write_xy_header(file=file, title="PCS structural noise", subtitle="%s Angstrom structural noise"%rmsd, sets=len(align_ids), set_names=align_ids, symbol_sizes=[0.5]*len(align_ids), linetype=[0]*len(align_ids), data_type=['pcs_bc', 'pcs'], axis_labels=["Ln\S3+\N to spin distance (Angstrom)", "PCS standard deviation (ppm)"]) + grace.write_xy_header(file=file, title="PCS structural noise", subtitle="%s Angstrom structural noise"%rmsd, sets=len(align_ids), set_names=align_ids, symbol_sizes=[0.5]*len(align_ids), linetype=[0]*len(align_ids), data_type=['pcs_bc', 'pcs'], axis_labels=["Ln\\S3+\\N to spin distance (Angstrom)", "PCS standard deviation (ppm)"]) # The main data. grace.write_xy_data(data=[grace_data], file=file, graph_type='xy') Modified: branches/frame_order_testing/test_suite/system_tests/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/system_tests/mol_res_spin.py?rev=18235&r1=18234&r2=18235&view=diff ============================================================================== --- branches/frame_order_testing/test_suite/system_tests/mol_res_spin.py (original) +++ branches/frame_order_testing/test_suite/system_tests/mol_res_spin.py Fri Jan 18 18:22:57 2013 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2012 Edward d'Auvergne # +# Copyright (C) 2012-2013 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -42,6 +42,31 @@ self.interpreter.pipe.create('mf', 'mf') + def test_prune_metadata(self): + """Check the proper pruning of the spin ID metadata.""" + + # Create a data pipe for all the data. + self.interpreter.pipe.create('CaM N-dom', 'N-state') + + # Create some spins. + self.interpreter.spin.create(spin_name='N', spin_num=1, res_name='Gly', res_num=3, mol_name='CaM') + self.interpreter.spin.create(spin_name='H', spin_num=2, res_name='Gly', res_num=3, mol_name='CaM') + + # Make sure that certain spin IDs have been removed. + print("The spin ID lookup table:\n%s" % cdp.mol._spin_id_lookup) + self.assert_(':3' not in cdp.mol._spin_id_lookup) + self.assert_('#CaM' not in cdp.mol._spin_id_lookup) + + # Create some more spins. + self.interpreter.spin.create(spin_name='N', spin_num=3, res_name='Gly', res_num=4, mol_name='CaM') + self.interpreter.spin.create(spin_name='H', spin_num=4, res_name='Gly', res_num=4, mol_name='CaM') + + # Make sure that certain spin IDs have been removed. + print("The spin ID lookup table:\n%s" % cdp.mol._spin_id_lookup) + self.assert_('@N' not in cdp.mol._spin_id_lookup) + self.assert_('@H' not in cdp.mol._spin_id_lookup) + + def test_residue_delete(self): """Test residue deletion.""" Modified: branches/frame_order_testing/test_suite/system_tests/pcs.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/system_tests/pcs.py?rev=18235&r1=18234&r2=18235&view=diff ============================================================================== --- branches/frame_order_testing/test_suite/system_tests/pcs.py (original) +++ branches/frame_order_testing/test_suite/system_tests/pcs.py Fri Jan 18 18:22:57 2013 @@ -25,6 +25,9 @@ # Python module imports. from os import sep +from re import search +from string import split +from tempfile import mkdtemp # relax module imports. from generic_fns.mol_res_spin import count_spins, spin_loop @@ -34,6 +37,153 @@ class Pcs(SystemTestCase): """Class for testing PCS operations.""" + + def test_grace_plot(self): + """Test the creation of Grace plots of PCS data.""" + + # Create a data pipe for all the data. + self.interpreter.pipe.create('CaM N-dom', 'N-state') + + # Create some spins. + self.interpreter.spin.create(spin_name='N', spin_num=1, res_name='Gly', res_num=3) + self.interpreter.spin.create(spin_name='H', spin_num=2, res_name='Gly', res_num=3) + self.interpreter.spin.create(spin_name='N', spin_num=3, res_name='Gly', res_num=4) + self.interpreter.spin.create(spin_name='H', spin_num=4, res_name='Gly', res_num=4) + self.interpreter.sequence.display() + + # Set the element type. + self.interpreter.spin.element(element='N', spin_id='@N') + self.interpreter.spin.element(element='H', spin_id='@H') + + # Data directory. + dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep + + # PCSs. + self.interpreter.pcs.read(align_id='dy', file='pcs_dy_200911.txt', dir=dir, res_num_col=1, data_col=2, error_col=4, spin_id='@N') + self.interpreter.pcs.read(align_id='dy', file='pcs_dy_200911.txt', dir=dir, res_num_col=1, data_col=3, error_col=4, spin_id='@H') + + # Fudge the back-calculated PCS data. + for spin in spin_loop(): + spin.pcs_bc = {} + spin.pcs_bc['dy'] = spin.pcs['dy'] + 0.1 + + # Create the grace plot. + self.tmpdir = mkdtemp() + self.interpreter.pcs.corr_plot(format='grace', file='pcs_corr.agr', dir=self.tmpdir, force=True) + + # Read the file data. + file = open(self.tmpdir+sep+'pcs_corr.agr') + lines = file.readlines() + file.close() + + # Check the diagonal data. + for i in range(len(lines)): + if search('G0.S0', lines[i]): + point1 = split(lines[i+2]) + point2 = split(lines[i+3]) + self.assertAlmostEqual(float(point1[0]), -100.0) + self.assertAlmostEqual(float(point1[1]), -100.0) + self.assertAlmostEqual(float(point2[0]), 100.0) + self.assertAlmostEqual(float(point2[1]), 100.0) + + # Check the 15N data. + for i in range(len(lines)): + if search('G0.S1', lines[i]): + point1 = split(lines[i+2]) + point2 = split(lines[i+3]) + self.assertAlmostEqual(float(point1[0]), 0.917+0.1) + self.assertAlmostEqual(float(point1[1]), 0.917) + self.assertAlmostEqual(float(point1[2]), 0.1) + self.assertAlmostEqual(float(point2[0]), 1.131+0.1) + self.assertAlmostEqual(float(point2[1]), 1.131) + self.assertAlmostEqual(float(point2[2]), 0.1) + + # Check the 1H data. + for i in range(len(lines)): + if search('G0.S2', lines[i]): + point1 = split(lines[i+2]) + point2 = split(lines[i+3]) + self.assertAlmostEqual(float(point1[0]), 0.843+0.1) + self.assertAlmostEqual(float(point1[1]), 0.843) + self.assertAlmostEqual(float(point1[2]), 0.1) + self.assertAlmostEqual(float(point2[0]), 1.279+0.1) + self.assertAlmostEqual(float(point2[1]), 1.279) + self.assertAlmostEqual(float(point2[2]), 0.1) + + + def test_load_multi_col_data(self): + """Test the loading of PCS data from a file with different columns for each spin type.""" + + # Create a data pipe for all the data. + self.interpreter.pipe.create('CaM N-dom', 'N-state') + + # Create some spins. + self.interpreter.spin.create(spin_name='N', spin_num=1, res_name='Gly', res_num=3) + self.interpreter.spin.create(spin_name='H', spin_num=2, res_name='Gly', res_num=3) + self.interpreter.spin.create(spin_name='N', spin_num=3, res_name='Gly', res_num=4) + self.interpreter.spin.create(spin_name='H', spin_num=4, res_name='Gly', res_num=4) + self.interpreter.sequence.display() + + # Data directory. + dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep + + # PCSs. + self.interpreter.pcs.read(align_id='dy', file='pcs_dy_200911.txt', dir=dir, res_num_col=1, data_col=2, error_col=4, spin_id='@N') + self.interpreter.pcs.read(align_id='dy', file='pcs_dy_200911.txt', dir=dir, res_num_col=1, data_col=3, error_col=4, spin_id='@H') + + # The data. + pcs_data = { + ':3@N': 0.917, + ':3@H': 0.843, + ':4@N': 1.131, + ':4@H': 1.279, + } + + # Check the PCS data. + print("\n") + for spin, spin_id in spin_loop(return_id=True): + print("Checking the PCS data of spin '%s'." % spin_id) + self.assert_(hasattr(spin, 'pcs')) + self.assertEqual(spin.pcs['dy'], pcs_data[spin_id]) + self.assertEqual(spin.pcs_err['dy'], 0.1) + + + def test_load_multi_col_data2(self): + """Test the loading of PCS data from a file with different columns for each spin type.""" + + # Create a data pipe for all the data. + self.interpreter.pipe.create('CaM N-dom', 'N-state') + + # Create some spins. + self.interpreter.spin.create(spin_name='N', spin_num=1, res_name='Gly', res_num=3, mol_name='CaM') + self.interpreter.spin.create(spin_name='H', spin_num=2, res_name='Gly', res_num=3, mol_name='CaM') + self.interpreter.spin.create(spin_name='N', spin_num=3, res_name='Gly', res_num=4, mol_name='CaM') + self.interpreter.spin.create(spin_name='H', spin_num=4, res_name='Gly', res_num=4, mol_name='CaM') + self.interpreter.sequence.display() + + # Data directory. + dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep + + # PCSs. + self.interpreter.pcs.read(align_id='dy', file='pcs_dy_200911.txt', dir=dir, res_num_col=1, data_col=2, error_col=4, spin_id='@N') + self.interpreter.pcs.read(align_id='dy', file='pcs_dy_200911.txt', dir=dir, res_num_col=1, data_col=3, error_col=4, spin_id='@H') + + # The data. + pcs_data = { + '#CaM:3@N': 0.917, + '#CaM:3@H': 0.843, + '#CaM:4@N': 1.131, + '#CaM:4@H': 1.279, + } + + # Check the PCS data. + print("\n") + for spin, spin_id in spin_loop(return_id=True): + print("Checking the PCS data of spin '%s'." % spin_id) + self.assert_(hasattr(spin, 'pcs')) + self.assertEqual(spin.pcs['dy'], pcs_data[spin_id]) + self.assertEqual(spin.pcs_err['dy'], 0.1) + def test_pcs_copy(self): """Test the operation of the pcs.copy user function.""" Modified: branches/frame_order_testing/test_suite/system_tests/pipes.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/test_suite/system_tests/pipes.py?rev=18235&r1=18234&r2=18235&view=diff ============================================================================== --- branches/frame_order_testing/test_suite/system_tests/pipes.py (original) +++ branches/frame_order_testing/test_suite/system_tests/pipes.py Fri Jan 18 18:22:57 2013 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2012 Edward d'Auvergne # +# Copyright (C) 2006-2013 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -24,6 +24,7 @@ # relax module imports. from data import Relax_data_store; ds = Relax_data_store() +import dep_check from generic_fns import pipes from status import Status; status = Status() from test_suite.system_tests.base_classes import SystemTestCase @@ -31,6 +32,22 @@ class Pipes(SystemTestCase): """TestCase class for the functional tests of relax data pipes.""" + + def __init__(self, methodName='runTest'): + """Skip some tests if scipy is not installed. + + @keyword methodName: The name of the test. + @type methodName: str + """ + + # Execute the base class method. + super(Pipes, self).__init__(methodName) + + # Missing module. + if not dep_check.scipy_module and methodName in ['test_change_type']: + # Store in the status object. + status.skipped_tests.append([methodName, 'Scipy', self._skip_type]) + def test_change_type(self): """Test the pipe.change_type user function."""