Author: bugman Date: Sun Oct 9 14:29:22 2011 New Revision: 14814 URL: http://svn.gna.org/viewcvs/relax?rev=14814&view=rev Log: Created the N-state model test_monte_carlo_sims() system test for checking MC sims with alignment data. Added: 1.3/test_suite/system_tests/scripts/n_state_model/monte_carlo_testing.py - copied, changed from r14812, 1.3/test_suite/system_tests/scripts/n_state_model/align_fit.py Modified: 1.3/test_suite/system_tests/n_state_model.py Modified: 1.3/test_suite/system_tests/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/n_state_model.py?rev=14814&r1=14813&r2=14814&view=diff ============================================================================== --- 1.3/test_suite/system_tests/n_state_model.py (original) +++ 1.3/test_suite/system_tests/n_state_model.py Sun Oct 9 14:29:22 2011 @@ -387,6 +387,58 @@ self.assertAlmostEqual(cdp.q_pcs, 0.0) + def test_monte_carlo_sims(self): + """Test the Monte Carlo simulation data of fitting RDCs and PCSs.""" + + # Execute the script. + self.interpreter.run(script_file=status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'n_state_model'+sep+'monte_carlo_testing.py') + + # Test the optimised values. + self.assertAlmostEqual(cdp.align_tensors[0].Axx, -0.351261/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Ayy, 0.556994/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Axy, -0.506392/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Axz, 0.560544/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Ayz, -0.286367/2000) + self.assertAlmostEqual(cdp.chi2, 1745860.0485368515) + self.assertAlmostEqual(cdp.q_rdc, 0.0) + self.assertAlmostEqual(cdp.q_pcs, 0.0) + + # The tensor key. + key = 'synth' + + # The spin data. + for spin in spin_loop(): + # Print out. + print(spin) + + # Check for simulation data. + self.assert_(hasattr(spin, 'rdc_sim')) + self.assert_(hasattr(spin, 'pcs_sim')) + self.assert_(spin.rdc_sim.has_key(key)) + self.assert_(spin.pcs_sim.has_key(key)) + + # Check the values of the simulated data. + for i in range(cdp.sim_number): + self.assertAlmostEqual(spin.rdc[key], spin.rdc_sim[key][i]) + self.assertAlmostEqual(spin.pcs[key], spin.pcs_sim[key][i]) + + # Test the optimised simluation values. + for i in range(cdp.sim_number): + self.assertAlmostEqual(cdp.align_tensors[0].Axx, -0.351261/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Ayy, 0.556994/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Axy, -0.506392/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Axz, 0.560544/2000) + self.assertAlmostEqual(cdp.align_tensors[0].Ayz, -0.286367/2000) + self.assertAlmostEqual(cdp.chi2, 1745860.0485368515) + + # Test the tensor error values. + self.assertAlmostEqual(cdp.align_tensors[0].Axx_err, 0.0) + self.assertAlmostEqual(cdp.align_tensors[0].Ayy_err, 0.0) + self.assertAlmostEqual(cdp.align_tensors[0].Axy_err, 0.0) + self.assertAlmostEqual(cdp.align_tensors[0].Axz_err, 0.0) + self.assertAlmostEqual(cdp.align_tensors[0].Ayz_err, 0.0) + + def test_paramag_centre_fit(self): """Test the use of RDCs and PCSs to find the alignment tensor.""" Copied: 1.3/test_suite/system_tests/scripts/n_state_model/monte_carlo_testing.py (from r14812, 1.3/test_suite/system_tests/scripts/n_state_model/align_fit.py) URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/scripts/n_state_model/monte_carlo_testing.py?p2=1.3/test_suite/system_tests/scripts/n_state_model/monte_carlo_testing.py&p1=1.3/test_suite/system_tests/scripts/n_state_model/align_fit.py&r1=14812&r2=14814&rev=14814&view=diff ============================================================================== --- 1.3/test_suite/system_tests/scripts/n_state_model/align_fit.py (original) +++ 1.3/test_suite/system_tests/scripts/n_state_model/monte_carlo_testing.py Sun Oct 9 14:29:22 2011 @@ -1,4 +1,4 @@ -"""Script for testing the fitting an alignment tensor to RDCs or PCSs.""" +"""Script for testing the Monte Carlo simulations of fitting an alignment tensor to RDCs and PCSs.""" # Python module imports. from os import sep @@ -11,26 +11,14 @@ # Path of the alignment data and structure. -DATA_PATH = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep+'CaM' -STRUCT_PATH = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures' +DATA_PATH = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'align_data'+sep+'monte_carlo_testing' +STRUCT_PATH = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'sphere' # Create the data pipe. -pipe.create('rdc', 'N-state') +pipe.create('MC test', 'N-state') -# Set the mode, if not specified by the system test. -if not hasattr(ds, 'mode'): - ds.mode = 'all' - -# The data to use. -if hasattr(ds, 'rand') and ds.rand: - rdc_file = 'synth_rdc_rand' - pcs_file = 'synth_pcs_rand' -else: - rdc_file = 'synth_rdc' - pcs_file = 'synth_pcs' - -# Load the CaM structure. -structure.read_pdb(file='bax_C_1J7P_N_H_Ca', dir=STRUCT_PATH) +# Load the test structure. +structure.read_pdb(file='sphere', dir=STRUCT_PATH) # Load the spins. structure.load_spins() @@ -44,35 +32,33 @@ value.set('1H', 'proton', spin_id="@N") # RDCs. -if ds.mode in ['rdc', 'all']: - rdc.read(align_id='synth', file=rdc_file, dir=DATA_PATH, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6) +rdc.read(align_id='synth', file='synth_rdc', dir=DATA_PATH, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7) # PCSs. -if ds.mode in ['pcs', 'all']: - pcs.read(align_id='synth', file=pcs_file, dir=DATA_PATH, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6) +pcs.read(align_id='synth', file='synth_pcs', dir=DATA_PATH, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7) - # Set the paramagnetic centre. - paramag.centre(atom_id=':1000@CA') +# Set the paramagnetic centre. +paramag.centre(pos=[10.0, 0.0, 0.0]) - # The temperature. - temperature(id='synth', temp=303) +# The temperature. +temperature(id='synth', temp=303) - # The frequency. - frq.set(id='synth', frq=600.0 * 1e6) +# The frequency. +frq.set(id='synth', frq=600.0 * 1e6) # Set up the model. n_state_model.select_model(model='fixed') -# Set the tensor elements. -#cdp.align_tensors[0].Axx = -0.351261/2000 -#cdp.align_tensors[0].Ayy = 0.556994/2000 -#cdp.align_tensors[0].Axy = -0.506392/2000 -#cdp.align_tensors[0].Axz = 0.560544/2000 -#cdp.align_tensors[0].Ayz = -0.286367/2000 - # Minimisation. grid_search(inc=3) minimise('simplex', constraints=False, max_iter=500) + +# Monte Carlo simulations. +monte_carlo.setup(3) +monte_carlo.create_data() +monte_carlo.initial_values() +minimise('simplex', constraints=False, max_iter=500) +monte_carlo.error_analysis() # Write out a results file. results.write('devnull', force=True)