Author: tlinnet Date: Wed Aug 20 13:56:47 2014 New Revision: 25088 URL: http://svn.gna.org/viewcvs/relax?rev=25088&view=rev Log: Moved the unit test of specific_analyses.relax_disp.checks.check_missing_r1() from a unit test to a system test. This is because the unit test involved several functions of relax. Modified: trunk/test_suite/system_tests/relax_disp.py trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_checks.py Modified: trunk/test_suite/system_tests/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/relax_disp.py?rev=25088&r1=25087&r2=25088&view=diff ============================================================================== --- trunk/test_suite/system_tests/relax_disp.py (original) +++ trunk/test_suite/system_tests/relax_disp.py Wed Aug 20 13:56:47 2014 @@ -33,6 +33,7 @@ import dep_check from lib.io import get_file_path from pipe_control.mol_res_spin import generate_spin_string, return_spin, spin_loop +from specific_analyses.relax_disp.checks import check_missing_r1 from specific_analyses.relax_disp.data import generate_r20_key, get_curve_type, has_r1rho_exp_type, loop_exp_frq, loop_exp_frq_offset_point, return_grace_file_name_ini, return_param_key_from_data from specific_analyses.relax_disp.data import INTERPOLATE_DISP, INTERPOLATE_OFFSET, X_AXIS_DISP, X_AXIS_W_EFF, X_AXIS_THETA, Y_AXIS_R2_R1RHO, Y_AXIS_R2_EFF from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_DQ, EXP_TYPE_CPMG_MQ, EXP_TYPE_CPMG_PROTON_MQ, EXP_TYPE_CPMG_PROTON_SQ, EXP_TYPE_CPMG_SQ, EXP_TYPE_CPMG_ZQ, EXP_TYPE_R1RHO, MODEL_B14_FULL, MODEL_CR72, MODEL_CR72_FULL, MODEL_DPL94, MODEL_DPL94_FIT_R1, MODEL_IT99, MODEL_LM63, MODEL_M61B, MODEL_MP05, MODEL_MP05_FIT_R1, MODEL_NOREX, MODEL_NOREX_R1RHO, MODEL_NOREX_R1RHO_FIT_R1, MODEL_NS_CPMG_2SITE_3D_FULL, MODEL_NS_CPMG_2SITE_EXPANDED, MODEL_NS_CPMG_2SITE_STAR_FULL, MODEL_NS_R1RHO_2SITE, MODEL_NS_R1RHO_2SITE_FIT_R1, MODEL_PARAMS, MODEL_R2EFF, MODEL_TP02, MODEL_TP02_FIT_R1, MODEL_TAP03, MODEL_TAP03_FIT_R1 @@ -691,6 +692,36 @@ self.interpreter.minimise.calculate(verbosity=1) + def setup_missing_r1_spins(self): + """Function for setting up a few spins for the given pipe.""" + + # Path to file. + data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' + + # File with spins. + file = open(data_path+sep+'R1_fitted_values.txt') + lines = file.readlines() + file.close() + + for i, line in enumerate(lines): + # Make the string test + line_split = line.split() + + if line_split[0] == "#": + continue + + mol_name = line_split[0] + mol_name = None + res_num = int(line_split[1]) + res_name = line_split[2] + spin_num = line_split[3] + spin_num = None + spin_name = line_split[4] + + # Create the spin. + self.interpreter.spin.create(spin_name=spin_name, spin_num=spin_num, res_name=res_name, res_num=res_num, mol_name=mol_name) + + def setup_tp02_data_to_ns_r1rho_2site(self, clustering=False): """Setup data for the test of relaxation dispersion 'NS R1rho 2-site' model fitting against the 'TP02' test data.""" @@ -1319,6 +1350,43 @@ # Assert that the number of columns is equal, plus 1 for "#". self.assertEqual(nr_split_header, len(line_split_val) + 1) + + + def test_check_missing_r1(self): + """Test of the check_missing_r1() function.""" + + # Set up some spins. + self.setup_missing_r1_spins() + + # Set variables. + exp_type = 'R1rho' + frq = 800.1 * 1E6 + + spectrum_id='test' + + # Set an experiment type to the pipe. + self.interpreter.relax_disp.exp_type(spectrum_id=spectrum_id, exp_type=exp_type) + + # Set a frequency to loop through. + self.interpreter.spectrometer.frequency(id=spectrum_id, frq=frq, units='Hz') + + # Check R1 for DPL94. + check_missing_r1_return = check_missing_r1(model=MODEL_DPL94) + self.assertEqual(check_missing_r1_return, True) + + # Check R1 for R2eff. + check_missing_r1_return = check_missing_r1(model=MODEL_R2EFF) + self.assertEqual(check_missing_r1_return, False) + + # The path to the data files. + data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' + + # Now load some R1 data. + self.interpreter.relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', 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) + + # Check R1. + check_missing_r1_return = check_missing_r1(model=MODEL_DPL94) + self.assertEqual(check_missing_r1_return, False) def test_cpmg_synthetic_b14_to_ns3d_cluster(self): Modified: trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_checks.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_checks.py?rev=25088&r1=25087&r2=25088&view=diff ============================================================================== --- trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_checks.py (original) +++ trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_checks.py Wed Aug 20 13:56:47 2014 @@ -24,91 +24,13 @@ from os import sep # relax module imports. -from data_store import Relax_data_store; ds = Relax_data_store() -from pipe_control import mol_res_spin, pipes, relax_data, spectrometer, state -from specific_analyses.relax_disp.checks import check_missing_r1, get_times -from specific_analyses.relax_disp.data import set_exp_type -from specific_analyses.relax_disp.variables import MODEL_DPL94, MODEL_R2EFF -from status import Status; status = Status() +from pipe_control import state +from specific_analyses.relax_disp.checks import get_times from test_suite.unit_tests.base_classes import UnitTestCase class Test_checks(UnitTestCase): """Unit tests for the functions of the specific_analyses.relax_disp.checks module.""" - - def setUp(self): - """Setup some structures for the unit tests.""" - - # Create a dispersion data pipe. - ds.add(pipe_name='orig', pipe_type='relax_disp') - - - def set_up_spins(self, pipe_name=None): - """Function for setting up a few spins for the given pipe.""" - - # Alias the pipe. - pipe = pipes.get_pipe(pipe_name) - - # Path to file. - data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' - - # File with spins. - file = open(data_path+sep+'R1_fitted_values.txt') - lines = file.readlines() - file.close() - - for i, line in enumerate(lines): - # Make the string test - line_split = line.split() - - if line_split[0] == "#": - continue - - mol_name = line_split[0] - mol_name = None - res_num = int(line_split[1]) - res_name = line_split[2] - spin_num = line_split[3] - spin_num = None - spin_name = line_split[4] - - # Create the spin. - mol_res_spin.create_spin(spin_num=spin_num, spin_name=spin_name, res_num=res_num, res_name=res_name, mol_name=mol_name, pipe=pipe_name) - - - def test_check_missing_r1(self): - """Unit test of the check_missing_r1() function.""" - - # Set up some spins. - self.set_up_spins(pipe_name='orig') - - # Set variables. - exp_type = 'R1rho' - frq = 800.1 * 1E6 - - # Set an experiment type to the pipe. - set_exp_type(spectrum_id='test', exp_type=exp_type) - - # Set a frequency to loop through. - spectrometer.set_frequency(id='test', frq=frq, units='Hz') - - # Check R1 for DPL94. - check_missing_r1_return = check_missing_r1(model=MODEL_DPL94) - self.assertEqual(check_missing_r1_return, True) - - # Check R1 for R2eff. - check_missing_r1_return = check_missing_r1(model=MODEL_R2EFF) - self.assertEqual(check_missing_r1_return, False) - - # The path to the data files. - data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'Kjaergaard_et_al_2013' - - # Now load some R1 data. - relax_data.read(ri_id='R1', ri_type='R1', frq=cdp.spectrometer_frq_list[0], file='R1_fitted_values.txt', 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) - - # Check R1. - check_missing_r1_return = check_missing_r1(model=MODEL_DPL94) - self.assertEqual(check_missing_r1_return, False) def test_get_times_cpmg(self):