Author: bugman Date: Tue Jun 18 14:30:34 2013 New Revision: 20193 URL: http://svn.gna.org/viewcvs/relax?rev=20193&view=rev Log: Merged revisions 20192 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r20192 | bugman | 2013-06-18 14:28:13 +0200 (Tue, 18 Jun 2013) | 7 lines Added support for mixed RDC data types per alignment. This is to allow, for example, one bond RDC values of the 'D' data type and two bond RDC values of the T = J+D data type to be loaded for the same alignment ID. This is now handled in the N-state or ensemble analysis by handling a different RDC data type per RDC value. ........ Modified: branches/relax_disp/ (props changed) branches/relax_disp/data_store/__init__.py branches/relax_disp/pipe_control/rdc.py branches/relax_disp/specific_analyses/n_state_model/__init__.py branches/relax_disp/specific_analyses/n_state_model/data.py branches/relax_disp/target_functions/n_state_model.py Propchange: branches/relax_disp/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Jun 18 14:30:34 2013 @@ -1,1 +1,1 @@ -/trunk:1-20187 +/trunk:1-20192 Modified: branches/relax_disp/data_store/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/data_store/__init__.py?rev=20193&r1=20192&r2=20193&view=diff ============================================================================== --- branches/relax_disp/data_store/__init__.py (original) +++ branches/relax_disp/data_store/__init__.py Tue Jun 18 14:30:34 2013 @@ -281,6 +281,18 @@ for name in eliminate: if hasattr(spin, name): delattr(spin, name) + + # Conversions for the interatomic data containers. + if hasattr(dp, 'interatomic'): + for interatom in dp.interatomic: + # RDC data. + if hasattr(interatom, 'rdc') and not hasattr(interatom, 'rdc_data_types'): + # Initialise. + interatom.rdc_data_types = {} + + # Add the data type, assumed to be 'D', for each alignment ID. + for id in dp.rdc_ids: + interatom.rdc_data_types[id] = 'D' # Convert the alignment tensors. if hasattr(dp, 'align_tensors'): Modified: branches/relax_disp/pipe_control/rdc.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/rdc.py?rev=20193&r1=20192&r2=20193&view=diff ============================================================================== --- branches/relax_disp/pipe_control/rdc.py (original) +++ branches/relax_disp/pipe_control/rdc.py Tue Jun 18 14:30:34 2013 @@ -120,7 +120,7 @@ interatom.rdc_bc[id] = ave_rdc_tensor(dj, unit_vect, cdp.N, cdp.align_tensors[get_tensor_index(align_id=id)].A, weights=weights) # T values. - if hasattr(cdp, 'rdc_data_types') and align_id in cdp.rdc_data_types and cdp.rdc_data_types[align_id] == 'T': + if hasattr(interatom, 'rdc_data_types') and align_id in interatom.rdc_data_types and interatom.rdc_data_types[align_id] == 'T': if not hasattr(interatom, 'j_coupling'): raise RelaxNoJError @@ -190,11 +190,13 @@ raise RelaxNoRDCError(rdc_id) -def convert(value, align_id, to_intern=False): +def convert(value, data_type, align_id, to_intern=False): """Convert the RDC based on the 'D' or '2D' data type. @param value: The value or error to convert. @type value: float or None + @param data_type: The RDC data type. Either 'D', '2D' or 'T'. + @type data_type: str @param align_id: The alignment tensor ID string. @type align_id: str @keyword to_intern: A flag which if True will convert to the internal D notation if needed, or if False will convert from the internal D notation to the external D or 2D format. @@ -209,7 +211,7 @@ # The conversion factor. factor = 1.0 - if hasattr(cdp, 'rdc_data_types') and align_id in cdp.rdc_data_types and cdp.rdc_data_types[align_id] == '2D': + if data_type == '2D': # Convert from 2D to D. if to_intern: factor = 2.0 @@ -330,11 +332,6 @@ # Append a new list for this alignment. data.append([]) - # T-type data. - j_flag = False - if hasattr(cdp, 'rdc_data_types') and align_id in cdp.rdc_data_types and cdp.rdc_data_types[align_id] == 'T': - j_flag = True - # Errors present? err_flag = False for interatom in interatomic_loop(): @@ -350,9 +347,9 @@ continue # Append the data. - rdc_bc = convert(interatom.rdc_bc[align_id], align_id) - rdc = convert(interatom.rdc[align_id], align_id) - if j_flag: + rdc_bc = convert(interatom.rdc_bc[align_id], interatom.rdc_data_types[align_id], align_id) + rdc = convert(interatom.rdc[align_id], interatom.rdc_data_types[align_id], align_id) + if hasattr(interatom, 'rdc_data_types') and align_id in interatom.rdc_data_types and interatom.rdc_data_types[align_id] == 'T': rdc_bc -= interatom.j_coupling rdc -= interatom.j_coupling data[-1].append([rdc_bc, rdc]) @@ -360,7 +357,7 @@ # Errors. if err_flag: if hasattr(interatom, 'rdc_err') and align_id in interatom.rdc_err.keys(): - data[-1][-1].append(convert(interatom.rdc_err[align_id], align_id)) + data[-1][-1].append(convert(interatom.rdc_err[align_id], interatom.rdc_data_types[align_id], align_id)) else: data[-1][-1].append(None) @@ -409,10 +406,6 @@ # The RDC ID. cdp.rdc_ids.pop(cdp.rdc_ids.index(id)) - # The data type. - if hasattr(cdp, 'rdc_data_types') and id in cdp.rdc_data_types: - cdp.rdc_data_types.pop(id) - # The interatomic data. for interatom in interatomic_loop(): # The data. @@ -422,6 +415,10 @@ # The error. if hasattr(interatom, 'rdc_err') and id in interatom.rdc_err: interatom.rdc_err.pop(id) + + # The data type. + if hasattr(interatom, 'rdc_data_types') and id in interatom.rdc_data_types: + interatom.rdc_data_types.pop(id) # Clean the global data. if not hasattr(cdp, 'pcs_ids') or id not in cdp.pcs_ids: @@ -486,7 +483,7 @@ if hasattr(interatom, 'rdc_bc') and align_id in interatom.rdc_bc: rdc_bc_data = True j_flag = False - if hasattr(cdp, 'rdc_data_types') and align_id in cdp.rdc_data_types and cdp.rdc_data_types[align_id] == 'T': + if hasattr(interatom, 'rdc_data_types') and align_id in interatom.rdc_data_types and interatom.rdc_data_types[align_id] == 'T': j_flag = True if not hasattr(interatom, 'j_coupling'): raise RelaxNoJError @@ -607,12 +604,6 @@ if data_type not in rdc_types: raise RelaxError("The RDC data type '%s' must be one of %s." % (data_type, rdc_types)) - # Store the data type as global data (need for the conversion of RDC data). - if not hasattr(cdp, 'rdc_data_types'): - cdp.rdc_data_types = {} - if not align_id in cdp.rdc_data_types: - cdp.rdc_data_types[align_id] = data_type - # Spin specific data. ##################### @@ -696,10 +687,16 @@ if interatom == None: interatom = create_interatom(spin_id1=spin_id1, spin_id2=spin_id2) + # Store the data type as global data (need for the conversion of RDC data). + if not hasattr(interatom, 'rdc_data_types'): + interatom.rdc_data_types = {} + if not align_id in interatom.rdc_data_types: + interatom.rdc_data_types[align_id] = data_type + # Convert and add the data. if data_col: # Data conversion. - value = convert(value, align_id, to_intern=True) + value = convert(value, data_type, align_id, to_intern=True) # Correction for the negative gyromagnetic ratio of 15N. if neg_g_corr and value != None: @@ -725,7 +722,7 @@ # Convert and add the error. if error_col: # Data conversion. - error = convert(error, align_id, to_intern=True) + error = convert(error, data_type, align_id, to_intern=True) # Initialise. if not hasattr(interatom, 'rdc_err'): @@ -864,13 +861,13 @@ # The value. if bc: - data[-1].append(repr(convert(interatom.rdc_bc[align_id], align_id))) + data[-1].append(repr(convert(interatom.rdc_bc[align_id], interatom.rdc_data_types[align_id], align_id))) else: - data[-1].append(repr(convert(interatom.rdc[align_id], align_id))) + data[-1].append(repr(convert(interatom.rdc[align_id], interatom.rdc_data_types[align_id], align_id))) # The error. if hasattr(interatom, 'rdc_err') and align_id in interatom.rdc_err.keys(): - data[-1].append(repr(convert(interatom.rdc_err[align_id], align_id))) + data[-1].append(repr(convert(interatom.rdc_err[align_id], interatom.rdc_data_types[align_id], align_id))) else: data[-1].append(repr(None)) Modified: branches/relax_disp/specific_analyses/n_state_model/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/n_state_model/__init__.py?rev=20193&r1=20192&r2=20193&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/n_state_model/__init__.py (original) +++ branches/relax_disp/specific_analyses/n_state_model/__init__.py Tue Jun 18 14:30:34 2013 @@ -574,12 +574,7 @@ rdc_err.append([]) rdc_weight.append([]) absolute.append([]) - - # T-type data. - if align_id in cdp.rdc_data_types and cdp.rdc_data_types[align_id] == 'T': - T_flags.append(True) - else: - T_flags.append(False) + T_flags.append([]) # Interatom loop. for interatom in interatomic_loop(): @@ -595,9 +590,15 @@ if not hasattr(interatom, 'rdc') or not hasattr(interatom, 'vector'): continue + # T-type data. + if align_id in interatom.rdc_data_types and interatom.rdc_data_types[align_id] == 'T': + T_flags[-1].append(True) + else: + T_flags[-1].append(False) + # Check for J couplings if the RDC data type is T = J+D. - if not hasattr(interatom, 'j_coupling'): - continue + if T_flags[-1][-1] and not hasattr(interatom, 'j_coupling'): + continue # Defaults of None. value = None @@ -620,7 +621,7 @@ # The error. if hasattr(interatom, 'rdc_err') and align_id in interatom.rdc_err.keys(): # T values. - if T_flags[-1]: + if T_flags[-1][-1]: error = -3.0 * sqrt(interatom.rdc_err[align_id]**2 + interatom.j_coupling_err**2) # D values. @@ -638,7 +639,7 @@ # The error. if hasattr(interatom, 'rdc_err') and align_id in interatom.rdc_err.keys(): # T values. - if T_flags[-1]: + if T_flags[-1][-1]: error = sqrt(interatom.rdc_err[align_id]**2 + interatom.j_coupling_err**2) # D values. Modified: branches/relax_disp/specific_analyses/n_state_model/data.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/n_state_model/data.py?rev=20193&r1=20192&r2=20193&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/n_state_model/data.py (original) +++ branches/relax_disp/specific_analyses/n_state_model/data.py Tue Jun 18 14:30:34 2013 @@ -293,8 +293,9 @@ # Loop over the alignments. for align_id in cdp.align_ids: - if align_id in cdp.rdc_data_types and cdp.rdc_data_types[align_id] == 'T': - return True + for interatom in interatomic_loop(): + if hasattr(interatom, 'rdc_data_types') and align_id in interatom.rdc_data_types and interatom.rdc_data_types[align_id] == 'T': + return True # No J values required. return False Modified: branches/relax_disp/target_functions/n_state_model.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/target_functions/n_state_model.py?rev=20193&r1=20192&r2=20193&view=diff ============================================================================== --- branches/relax_disp/target_functions/n_state_model.py (original) +++ branches/relax_disp/target_functions/n_state_model.py Tue Jun 18 14:30:34 2013 @@ -136,7 +136,7 @@ @keyword rdc_vect: The unit vector lists for the RDC. The first index must correspond to the spin pair and the second index to each structure (its size being equal to the number of states). @type rdc_vect: numpy rank-2 array @keyword T_flags: The array of flags specifying if the data for the given alignment is of the T = J+D type. - @type T_flags: numpy rank-1 array + @type T_flags: numpy rank-2 array @keyword j_couplings: The J couplings list, used when the RDC data is of the type T = J+D. The number of elements must match the second dimension of the rdcs argument. @type j_couplings: numpy rank-1 array @keyword temp: The temperature of each experiment, used for the PCS. @@ -677,7 +677,7 @@ self.rdc_theta[align_index, j] = ave_rdc_tensor(self.dip_const[j], self.dip_vect[j], self.N, self.A[align_index], weights=self.probs) # Add the J coupling to convert into the back-calculated T = J+D value. - if self.T_flags[align_index]: + if self.T_flags[align_index, j]: self.rdc_theta[align_index, j] += self.j_couplings[j] # Take the absolute value.