Author: bugman Date: Wed Sep 4 19:03:17 2013 New Revision: 20817 URL: http://svn.gna.org/viewcvs/relax?rev=20817&view=rev Log: Redesigned the relax_disp.exp_type user function to be associated with spectrum IDs. This follows from http://thread.gmane.org/gmane.science.nmr.relax.devel/4530, the thread about supporting multiple data types such as SQ+MQ data simultaneously. The user function backend has been moved from specific_analyses.relax_disp.api to specific_analyses.relax_disp.disp_data. A few temporary code additions have been made to keep the user function functional with the current dispersion code. Modified: branches/relax_disp/specific_analyses/relax_disp/api.py branches/relax_disp/specific_analyses/relax_disp/disp_data.py branches/relax_disp/user_functions/relax_disp.py Modified: branches/relax_disp/specific_analyses/relax_disp/api.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/api.py?rev=20817&r1=20816&r2=20817&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/api.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/api.py Wed Sep 4 19:03:17 2013 @@ -278,36 +278,6 @@ # Return the IDs. return ids - - - def _exp_type(self, exp_type='cpmg fixed'): - """Select the relaxation dispersion experiment type performed. - - @keyword exp: The relaxation dispersion experiment type. Can be one of 'cpmg fixed', 'cpmg exponential', 'r1rho fixed' or 'r1rho exponential'. - @type exp: str - """ - - # Test if the current pipe exists. - pipes.test() - - # Printouts. - if exp_type == 'cpmg fixed': - print("The fixed relaxation time period CPMG-type experiments.") - elif exp_type == 'cpmg exponential': - print("The CPMG-type experiments consisting of full exponential curves for each dispersion point.") - elif exp_type == 'r1rho fixed': - print("The fixed relaxation time period R1rho-type experiments.") - elif exp_type == 'r1rho exponential': - print("The R1rho-type experiments consisting of full exponential curves for each dispersion point.") - else: - raise RelaxError("The relaxation dispersion experiment '%s' is invalid." % exp_type) - - # Sanity check. - if exp_type not in EXP_TYPE_LIST_FIXED_TIME and exp_type not in EXP_TYPE_LIST_VAR_TIME: - raise RelaxError("The experiment type '%s' is neither a fixed relaxation time period or variable relaxation time period experiment." % exp_type) - - # Store the value. - cdp.exp_type = exp_type def _grid_search_setup(self, spins=None, param_vector=None, lower=None, upper=None, inc=None, scaling_matrix=None): Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/disp_data.py?rev=20817&r1=20816&r2=20817&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Wed Sep 4 19:03:17 2013 @@ -46,7 +46,8 @@ from pipe_control import pipes from pipe_control.mol_res_spin import exists_mol_res_spin_data, return_spin, spin_loop from pipe_control.result_files import add_result_file -from specific_analyses.relax_disp.variables import EXP_TYPE_LIST_CPMG, EXP_TYPE_LIST_FIXED_TIME, EXP_TYPE_LIST_R1RHO +from pipe_control.spectrum import check_spectrum_id +from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG_FIXED, EXP_TYPE_CPMG_EXP, EXP_TYPE_DESC_CPMG_FIXED, EXP_TYPE_DESC_CPMG_EXP, EXP_TYPE_DESC_R1RHO_FIXED, EXP_TYPE_DESC_R1RHO_EXP, EXP_TYPE_LIST, EXP_TYPE_LIST_CPMG, EXP_TYPE_LIST_FIXED_TIME, EXP_TYPE_LIST_R1RHO, EXP_TYPE_R1RHO_FIXED, EXP_TYPE_R1RHO_EXP from stat import S_IRWXU, S_IRGRP, S_IROTH from os import chmod, path, sep @@ -181,6 +182,55 @@ print("Setting the '%s' spectrum CPMG frequency %s Hz." % (spectrum_id, cdp.cpmg_frqs[spectrum_id])) +def exp_type(spectrum_id=None, exp_type=None): + """Select the relaxation dispersion experiment type performed. + + @keyword spectrum_id: The spectrum ID string. + @type spectrum_id: str + @keyword exp: The relaxation dispersion experiment type. It can be one of 'cpmg fixed', 'cpmg exponential', 'r1rho fixed' or 'r1rho exponential'. + @type exp: str + """ + + # Data checks. + pipes.test() + check_spectrum_id(spectrum_id) + + # Check the experiment type. + if exp_type not in EXP_TYPE_LIST: + raise RelaxError("The relaxation dispersion experiment '%s' is invalid." % exp_type) + + # FIXME: Temporary solution to keep the branch functional. + cdp.exp_type = {} + + # Initialise the experiment type data structures if needed. + if not hasattr(cdp, 'exp_type'): + cdp.exp_type = {} + if not hasattr(cdp, 'exp_type_list'): + cdp.exp_type_list = [] + + # Store the value. + cdp.exp_type[spectrum_id] = exp_type + + # Unique experiments. + if cdp.exp_type[spectrum_id] not in cdp.exp_type_list: + cdp.exp_type_list.append(cdp.exp_type[spectrum_id]) + + # Printout. + text = "Setting the '%s' spectrum to" % spectrum_id + if exp_type == EXP_TYPE_CPMG_FIXED: + text += EXP_TYPE_DESC_CPMG_FIXED + "." + elif exp_type == EXP_TYPE_CPMG_EXP: + text += EXP_TYPE_DESC_CPMG_EXP + "." + elif exp_type == EXP_TYPE_R1RHO_FIXED: + text += EXP_TYPE_DESC_R1RHO_FIXED + "." + elif exp_type == EXP_TYPE_R1RHO_EXP: + text += EXP_TYPE_DESC_R1RHO_EXP + "." + print(text) + + # FIXME: Temporary solution to keep the branch functional. + cdp.exp_type = exp_type + + def find_intensity_keys(frq=None, point=None, time=None): """Return the key corresponding to the spectrometer frequency, dispersion point, and relaxation time. Modified: branches/relax_disp/user_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/relax_disp.py?rev=20817&r1=20816&r2=20817&view=diff ============================================================================== --- branches/relax_disp/user_functions/relax_disp.py (original) +++ branches/relax_disp/user_functions/relax_disp.py Wed Sep 4 19:03:17 2013 @@ -37,7 +37,7 @@ from pipe_control.mol_res_spin import get_spin_ids from graphics import ANALYSIS_IMAGE_PATH, WIZARD_IMAGE_PATH from specific_analyses.relax_disp.cpmgfit import cpmgfit_execute, cpmgfit_input -from specific_analyses.relax_disp.disp_data import cpmg_frq, plot_disp_curves, plot_exp_curves, relax_time, spin_lock_field, spin_lock_offset +from specific_analyses.relax_disp.disp_data import cpmg_frq, exp_type, plot_disp_curves, plot_exp_curves, relax_time, spin_lock_field, spin_lock_offset from specific_analyses.relax_disp.nessy import nessy_input from specific_analyses.relax_disp.parameters import copy from specific_analyses.relax_disp.sherekhan import sherekhan_input @@ -224,8 +224,17 @@ # The relax_disp.exp_type user function. uf = uf_info.add_uf('relax_disp.exp_type') -uf.title = "Select the type of relaxation dispersion experiments to be analysed." +uf.title = "Select the relaxation dispersion experiment type." uf.title_short = "Relaxation dispersion experiment type selection." +uf.add_keyarg( + name = "spectrum_id", + py_type = "str", + desc_short = "spectrum ID string", + desc = "The spectrum ID string to associate the spin-lock field strength to.", + wiz_element_type = 'combo', + wiz_combo_iter = spectrum.get_ids, + wiz_read_only = True +) uf.add_keyarg( name = "exp_type", default = "cpmg fixed", @@ -236,8 +245,8 @@ wiz_combo_choices = [ "CPMG, fixed time", "CPMG, full exponential", - "R1rho, fixed time", - "R1rho, full exponential" + u("R\u2081\u1D68, fixed time"), + u("R\u2081\u1D68, full exponential") ], wiz_combo_data = [ "cpmg fixed", @@ -249,6 +258,7 @@ ) # Description. uf.desc.append(Desc_container()) +uf.desc[-1].add_paragraph("Peak intensities should already be loaded using the spectrum.read_intensities user function. The intensity values will then be associated with a spectrum ID. To allow for different data types to be analysed together, each spectrum ID must be associated an experiment type.") uf.desc[-1].add_paragraph("The currently supported experiments include:") uf.desc[-1].add_item_list_element("'cpmg fixed'", "The fixed relaxation time period CPMG-type experiments,") uf.desc[-1].add_item_list_element("'cpmg exponential'", "The full exponential curve CPMG-type experiments,") @@ -275,7 +285,7 @@ uf.desc[-1].add_paragraph("To pick the experiment type 'cpmg fixed' for all selected spins, type one of:") uf.desc[-1].add_prompt("relax> relax_disp.exp_type('cpmg fixed')") uf.desc[-1].add_prompt("relax> relax_disp.exp_type(exp_type='cpmg fixed')") -uf.backend = relax_disp_obj._exp_type +uf.backend = exp_type uf.menu_text = "&exp_type" uf.wizard_height_desc = 500 uf.wizard_size = (1000, 700)