Author: bugman Date: Wed Oct 22 14:52:21 2014 New Revision: 26348 URL: http://svn.gna.org/viewcvs/relax?rev=26348&view=rev Log: Implemented the spin_selection Boolean argument for the interatom.define user function. This has been added to the frontend with a description, and to the backend. When set, it allows the spin selections to define the interatomic data container selection. Modified: trunk/pipe_control/interatomic.py trunk/user_functions/interatom.py Modified: trunk/pipe_control/interatomic.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/interatomic.py?rev=26348&r1=26347&r2=26348&view=diff ============================================================================== --- trunk/pipe_control/interatomic.py (original) +++ trunk/pipe_control/interatomic.py Wed Oct 22 14:52:21 2014 @@ -195,19 +195,21 @@ return dp.interatomic.add_item(spin_id1=spin_id1, spin_id2=spin_id2) -def define(spin_id1=None, spin_id2=None, pipe=None, direct_bond=False, verbose=True): +def define(spin_id1=None, spin_id2=None, pipe=None, direct_bond=False, spin_selection=True, verbose=True): """Set up the magnetic dipole-dipole interaction. - @keyword spin_id1: The spin identifier string of the first spin of the pair. - @type spin_id1: str - @keyword spin_id2: The spin identifier string of the second spin of the pair. - @type spin_id2: str - @param pipe: The data pipe to operate on. Defaults to the current data pipe. - @type pipe: str - @keyword direct_bond: A flag specifying if the two spins are directly bonded. - @type direct_bond: bool - @keyword verbose: A flag which if True will result in printouts of the created interatomoic data containers. - @type verbose: bool + @keyword spin_id1: The spin identifier string of the first spin of the pair. + @type spin_id1: str + @keyword spin_id2: The spin identifier string of the second spin of the pair. + @type spin_id2: str + @param pipe: The data pipe to operate on. Defaults to the current data pipe. + @type pipe: str + @keyword direct_bond: A flag specifying if the two spins are directly bonded. + @type direct_bond: bool + @keyword spin_selection: Define the interatomic data container selection based on the spin selection. If either spin is deselected, the interatomic container will also be deselected. Otherwise the container will be selected. + @type spin_selection: bool + @keyword verbose: A flag which if True will result in printouts of the created interatomoic data containers. + @type verbose: bool """ # The data pipe. @@ -219,6 +221,7 @@ # Initialise the spin ID pairs list. ids = [] + spin_selections = [] # Use the structural data to find connected atoms. if hasattr(dp, 'structure'): @@ -232,7 +235,8 @@ id1 = generate_spin_id_unique(pipe_cont=dp, mol_name=mol_name1, res_num=res_num1, res_name=res_name1, spin_num=atom_num1, spin_name=atom_name1) # Do the spin exist? - if not return_spin(id1): + spin1 = return_spin(id1) + if not spin1: continue # Loop over the atoms of the second spin selection. @@ -251,11 +255,13 @@ id2 = generate_spin_id_unique(pipe_cont=dp, mol_name=mol_name2, res_num=res_num2, res_name=res_name2, spin_num=atom_num2, spin_name=atom_name2) # Do the spin exist? - if not return_spin(id2): + spin2 = return_spin(id2) + if not spin2: continue # Store the IDs for the printout. ids.append([id1, id2]) + spin_selections.append([spin1.select, spin2.select]) # No structural data present or the spin IDs are not in the structural data, so use spin loops and some basic rules. if ids == []: @@ -288,6 +294,7 @@ # Store the IDs for the printout. ids.append([id1, id2]) + spin_selections.append([spin1.select, spin2.select]) # No matches, so fail! if not len(ids): @@ -310,7 +317,9 @@ raise RelaxError("Unknown error.") # Define the interaction. - for id1, id2 in ids: + for i in range(len(ids)): + # Unpack. + id1, id2 = ids[i] # Get the interatomic data object, if it exists. interatom = return_interatom(id1, id2, pipe=pipe) @@ -324,6 +333,12 @@ # Set a flag indicating that a dipole-dipole interaction is present. interatom.dipole_pair = True + + # Set the selection. + if spin_selection: + interatom.select = False + if spin_selections[i][0] and spin_selections[i][1]: + interatom.select = True # Printout. if verbose: Modified: trunk/user_functions/interatom.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/interatom.py?rev=26348&r1=26347&r2=26348&view=diff ============================================================================== --- trunk/user_functions/interatom.py (original) +++ trunk/user_functions/interatom.py Wed Oct 22 14:52:21 2014 @@ -134,6 +134,13 @@ desc = "This is a flag which if True means that the two spins are directly bonded. This flag is useful to simplify the set up of the main heteronuclear relaxation mechanism or one-bond residual dipolar couplings." ) uf.add_keyarg( + name = "spin_selection", + default = True, + py_type = "bool", + desc_short = "selection from the spins", + desc = "Define the interatomic data container selection based on the spin selection. If either spin is deselected, the interatomic container will also be deselected. Otherwise the container will be selected." +) +uf.add_keyarg( name = "pipe", py_type = "str", desc_short = "alternative data pipe", @@ -147,6 +154,7 @@ uf.desc.append(Desc_container()) uf.desc[-1].add_paragraph("To analyse relaxation or residual dipolar coupling (RDC) data, for example, pairs of spins which are coupled need to be defined. This can be via the magnetic dipole-dipole interaction or scalar coupling interaction. This function will create an interatomic data object connecting two existing spins. This data container will be used to store all information about the interactomic interaction including interatomic vectors and distances.") uf.desc[-1].add_paragraph("For analyses which use relaxation data, simply defining the interatomic interaction will indicate that there is a dipolar relaxation mechanism operating between the two spins. Note that for model-free analyses or reduced spectral density mapping, only a single relaxation mechanism can be handled. For RDC dependent analyses, the presence of the interatomic interaction indicates that dipolar coupling is expected between the two spins.") +uf.desc[-1].add_paragraph("If the spin selection flag is set, then the newly created interatomic data container will be selected based on the current selection status of the two spins defining the interaction. If either of the spins are deselected, then the new interatomic data container will also be deselected. If both spins are selected, then the interatomic data container will also be selected.") # Prompt examples. uf.desc.append(Desc_container("Prompt examples")) uf.desc[-1].add_paragraph("To connect the spins ':1@N' to ':1@H', type one of:") @@ -158,8 +166,8 @@ uf.backend = interatomic.define uf.menu_text = "&define" uf.gui_icon = "oxygen.actions.list-add-relax-blue" -uf.wizard_height_desc = 350 -uf.wizard_size = (900, 700) +uf.wizard_height_desc = 380 +uf.wizard_size = (950, 700) uf.wizard_image = WIZARD_IMAGE_PATH + 'dipole_pair' + sep + 'NH_dipole_pair.png'