def test_value_set_r1_rit(self): """Test of the pipe_control.value.set() function.""" # Set the current data pipe to 'mf'. pipes.switch('relax_disp') # 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') # Generate dic key. r20_key = generate_r20_key(exp_type=exp_type, frq=frq) # Set first similar to r2. value.set(val=None, param='r2') self.assertEqual(cdp.mol[0].res[0].spin[0].r2[r20_key], 10.0) # Then set for r1. value.set(val=None, param='r1') print(cdp.mol[0].res[0].spin[0]) self.assertEqual(cdp.mol[0].res[0].spin[0].r1[r20_key], 2.0)
def test_value_set_r1_rit(self): """Test of the pipe_control.value.set() function.""" # Set the current data pipe to 'mf'. pipes.switch('relax_disp') # 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') # Generate dic key. r20_key = generate_r20_key(exp_type=exp_type, frq=frq) # Set first similar to r2. value.set(val=None, param='r2') self.assertEqual(cdp.mol[0].res[0].spin[0].r2[r20_key], 10.0) # Then set for r1. value.set(val=None, param='r1') print(cdp.mol[0].res[0].spin[0]) self.assertEqual(cdp.mol[0].res[0].spin[0].r1[r20_key], 2.0)
relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) # Relaxation dispersion CPMG constant time delay T (in s). relax_disp.relax_time(spectrum_id=new_id, time=relax_time) # Set the CPMG frequency. relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir=DATA_PATH, spin_id=spin_id, disp_point_col=7, data_col=10, error_col=9) # Change the model. relax_disp.select_model('NS MMQ 3-site linear') # The R20 keys. r20_1h_sq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=400e6) r20_1h_sq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_1h_sq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) r20_1h_sq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=1000e6) r20_sq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=400e6) r20_sq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_sq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_sq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=1000e6) r20_zq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=400e6) r20_zq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) r20_zq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) r20_zq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=1000e6) r20_dq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=400e6) r20_dq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) r20_dq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) r20_dq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=1000e6)
# Set the offset. relax_disp.spin_lock_offset(spectrum_id=new_id, offset=-frequency_to_ppm(frq=offset, B0=H_frq, isotope='15N')) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='..', spin_id=':1', offset_col=6, data_col=10, error_col=9) # Load the R1 data. relax_data.read(ri_id='600MHz', ri_type='R1', frq=600e6, file='R1_600MHz.out', dir='..', 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) relax_data.read(ri_id='800MHz', ri_type='R1', frq=800e6, file='R1_800MHz.out', dir='..', 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) # Change the model. relax_disp.select_model('NS R1rho 3-site linear') # The R20 keys. r20_600_key = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=600e6) r20_800_key = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) # Manually set the parameter values. spin = cdp.mol[0].res[0].spin[0] spin.r2 = { r20_600_key: 8.000284037933310, r20_800_key: 9.000296050530716, } spin.pA = 0.850029879276267 spin.pB = 0.049922261890898 spin.pC = 0.100047858832835 spin.kex_AB = 500.991549690434681 spin.kex_AC = 0.0 spin.kex_BC = 2003.189830166320235 spin.dw_AB = -2.991465198310455
def loop_parameters(spins=None): """Generator function for looping of the parameters of the cluster. @keyword spins: The list of spin data containers for the block. @type spins: list of SpinContainer instances @return: The parameter name, the parameter index (for the parameter vector), the spin index (for the cluster), and the R20 parameter key (for R20, R20A, and R20B parameters stored as dictionaries). @rtype: str, int, int, str """ # Make sure that the R1 parameter is correctly set up. r1_setup() # The parameter index. param_index = -1 # The R2eff model. if cdp.model_type == 'R2eff': # Loop over the spins. for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # Yield the two parameters. params = ['r2eff', 'i0'] for i in range(2): # First increment the indices. param_index += 1 # Yield the data. yield params[i], param_index, spin_index, None # All other models. else: # First the R1 fit parameter (one per spin per field strength). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The R1 parameter. if 'r1' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r1', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # Then the R2 parameters (one per spin per field strength). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The R2 parameter. if 'r2' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r2', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # The R2A parameter. if 'r2a' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r2a', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # The R2B parameter. if 'r2b' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r2b', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # Then the chemical shift difference parameters 'phi_ex', 'phi_ex_B', 'phi_ex_C', 'padw2', 'dw', 'dw_AB', 'dw_BC', 'dw_AB' (one per spin). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # Yield the data. if 'phi_ex' in spins[spin_index].params: param_index += 1 yield 'phi_ex', param_index, spin_index, None if 'phi_ex_B' in spins[spin_index].params: param_index += 1 yield 'phi_ex_B', param_index, spin_index, None if 'phi_ex_C' in spins[spin_index].params: param_index += 1 yield 'phi_ex_C', param_index, spin_index, None if 'padw2' in spins[spin_index].params: param_index += 1 yield 'padw2', param_index, spin_index, None if 'dw' in spins[spin_index].params: param_index += 1 yield 'dw', param_index, spin_index, None if 'dw_AB' in spins[spin_index].params: param_index += 1 yield 'dw_AB', param_index, spin_index, None if 'dw_BC' in spins[spin_index].params: param_index += 1 yield 'dw_BC', param_index, spin_index, None if 'dw_AC' in spins[spin_index].params: param_index += 1 yield 'dw_AC', param_index, spin_index, None # Then a separate block for the proton chemical shift difference parameters for the MQ models (one per spin). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue if 'dwH' in spins[spin_index].params: param_index += 1 yield 'dwH', param_index, spin_index, None if 'dwH_AB' in spins[spin_index].params: param_index += 1 yield 'dwH_AB', param_index, spin_index, None if 'dwH_BC' in spins[spin_index].params: param_index += 1 yield 'dwH_BC', param_index, spin_index, None if 'dwH_AC' in spins[spin_index].params: param_index += 1 yield 'dwH_AC', param_index, spin_index, None # All other parameters (one per spin cluster). for param in spins[0].params: if not param in ['r1', 'r2', 'r2a', 'r2b', 'phi_ex', 'phi_ex_B', 'phi_ex_C', 'padw2', 'dw', 'dw_AB', 'dw_BC', 'dw_AB', 'dwH', 'dwH_AB', 'dwH_BC', 'dwH_AB']: param_index += 1 yield param, param_index, None, None
relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) # Relaxation dispersion CPMG constant time delay T (in s). relax_disp.relax_time(spectrum_id=new_id, time=relax_time) # Set the CPMG frequency. relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='..', spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) # Change the model. relax_disp.select_model('MMQ CR72') # The R20 keys. r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6) r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6) r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6) r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6) r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6) r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) # Relaxation dispersion CPMG constant time delay T (in s). relax_disp.relax_time(spectrum_id=new_id, time=relax_time) # Set the CPMG frequency. relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='..', spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) # Change the model. relax_disp.select_model('NS MMQ 2-site') # The R20 keys. r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_key7 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6) r20_key8 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) r20_key9 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) r20_key10 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6) r20_key11 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) r20_key12 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) r20_key13 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6) r20_key14 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=600e6) r20_key15 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=800e6) r20_key16 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6)
pipe.switch(pipe_name=pipe_name) print("\nModel: %s" % (model)) # Loop over the spins. for cur_spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True): # Generate spin string. spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn) # Loop over the parameters. print("\nOptimised parameters for spin: %s" % (spin_string)) for param in cur_spin.params + ['chi2']: # Get the value. if param in ['r1', 'r2']: for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True): # Generate the R20 key. r20_key = generate_r20_key(exp_type=exp_type, frq=frq) # Get the value. value = getattr(cur_spin, param)[r20_key] # Print value. print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value)) # For all other parameters. else: # Get the value. value = getattr(cur_spin, param) # Print value. print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value))
# NS : r2a = r2b model_analyse_list.append(MODEL_NS_CPMG_2SITE_3D) model_analyse_list.append(MODEL_NS_CPMG_2SITE_STAR) model_analyse_list.append(MODEL_NS_CPMG_2SITE_EXPANDED) # NS full : r2a = r2b model_analyse_list.append(MODEL_NS_CPMG_2SITE_3D_FULL) model_analyse_list.append(MODEL_NS_CPMG_2SITE_STAR_FULL) # The model. model_analyse = model_analyse_list[10] ## Experiments # Exp 1 sfrq_1 = 500.0*1E6 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1) time_T2_1 = 0.05 ncycs_1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 50] # Here you define the direct R2eff errors (rad/s), as being added or subtracted for the created R2eff point in the corresponding ncyc cpmg frequence. #r2eff_errs_1 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05] r2eff_errs_1 = [0.0] * len(ncycs_1) exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1] sfrq_2 = 600.0*1E6 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2) time_T2_2 = 0.06 ncycs_2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 60] # Here you define the direct R2eff errors (rad/s), as being added or subtracted for the created R2eff point in the corresponding ncyc cpmg frequence. #r2eff_errs_2 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05] r2eff_errs_2 = [0.0] * len(ncycs_2) exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
def loop_parameters(spins=None): """Generator function for looping of the parameters of the cluster. @keyword spins: The list of spin data containers for the block. @type spins: list of SpinContainer instances @return: The parameter name, the parameter index (for the parameter vector), the spin index (for the cluster), and the R20 parameter key (for R20, R20A, and R20B parameters stored as dictionaries). @rtype: str, int, int, str """ # Make sure that the R1 parameter is correctly set up. r1_setup() # The parameter index. param_index = -1 # The R2eff model. if cdp.model_type == 'R2eff': # Loop over the spins. for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # Yield the two parameters. params = ['r2eff', 'i0'] for i in range(2): # First increment the indices. param_index += 1 # Yield the data. yield params[i], param_index, spin_index, None # All other models. else: # First the R1 fit parameter (one per spin per field strength). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The R1 parameter. if 'r1' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r1', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # Then the R2 parameters (one per spin per field strength). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The R2 parameter. if 'r2' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r2', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # The R2A parameter. if 'r2a' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r2a', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # The R2B parameter. if 'r2b' in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield 'r2b', param_index, spin_index, generate_r20_key(exp_type=exp_type, frq=frq) # Then the chemical shift difference parameters 'phi_ex', 'phi_ex_B', 'phi_ex_C', 'padw2', 'dw', 'dw_AB', 'dw_BC', 'dw_AB' (one per spin). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # Yield the data. if 'phi_ex' in spins[spin_index].params: param_index += 1 yield 'phi_ex', param_index, spin_index, None if 'phi_ex_B' in spins[spin_index].params: param_index += 1 yield 'phi_ex_B', param_index, spin_index, None if 'phi_ex_C' in spins[spin_index].params: param_index += 1 yield 'phi_ex_C', param_index, spin_index, None if 'padw2' in spins[spin_index].params: param_index += 1 yield 'padw2', param_index, spin_index, None if 'dw' in spins[spin_index].params: param_index += 1 yield 'dw', param_index, spin_index, None if 'dw_AB' in spins[spin_index].params: param_index += 1 yield 'dw_AB', param_index, spin_index, None if 'dw_BC' in spins[spin_index].params: param_index += 1 yield 'dw_BC', param_index, spin_index, None if 'dw_AC' in spins[spin_index].params: param_index += 1 yield 'dw_AC', param_index, spin_index, None # Then a separate block for the proton chemical shift difference parameters for the MQ models (one per spin). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue if 'dwH' in spins[spin_index].params: param_index += 1 yield 'dwH', param_index, spin_index, None if 'dwH_AB' in spins[spin_index].params: param_index += 1 yield 'dwH_AB', param_index, spin_index, None if 'dwH_BC' in spins[spin_index].params: param_index += 1 yield 'dwH_BC', param_index, spin_index, None if 'dwH_AC' in spins[spin_index].params: param_index += 1 yield 'dwH_AC', param_index, spin_index, None # All other parameters (one per spin cluster). for param in spins[0].params: if not param in ['r1', 'r2', 'r2a', 'r2b', 'phi_ex', 'phi_ex_B', 'phi_ex_C', 'padw2', 'dw', 'dw_AB', 'dw_BC', 'dw_AB', 'dwH', 'dwH_AB', 'dwH_BC', 'dwH_AB']: param_index += 1 yield param, param_index, None, None
# NS : r2a = r2b model_analyse_list.append(MODEL_NS_CPMG_2SITE_3D) model_analyse_list.append(MODEL_NS_CPMG_2SITE_STAR) model_analyse_list.append(MODEL_NS_CPMG_2SITE_EXPANDED) # NS full : r2a = r2b model_analyse_list.append(MODEL_NS_CPMG_2SITE_3D_FULL) model_analyse_list.append(MODEL_NS_CPMG_2SITE_STAR_FULL) # The model. model_analyse = model_analyse_list[0] ## Experiments # Exp 1 sfrq_1 = 599.8908617*1E6 r20_key_1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_1) time_T2_1 = 0.06 ncycs_1 = [28, 4, 32, 60, 2, 10, 16, 8, 20, 50, 18, 40, 6, 12, 24] # Here you define the direct R2eff errors (rad/s), as being added or subtracted for the created R2eff point in the corresponding ncyc cpmg frequence. #r2eff_errs_1 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05] r2eff_errs_1 = [0.0] * len(ncycs_1) exp_1 = [sfrq_1, time_T2_1, ncycs_1, r2eff_errs_1] sfrq_2 = 499.8908617*1E6 r20_key_2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=sfrq_2) time_T2_2 = 0.04 ncycs_2 = [20, 16, 10, 36, 2, 12, 4, 22, 18, 40, 14, 26, 8, 32, 24, 6, 28 ] # Here you define the direct R2eff errors (rad/s), as being added or subtracted for the created R2eff point in the corresponding ncyc cpmg frequence. #r2eff_errs_2 = [0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05, -0.05, 0.05] r2eff_errs_2 = [0.0] * len(ncycs_2) exp_2 = [sfrq_2, time_T2_2, ncycs_2, r2eff_errs_2]
def loop_parameters(spins=None): """Generator function for looping of the model parameters of the cluster. @keyword spins: The list of spin data containers for the block. @type spins: list of SpinContainer instances @return: The parameter name, the parameter index (for the parameter vector), the spin index (for the cluster), and the R20 parameter key (for R20, R20A, and R20B parameters stored as dictionaries). @rtype: str, int, int, str """ # Make sure that the R1 parameter is correctly set up. r1_setup() # The parameter index. param_index = -1 # The R2eff model. if cdp.model_type == 'R2eff': # Loop over the spins. for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # One or two parameters. params = ['r2eff'] if has_exponential_exp_type(): params = ['r2eff', 'i0'] # Yield the parameters. for param in params: # First increment the indices. param_index += 1 # Yield the data. yield param, param_index, spin_index, None # All other models. else: # First the R1 fit parameter (one per spin per field strength). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The parameters. for param in PARAMS_R1: if param in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield param, param_index, spin_index, generate_r20_key( exp_type=exp_type, frq=frq) # Then the R2 parameters (one per spin per field strength). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The parameters. for param in PARAMS_R20: if param in spins[spin_index].params: for exp_type, frq in loop_exp_frq(): param_index += 1 yield param, param_index, spin_index, generate_r20_key( exp_type=exp_type, frq=frq) # Then the chemical shift difference parameters (one per spin). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # Yield the data. for param in PARAMS_CHEM_SHIFT_DIFF: if param in spins[spin_index].params: param_index += 1 yield param, param_index, spin_index, None # Then a separate block for the proton chemical shift difference parameters for the MQ models (one per spin). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # Yield the data. for param in PARAMS_CHEM_SHIFT_DIFF_MMQ: if param in spins[spin_index].params: param_index += 1 yield param, param_index, spin_index, None # All other parameters (one per spin cluster). for spin_index in range(len(spins)): # Skip deselected spins. if not spins[spin_index].select: continue # The parameters. for param in spins[0].params: if not param in PARAMS_SPIN: param_index += 1 yield param, param_index, None, None # No more spins. break
relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='..', spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) # Change the model. relax_disp.select_model('NS MMQ 2-site') # The R20 keys. r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) # Manually set the parameter values. spin_N = cdp.mol[0].res[0].spin[1] spin_N.r2 = { r20_key1: 8.412998, r20_key2: 8.847946, r20_key3: 10.329567, r20_key4: 6.779626, r20_key5: 7.089813, r20_key6: 5.610770
def test_tp02_data_to_tp02(self): """Test the GUI analysis with the relaxation dispersion 'TP02' model fitting to the 'TP02' synthetic data.""" # The paths to the data files. data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + sep + 'dispersion' + sep + 'r1rho_off_res_tp02' + sep # Simulate the new analysis wizard, selecting the fixed time CPMG experiment. analysis = self.new_analysis_wizard(analysis_type='disp') # Change the results directory. analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) # Create the sequence data. self._execute_uf(uf_name='spin.create', res_name='Trp', res_num=1, spin_name='N') interpreter.flush() self._execute_uf(uf_name='spin.create', res_name='Trp', res_num=2, spin_name='N') interpreter.flush() self._execute_uf(uf_name='sequence.display') interpreter.flush() # Set up the nuclear isotopes. analysis.spin_isotope() uf_store['spin.isotope'].page.SetValue('spin_id', '') uf_store['spin.isotope'].wizard._go_next() interpreter.flush() # Required because of the asynchronous uf call. # Load the chemical shift data. self._execute_uf(uf_name='chemical_shift.read', file='ref_500MHz.list', dir=data_path) interpreter.flush() # The spectral data. frq = [500, 800] frq_label = ['500MHz', '800MHz'] error = 200000.0 data = [] spin_lock = [ None, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 3500.0, 4000.0, 4500.0, 5000.0, 5500.0, 6000.0 ] for frq_index in range(len(frq)): for spin_lock_index in range(len(spin_lock)): # The reference. if spin_lock[spin_lock_index] == None: id = 'ref_%s' % frq_label[frq_index] file = "ref_%s.list" % frq_label[frq_index] # Normal data. else: id = "nu_%s_%s" % (spin_lock[spin_lock_index], frq_label[frq_index]) file = "nu_%s_%s.list" % (spin_lock[spin_lock_index], frq_label[frq_index]) # Append the data. data.append( [id, file, spin_lock[spin_lock_index], frq[frq_index]]) # Load the R1 data. for frq_index in range(len(frq)): label = 'R1_%s' % frq_label[frq_index] self._execute_uf(uf_name='relax_data.read', ri_id=label, ri_type='R1', frq=frq[frq_index] * 1e6, file='%s.out' % label, 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) interpreter.flush() # Set up the peak intensity wizard. analysis.peak_wizard_launch(None) wizard = analysis.peak_wizard # The spectra. for id, file, field, H_frq in data: wizard.setup_page(page='read', file=data_path + file, spectrum_id=id, int_method='height', dim=1) wizard._apply(None) wizard._skip(None) # The error type. page = wizard.get_page(wizard.page_indices['err_type']) page.selection = 'rmsd' wizard._go_next(None) # Baseplane RMSD. for id, file, field, H_frq in data: wizard.setup_page(page='rmsd', spectrum_id=id, error=error) wizard._apply(None) wizard._skip(None) # The experiment type. for id, file, field, H_frq in data: wizard.setup_page(page='exp_type', spectrum_id=id, exp_type='R1rho') wizard._apply(None) wizard._skip(None) # Set the spectrometer frequency. for id, file, field, H_frq in data: wizard.setup_page(page='spectrometer_frequency', id=id, frq=H_frq, units='MHz') wizard._apply(None) wizard._skip(None) # Set the relaxation times. for id, file, field, H_frq in data: wizard.setup_page(page='relax_time', spectrum_id=id, time=0.1) wizard._apply(None) wizard._skip(None) # Set the relaxation dispersion spin-lock field strength (nu1). for id, file, field, H_frq in data: wizard.setup_page(page='spin_lock_field', spectrum_id=id, field=field) wizard._apply(None) wizard._skip(None) # Set the spin-lock offset. for id, file, field, H_frq in data: wizard.setup_page(page='spin_lock_offset', spectrum_id=id, offset=110.0) wizard._apply(None) wizard._skip(None) # Flush all wx events (to allow the spectrum list GUI element to populate all its rows). wx.Yield() # Simulate right clicking in the spectrum list element to test the popup menu. analysis.peak_intensity.on_right_click(Fake_right_click()) # Simulate the popup menu entries to catch bugs there (just apply the user functions with the currently set values). # FIXME: skipping the checks for certain wxPython bugs. if status.relax_mode != 'gui' and wx.version( ) != '2.9.4.1 gtk2 (classic)': analysis.peak_intensity.action_relax_disp_spin_lock_field(item=4) uf_store['relax_disp.spin_lock_field'].wizard._go_next() interpreter.flush() analysis.peak_intensity.action_relax_disp_exp_type(item=5) uf_store['relax_disp.exp_type'].wizard._go_next() interpreter.flush() analysis.peak_intensity.action_relax_disp_relax_time(item=0) uf_store['relax_disp.relax_time'].wizard._go_next() interpreter.flush() analysis.peak_intensity.action_spectrometer_frq(item=10) uf_store['spectrometer.frequency'].wizard._go_next() interpreter.flush() # Deselect all but the 'TP02' model. models = [MODEL_R2EFF, MODEL_NOREX, MODEL_TP02] for i in range(len(analysis.model_field.models_stripped)): if analysis.model_field.models_stripped[i] in models: analysis.model_field.select[i] = True else: analysis.model_field.select[i] = False analysis.model_field.modify() # Set the grid search size and number of MC sims. analysis.grid_inc.SetValue(4) analysis.mc_sim_num.SetValue(3) # Optimisation speedups. analysis.opt_func_tol = 1e-10 analysis.opt_max_iterations = 10000 # Execute relax. analysis.execute( wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) # Wait for execution to complete. analysis.thread.join() # Flush all wx events. wx.Yield() # Exceptions in the thread. self.check_exceptions() # Check the relax controller. # FIXME: skipping the checks for certain wxPython bugs. if status.relax_mode != 'gui' and wx.version( ) != '2.9.4.1 gtk2 (classic)': self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) # The original parameters. r1rho_prime = [[10.0, 15.0], [12.0, 18.0]] pA = 0.7654321 kex = 1234.56789 delta_omega = [7.0, 9.0] # The R20 keys. r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) # Switch to the 'TP02' model data pipe, then check for each spin. switch("%s - %s" % ('TP02', get_bundle())) spin_index = 0 for spin, spin_id in spin_loop(return_id=True): # Printout. print("\nSpin %s." % spin_id) # Check the fitted parameters. self.assertAlmostEqual(spin.r2[r20_key1] / 10, r1rho_prime[spin_index][0] / 10, 4) self.assertAlmostEqual(spin.r2[r20_key2] / 10, r1rho_prime[spin_index][1] / 10, 4) self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3) self.assertAlmostEqual(spin.kex / 1000.0, kex / 1000.0, 3) # Increment the spin index. spin_index += 1
def test_tp02_data_to_tp02(self): """Test the GUI analysis with the relaxation dispersion 'TP02' model fitting to the 'TP02' synthetic data.""" # The paths to the data files. data_path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'r1rho_off_res_tp02'+sep # Simulate the new analysis wizard, selecting the fixed time CPMG experiment. analysis = self.new_analysis_wizard(analysis_type='disp') # Change the results directory. analysis.field_results_dir.SetValue(str_to_gui(ds.tmpdir)) # Create the sequence data. self._execute_uf(uf_name='spin.create', res_name='Trp', res_num=1, spin_name='N') interpreter.flush() self._execute_uf(uf_name='spin.create', res_name='Trp', res_num=2, spin_name='N') interpreter.flush() self._execute_uf(uf_name='sequence.display') interpreter.flush() # Set up the nuclear isotopes. analysis.spin_isotope() uf_store['spin.isotope'].page.SetValue('spin_id', '') uf_store['spin.isotope'].wizard._go_next() interpreter.flush() # Required because of the asynchronous uf call. # Load the chemical shift data. self._execute_uf(uf_name='chemical_shift.read', file='ref_500MHz.list', dir=data_path) interpreter.flush() # The spectral data. frq = [500, 800] frq_label = ['500MHz', '800MHz'] error = 200000.0 data = [] spin_lock = [None, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 3500.0, 4000.0, 4500.0, 5000.0, 5500.0, 6000.0] for frq_index in range(len(frq)): for spin_lock_index in range(len(spin_lock)): # The reference. if spin_lock[spin_lock_index] == None: id = 'ref_%s' % frq_label[frq_index] file = "ref_%s.list" % frq_label[frq_index] # Normal data. else: id = "nu_%s_%s" % (spin_lock[spin_lock_index], frq_label[frq_index]) file = "nu_%s_%s.list" % (spin_lock[spin_lock_index], frq_label[frq_index]) # Append the data. data.append([id, file, spin_lock[spin_lock_index], frq[frq_index]]) # Load the R1 data. for frq_index in range(len(frq)): label = 'R1_%s' % frq_label[frq_index] self._execute_uf(uf_name='relax_data.read', ri_id=label, ri_type='R1', frq=frq[frq_index]*1e6, file='%s.out'%label, 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) interpreter.flush() # Set up the peak intensity wizard. analysis.peak_wizard_launch(None) wizard = analysis.peak_wizard # The spectra. for id, file, field, H_frq in data: wizard.setup_page(page='read', file=data_path+file, spectrum_id=id, int_method='height', dim=1) wizard._apply(None) wizard._skip(None) # The error type. page = wizard.get_page(wizard.page_indices['err_type']) page.selection = 'rmsd' wizard._go_next(None) # Baseplane RMSD. for id, file, field, H_frq in data: wizard.setup_page(page='rmsd', spectrum_id=id, error=error) wizard._apply(None) wizard._skip(None) # The experiment type. for id, file, field, H_frq in data: wizard.setup_page(page='exp_type', spectrum_id=id, exp_type='R1rho') wizard._apply(None) wizard._skip(None) # Set the spectrometer frequency. for id, file, field, H_frq in data: wizard.setup_page(page='spectrometer_frequency', id=id, frq=H_frq, units='MHz') wizard._apply(None) wizard._skip(None) # Set the relaxation times. for id, file, field, H_frq in data: wizard.setup_page(page='relax_time', spectrum_id=id, time=0.1) wizard._apply(None) wizard._skip(None) # Set the relaxation dispersion spin-lock field strength (nu1). for id, file, field, H_frq in data: wizard.setup_page(page='spin_lock_field', spectrum_id=id, field=field) wizard._apply(None) wizard._skip(None) # Set the spin-lock offset. for id, file, field, H_frq in data: wizard.setup_page(page='spin_lock_offset', spectrum_id=id, offset=110.0) wizard._apply(None) wizard._skip(None) # Flush all wx events (to allow the spectrum list GUI element to populate all its rows). wx.Yield() # Simulate right clicking in the spectrum list element to test the popup menu. analysis.peak_intensity.on_right_click(Fake_right_click()) # Simulate the popup menu entries to catch bugs there (just apply the user functions with the currently set values). # FIXME: skipping the checks for certain wxPython bugs. if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': analysis.peak_intensity.action_relax_disp_spin_lock_field(item=4) uf_store['relax_disp.spin_lock_field'].wizard._go_next() interpreter.flush() analysis.peak_intensity.action_relax_disp_exp_type(item=5) uf_store['relax_disp.exp_type'].wizard._go_next() interpreter.flush() analysis.peak_intensity.action_relax_disp_relax_time(item=0) uf_store['relax_disp.relax_time'].wizard._go_next() interpreter.flush() analysis.peak_intensity.action_spectrometer_frq(item=10) uf_store['spectrometer.frequency'].wizard._go_next() interpreter.flush() # Deselect all but the 'TP02' model. models = [MODEL_R2EFF, MODEL_NOREX, MODEL_TP02] for i in range(len(analysis.model_field.models_stripped)): if analysis.model_field.models_stripped[i] in models: analysis.model_field.select[i] = True else: analysis.model_field.select[i] = False analysis.model_field.modify() # Set the grid search size and number of MC sims. analysis.grid_inc.SetValue(4) analysis.mc_sim_num.SetValue(3) # Optimisation speedups. analysis.opt_func_tol = 1e-10 analysis.opt_max_iterations = 10000 # Execute relax. analysis.execute(wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, analysis.button_exec_relax.GetId())) # Wait for execution to complete. analysis.thread.join() # Flush all wx events. wx.Yield() # Exceptions in the thread. self.check_exceptions() # Check the relax controller. # FIXME: skipping the checks for certain wxPython bugs. if status.relax_mode != 'gui' and wx.version() != '2.9.4.1 gtk2 (classic)': self.assertEqual(self.app.gui.controller.mc_gauge_rx.GetValue(), 100) self.assertEqual(self.app.gui.controller.main_gauge.GetValue(), 100) # The original parameters. r1rho_prime = [[10.0, 15.0], [12.0, 18.0]] pA = 0.7654321 kex = 1234.56789 delta_omega = [7.0, 9.0] # The R20 keys. r20_key1 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=500e6) r20_key2 = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) # Switch to the 'TP02' model data pipe, then check for each spin. switch("%s - %s" % ('TP02', get_bundle())) spin_index = 0 for spin, spin_id in spin_loop(return_id=True): # Printout. print("\nSpin %s." % spin_id) # Check the fitted parameters. self.assertAlmostEqual(spin.r2[r20_key1]/10, r1rho_prime[spin_index][0]/10, 4) self.assertAlmostEqual(spin.r2[r20_key2]/10, r1rho_prime[spin_index][1]/10, 4) self.assertAlmostEqual(spin.dw, delta_omega[spin_index], 3) self.assertAlmostEqual(spin.kex/1000.0, kex/1000.0, 3) # Increment the spin index. spin_index += 1
relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir=DATA_PATH, spin_id=spin_id, disp_point_col=7, data_col=10, error_col=9) # Change the model. relax_disp.select_model('NS MMQ 3-site linear') # The R20 keys. r20_1h_sq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=400e6) r20_1h_sq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_1h_sq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) r20_1h_sq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=1000e6) r20_sq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=400e6) r20_sq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_sq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_sq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=1000e6) r20_zq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=400e6) r20_zq_600_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) r20_zq_800_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) r20_zq_1000_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=1000e6) r20_dq_400_key = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=400e6)
relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) # Relaxation dispersion CPMG constant time delay T (in s). relax_disp.relax_time(spectrum_id=new_id, time=relax_time) # Set the CPMG frequency. relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='../..', spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) # Change the model. relax_disp.select_model('NS MMQ 2-site') # The R20 keys. r20_key_sq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) r20_key_sq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_key_sq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_key_1h_sq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) r20_key_1h_sq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_key_1h_sq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) r20_key_zq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6) r20_key_zq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) r20_key_zq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) r20_key_dq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6) r20_key_dq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) r20_key_dq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) r20_key_mq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6) r20_key_mq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6) r20_key_mq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) r20_key_1h_mq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
frq=800e6, file='R1_800MHz.out', dir='..', 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) # Change the model. relax_disp.select_model('TP02') # The R20 keys. r20_600_key = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=600e6) r20_800_key = generate_r20_key(exp_type=EXP_TYPE_R1RHO, frq=800e6) # Manually set the parameter values. spin_N = cdp.mol[0].res[0].spin[0] spin_N.r2 = { r20_600_key: 9.108060397660111, r20_800_key: 13.793213528551924, } spin_N.pA = 0.945912353996981 spin_N.pB = 0.054087646003019 spin_N.kex = 367.981715073974556 spin_N.dw = 4.305697497613982 spin_N.ri_data['600MHz'] = 3.179051390898238 spin_N.ri_data['800MHz'] = 4.452840879991469
return_id=True, skip_desel=True): # Generate spin string. spin_string = generate_spin_string(spin=cur_spin, mol_name=mol_name, res_num=resi, res_name=resn) # Loop over the parameters. print("\nOptimised parameters for spin: %s" % (spin_string)) for param in cur_spin.params + ['chi2']: # Get the value. if param in ['r1', 'r2']: for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True): # Generate the R20 key. r20_key = generate_r20_key(exp_type=exp_type, frq=frq) # Get the value. value = getattr(cur_spin, param)[r20_key] # Print value. print("%-10s %-6s %-6s %3.8f" % ("Parameter:", param, "Value:", value)) # For all other parameters. else: # Get the value. value = getattr(cur_spin, param) # Print value. print("%-10s %-6s %-6s %3.8f" %
relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) # Relaxation dispersion CPMG constant time delay T (in s). relax_disp.relax_time(spectrum_id=new_id, time=relax_time) # Set the CPMG frequency. relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='../..', spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) # Change the model. relax_disp.select_model('NS MMQ 2-site') # The R20 keys. r20_key_sq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) r20_key_sq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_key_sq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_key_1h_sq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) r20_key_1h_sq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_key_1h_sq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) r20_key_zq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=500e6) r20_key_zq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=600e6) r20_key_zq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_ZQ, frq=800e6) r20_key_dq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=500e6) r20_key_dq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=600e6) r20_key_dq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_DQ, frq=800e6) r20_key_mq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=500e6) r20_key_mq_600 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=600e6) r20_key_mq_800 = generate_r20_key(exp_type=EXP_TYPE_CPMG_MQ, frq=800e6) r20_key_1h_mq_500 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_MQ, frq=500e6)
relax_disp.exp_type(spectrum_id=new_id, exp_type=exp_type) # Relaxation dispersion CPMG constant time delay T (in s). relax_disp.relax_time(spectrum_id=new_id, time=relax_time) # Set the CPMG frequency. relax_disp.cpmg_setup(spectrum_id=new_id, cpmg_frq=cpmg_frq) # Read the R2eff data. relax_disp.r2eff_read_spin(id=id, file=file, dir='..', spin_id=spin_id, disp_point_col=1, data_col=2, error_col=3) # Change the model. relax_disp.select_model('NS MMQ 2-site') # The R20 keys. r20_key1 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=500e6) r20_key2 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=600e6) r20_key3 = generate_r20_key(exp_type=EXP_TYPE_CPMG_SQ, frq=800e6) r20_key4 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=500e6) r20_key5 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=600e6) r20_key6 = generate_r20_key(exp_type=EXP_TYPE_CPMG_PROTON_SQ, frq=800e6) # Manually set the parameter values. spin_N = cdp.mol[0].res[0].spin[1] spin_N.r2 = {r20_key1: 8.412998, r20_key2: 8.847946, r20_key3: 10.329567, r20_key4: 6.779626, r20_key5: 7.089813, r20_key6: 5.610770} spin_N.pA = 0.947960 spin_N.kex = 408.394 spin_N.dw = 4.369907 spin_N.dwH = -0.267240 # Optimisation.