Author: bugman Date: Fri Apr 25 11:45:05 2008 New Revision: 6004 URL: http://svn.gna.org/viewcvs/relax?rev=6004&view=rev Log: Simplified the name() and number() functions. They now handle complex spin selections. Modified: 1.3/generic_fns/spin.py Modified: 1.3/generic_fns/spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/spin.py?rev=6004&r1=6003&r2=6004&view=diff ============================================================================== --- 1.3/generic_fns/spin.py (original) +++ 1.3/generic_fns/spin.py Fri Apr 25 11:45:05 2008 @@ -198,17 +198,9 @@ @type name: str """ - # Split up the selection string. - mol_token, res_token, spin_token = tokenise(spin_id) - - # Parse the tokens. - spins = parse_token(spin_token) - - # Spin loop. + # Rename the spin. for spin in spin_loop(spin_id): - # Rename the spin if there is a match. - if spin.num in spins or spin.name in spins: - spin.name = name + spin.name = name def number(spin_id=None, number=None): @@ -220,24 +212,15 @@ @type number: int """ - # Split up the selection string. - mol_token, res_token, spin_token = tokenise(spin_id) - - # Parse the tokens. - spins = parse_token(spin_token) - # Catch multiple renumberings! i = 0 for spin in spin_loop(spin_id): - if spin.num in spins or spin.name in spins: - i = i + 1 + i = i + 1 # Fail if multiple spins are numbered. if i > 1: raise RelaxError, "The numbering of multiple spins is disallowed, as each spin requires a unique number." - # Spin loop. + # Rename the spin. for spin in spin_loop(spin_id): - # Rename the spin if there is a match. - if spin.num in spins or spin.name in spins: - spin.num = number + spin.num = number