Author: bugman Date: Tue Apr 9 15:40:58 2013 New Revision: 19406 URL: http://svn.gna.org/viewcvs/relax?rev=19406&view=rev Log: Added the skip_desel flag to the important pipe_control.mol_res_spin.spin_loop() generator function. This is used to skip deselected spins within the loop. As must of the code in relax using the spin_loop() does this anyway, this can be used to simplify many of the spin looping elements in relax. Modified: trunk/pipe_control/mol_res_spin.py Modified: trunk/pipe_control/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/mol_res_spin.py?rev=19406&r1=19405&r2=19406&view=diff ============================================================================== --- trunk/pipe_control/mol_res_spin.py (original) +++ trunk/pipe_control/mol_res_spin.py Tue Apr 9 15:40:58 2013 @@ -3589,19 +3589,21 @@ yield mol_index, res_index, spin_index -def spin_loop(selection=None, pipe=None, full_info=False, return_id=False): +def spin_loop(selection=None, pipe=None, full_info=False, return_id=False, skip_desel=False): """Generator function for looping over all the spin systems of the given selection. - @keyword selection: The spin system selection identifier. - @type selection: str - @keyword pipe: The data pipe containing the spin. Defaults to the current data pipe. - @type pipe: str - @keyword full_info: A flag which if True will cause the the molecule name, residue number, and residue name to be returned in addition to the spin container. - @type full_info: bool - @keyword return_id: A flag which if True will cause the spin identification string of the current spin to be returned in addition to the spin container. - @type return_id: bool - @return: The spin system specific data container. If full_info is True, a tuple of the spin container, the molecule name, residue number, and residue name. If return_id is True, a tuple of the spin container and spin id. If both flags are True, then a tuple of the spin container, the molecule name, residue number, residue name, and spin id. - @rtype: If full_info and return_id are False, SpinContainer instance. If full_info is True and return_id is false, a tuple of (SpinContainer instance, str, int, str). If full_info is False and return_id is True, a tuple of (SpinContainer instance, str). If full_info and return_id are False, a tuple of (SpinContainer instance, str, int, str, str) + @keyword selection: The spin system selection identifier. + @type selection: str + @keyword pipe: The data pipe containing the spin. Defaults to the current data pipe. + @type pipe: str + @keyword full_info: A flag which if True will cause the the molecule name, residue number, and residue name to be returned in addition to the spin container. + @type full_info: bool + @keyword return_id: A flag which if True will cause the spin identification string of the current spin to be returned in addition to the spin container. + @type return_id: bool + @keyword skip_desel: A flag which if True will cause deselected spins to be skipped. + @type skip_desel: bool + @return: The spin system specific data container. If full_info is True, a tuple of the spin container, the molecule name, residue number, and residue name. If return_id is True, a tuple of the spin container and spin id. If both flags are True, then a tuple of the spin container, the molecule name, residue number, residue name, and spin id. + @rtype: If full_info and return_id are False, SpinContainer instance. If full_info is True and return_id is false, a tuple of (SpinContainer instance, str, int, str). If full_info is False and return_id is True, a tuple of (SpinContainer instance, str). If full_info and return_id are False, a tuple of (SpinContainer instance, str, int, str, str) """ # The data pipe. @@ -3631,6 +3633,10 @@ if not select_obj.contains_spin(spin_num=spin.num, spin_name=spin.name, res_num=res.num, res_name=res.name, mol=mol.name): continue + # Skip deselected spins. + if not spin.select: + continue + # Generate the spin id. if return_id: spin_id = generate_spin_id_unique(pipe_cont=dp, mol=mol, res=res, spin=spin)