Author: bugman Date: Tue Nov 19 17:42:30 2013 New Revision: 21529 URL: http://svn.gna.org/viewcvs/relax?rev=21529&view=rev Log: Many more fixes for the MMQ-type dispersion models for the proton spin data. Modified: branches/relax_disp/specific_analyses/relax_disp/api.py branches/relax_disp/specific_analyses/relax_disp/disp_data.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=21529&r1=21528&r2=21529&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/api.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/api.py Tue Nov 19 17:42:30 2013 @@ -36,7 +36,7 @@ # relax module imports. from dep_check import C_module_exp_fn from lib.dispersion.two_point import calc_two_point_r2eff, calc_two_point_r2eff_err -from lib.errors import RelaxError +from lib.errors import RelaxError, RelaxImplementError from lib.text.sectioning import subsection from multi import Processor_box from pipe_control import pipes, sequence @@ -116,6 +116,10 @@ @rtype: numpy rank-1 float array """ + # Skip protons for MMQ data. + if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H': + return + # Create the initial parameter vector. param_vector = assemble_param_vector(spins=[spin]) @@ -695,14 +699,28 @@ # All other models (the base data is the R2eff/R1rho values). else: + # MMQ flags. + proton_sq_flag = has_proton_sq_cpmg() + proton_mq_flag = has_proton_mq_cpmg() + proton_mmq_flag = proton_sq_flag or proton_mq_flag + # Loop over the sequence. for spin, spin_id in spin_loop(return_id=True): + # Skip protons for MMQ data. + if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H': + continue + # Skip deselected spins. if not spin.select: continue + # Get the attached proton. + proton = None + if proton_mmq_flag: + proton = return_attached_protons(spin_id)[0] + # Skip spins with no R2eff/R1rho values. - if not hasattr(spin, 'r2eff'): + if not hasattr(spin, 'r2eff') and not hasattr(proton, 'r2eff'): continue # Yield the spin container and ID. @@ -1115,11 +1133,17 @@ @rtype: list of float """ - # Get the spin container. - spin = return_spin(spin_id) - - # Return the data. - return spin.intensities + # The R2eff model. + if cdp.model_type == 'R2eff': + # Unpack the data. + spin, exp_type, frq, point = data_id + + # Return the data. + return spin.intensities + + # All other models. + else: + raise RelaxImplementError return_data_name_doc = Desc_container("Relaxation dispersion curve fitting data type string matching patterns") @@ -1167,8 +1191,23 @@ # Unpack the data. spin, spin_id = data_id + # MMQ flags. + proton_sq_flag = has_proton_sq_cpmg() + proton_mq_flag = has_proton_mq_cpmg() + proton_mmq_flag = proton_sq_flag or proton_mq_flag + + # Get the attached proton. + proton = None + if proton_mmq_flag: + proton = return_attached_protons(spin_id)[0] + # The errors. - return spin.r2eff_err + r2eff_err = {} + if hasattr(spin, 'r2eff_err'): + r2eff_err.update(spin.r2eff_err) + if hasattr(proton, 'r2eff_err'): + r2eff_err.update(proton.r2eff_err) + return r2eff_err # Return the error list. return errors @@ -1297,10 +1336,14 @@ # Set the Monte Carlo parameter values. ####################################### - # Loop over the residues. + # Loop over the spins. for spin in spin_loop(): - # Skip deselected residues. + # Skip deselected spins. if not spin.select: + continue + + # Skip protons for MMQ data. + if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H': continue # Loop over all the data names. @@ -1391,8 +1434,20 @@ # Unpack the data. spin, spin_id = data_id + # MMQ flags. + proton_sq_flag = has_proton_sq_cpmg() + proton_mq_flag = has_proton_mq_cpmg() + proton_mmq_flag = proton_sq_flag or proton_mq_flag + + # Get the attached proton. + proton = None + if proton_mmq_flag: + proton = return_attached_protons(spin_id)[0] + # Pack the data. spin.r2eff_sim = sim_data + if proton != None: + proton.r2eff_sim = sim_data def sim_return_param(self, model_info, index): 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=21529&r1=21528&r2=21529&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Tue Nov 19 17:42:30 2013 @@ -1049,6 +1049,25 @@ for exp_type, exp_type_index in loop_exp(return_indices=True): # Loop over each spin. for spin, spin_id in spin_loop(return_id=True, skip_desel=True): + # Skip protons for MMQ data. + if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H': + continue + + # MMQ flags. + proton_sq_flag = has_proton_sq_cpmg() + proton_mq_flag = has_proton_mq_cpmg() + proton_mmq_flag = proton_sq_flag or proton_mq_flag + + # Get the attached proton. + proton = None + if proton_mmq_flag: + proton = return_attached_protons(spin_id)[0] + + # Alias the correct spin. + current_spin = spin + if exp_type in [EXP_TYPE_CPMG_PROTON_SQ, EXP_TYPE_CPMG_PROTON_MQ]: + current_spin = proton + # The unique file name. file_name = "disp%s.agr" % spin_id.replace('#', '_').replace(':', '_').replace('@', '_') if num_exp_types() > 1: @@ -1086,16 +1105,16 @@ key = return_param_key_from_data(frq=frq, point=point) # No data present. - if key not in spin.r2eff: + if key not in current_spin.r2eff: continue # Add the data. - data[-1].append([point, spin.r2eff[key]]) + data[-1].append([point, current_spin.r2eff[key]]) # Add the error. - if hasattr(spin, 'r2eff_err') and key in spin.r2eff_err: + if hasattr(current_spin, 'r2eff_err') and key in current_spin.r2eff_err: err = True - data[-1][-1].append(spin.r2eff_err[key]) + data[-1][-1].append(current_spin.r2eff_err[key]) # Add the back-calculated data. for frq, frq_index in loop_frq(return_indices=True): @@ -1117,11 +1136,11 @@ key = return_param_key_from_data(frq=frq, point=point) # No data present. - if not hasattr(spin, 'r2eff_bc') or key not in spin.r2eff_bc: + if not hasattr(current_spin, 'r2eff_bc') or key not in current_spin.r2eff_bc: continue # Add the data. - data[-1].append([point, spin.r2eff_bc[key]]) + data[-1].append([point, current_spin.r2eff_bc[key]]) # Handle the errors. if err: @@ -1144,16 +1163,16 @@ key = return_param_key_from_data(frq=frq, point=point) # No data present. - if key not in spin.r2eff or not hasattr(spin, 'r2eff_bc') or key not in spin.r2eff_bc: + if key not in current_spin.r2eff or not hasattr(current_spin, 'r2eff_bc') or key not in current_spin.r2eff_bc: continue # Add the data. - data[-1].append([point, spin.r2eff[key] - spin.r2eff_bc[key]]) + data[-1].append([point, current_spin.r2eff[key] - current_spin.r2eff_bc[key]]) # Handle the errors. if err: err = True - data[-1][-1].append(spin.r2eff_err[key]) + data[-1][-1].append(current_spin.r2eff_err[key]) # The axis labels. if exp_type in EXP_TYPE_LIST_CPMG: @@ -1234,9 +1253,28 @@ # Loop over each spin. for spin, id in spin_loop(return_id=True, skip_desel=True): + # Skip protons for MMQ data. + if spin.model in MODEL_LIST_MMQ and spin.isotope == '1H': + continue + # No data present. if not hasattr(spin, 'intensities'): continue + + # MMQ flags. + proton_sq_flag = has_proton_sq_cpmg() + proton_mq_flag = has_proton_mq_cpmg() + proton_mmq_flag = proton_sq_flag or proton_mq_flag + + # Get the attached proton. + proton = None + if proton_mmq_flag: + proton = return_attached_protons(spin_id)[0] + + # Alias the correct spin. + current_spin = spin + if exp_type in [EXP_TYPE_CPMG_PROTON_SQ, EXP_TYPE_CPMG_PROTON_MQ]: + current_spin = proton # Append a new set structure and set the name to the spin ID. data[graph_index].append([]) @@ -1251,15 +1289,15 @@ # Loop over each key. for key in keys: # No key present. - if key not in spin.intensities: + if key not in current_spin.intensities: continue # Add the data. - if hasattr(spin, 'intensity_err'): - data[graph_index][-1].append([time, spin.intensities[key], spin.intensity_err[key]]) + if hasattr(current_spin, 'intensity_err'): + data[graph_index][-1].append([time, current_spin.intensities[key], spin.intensity_err[key]]) err = True else: - data[graph_index][-1].append([time, spin.intensities[key]]) + data[graph_index][-1].append([time, current_spin.intensities[key]]) # Increment the frq index. graph_index += 1