Author: bugman Date: Sun May 4 11:46:52 2008 New Revision: 6064 URL: http://svn.gna.org/viewcvs/relax?rev=6064&view=rev Log: Shifted all the naming functions into generic_fns.mol_res_spin. Modified: branches/mol_res_spin_module_rename/generic_fns/mol_res_spin.py branches/mol_res_spin_module_rename/generic_fns/molecule.py branches/mol_res_spin_module_rename/generic_fns/residue.py branches/mol_res_spin_module_rename/generic_fns/spin.py Modified: branches/mol_res_spin_module_rename/generic_fns/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/mol_res_spin_module_rename/generic_fns/mol_res_spin.py?rev=6064&r1=6063&r2=6064&view=diff ============================================================================== --- branches/mol_res_spin_module_rename/generic_fns/mol_res_spin.py (original) +++ branches/mol_res_spin_module_rename/generic_fns/mol_res_spin.py Sun May 4 11:46:52 2008 @@ -1120,6 +1120,80 @@ yield mol +def name_molecule(mol_id, new_name=None): + """Function for renaming molecules. + + @param mol_id: The identifier string for the molecule to rename. + @type mol_id: str + @param new_name: The new molecule name. + @type new_name: str + """ + + # Split up the selection string. + mol_token, res_token, spin_token = tokenise(mol_id) + + # Disallow spin selections. + if spin_token != None: + raise RelaxSpinSelectDisallowError + + # Disallow residue selections. + if res_token != None: + raise RelaxResSelectDisallowError + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # Parse the tokens. + molecules = parse_token(mol_token) + + # Get the single molecule data container. + mol = return_molecule(mol_id) + + # Rename the molecule is there is a match. + if mol: + mol.name = new_name + + +def name_residue(res_id, new_name=None): + """Function for renaming residues. + + @param res_id: The identifier string for the residue(s) to rename. + @type res_id: str + @param new_name: The new residue name. + @type new_name: str + """ + + # Split up the selection string. + mol_token, res_token, spin_token = tokenise(res_id) + + # Disallow spin selections. + if spin_token != None: + raise RelaxSpinSelectDisallowError + + # Parse the tokens. + residues = parse_token(res_token) + + # Residue loop. + for res in residue_loop(res_id): + # Rename the residue is there is a match. + if res.num in residues or res.name in residues: + res.name = new_name + + +def name_spin(spin_id=None, name=None): + """Name the spins. + + @param spin_id: The spin identification string. + @type spin_id: str + @param name: The new spin name. + @type name: str + """ + + # Rename the spin. + for spin in spin_loop(spin_id): + spin.name = name + + def parse_token(token): """Parse the token string and return a list of identifying numbers and names. Modified: branches/mol_res_spin_module_rename/generic_fns/molecule.py URL: http://svn.gna.org/viewcvs/relax/branches/mol_res_spin_module_rename/generic_fns/molecule.py?rev=6064&r1=6063&r2=6064&view=diff ============================================================================== --- branches/mol_res_spin_module_rename/generic_fns/molecule.py (original) +++ branches/mol_res_spin_module_rename/generic_fns/molecule.py Sun May 4 11:46:52 2008 @@ -33,35 +33,4 @@ """ -def name_molecule(mol_id, new_name=None): - """Function for renaming molecules. - @param mol_id: The identifier string for the molecule to rename. - @type mol_id: str - @param new_name: The new molecule name. - @type new_name: str - """ - - # Split up the selection string. - mol_token, res_token, spin_token = tokenise(mol_id) - - # Disallow spin selections. - if spin_token != None: - raise RelaxSpinSelectDisallowError - - # Disallow residue selections. - if res_token != None: - raise RelaxResSelectDisallowError - - # Alias the current data pipe. - cdp = relax_data_store[relax_data_store.current_pipe] - - # Parse the tokens. - molecules = parse_token(mol_token) - - # Get the single molecule data container. - mol = return_molecule(mol_id) - - # Rename the molecule is there is a match. - if mol: - mol.name = new_name Modified: branches/mol_res_spin_module_rename/generic_fns/residue.py URL: http://svn.gna.org/viewcvs/relax/branches/mol_res_spin_module_rename/generic_fns/residue.py?rev=6064&r1=6063&r2=6064&view=diff ============================================================================== --- branches/mol_res_spin_module_rename/generic_fns/residue.py (original) +++ branches/mol_res_spin_module_rename/generic_fns/residue.py Sun May 4 11:46:52 2008 @@ -31,32 +31,6 @@ This touches part of the molecule-residue-spin data structure. """ - - -def name_residue(res_id, new_name=None): - """Function for renaming residues. - - @param res_id: The identifier string for the residue(s) to rename. - @type res_id: str - @param new_name: The new residue name. - @type new_name: str - """ - - # Split up the selection string. - mol_token, res_token, spin_token = tokenise(res_id) - - # Disallow spin selections. - if spin_token != None: - raise RelaxSpinSelectDisallowError - - # Parse the tokens. - residues = parse_token(res_token) - - # Residue loop. - for res in residue_loop(res_id): - # Rename the residue is there is a match. - if res.num in residues or res.name in residues: - res.name = new_name def number_residue(res_id, new_number=None): Modified: branches/mol_res_spin_module_rename/generic_fns/spin.py URL: http://svn.gna.org/viewcvs/relax/branches/mol_res_spin_module_rename/generic_fns/spin.py?rev=6064&r1=6063&r2=6064&view=diff ============================================================================== --- branches/mol_res_spin_module_rename/generic_fns/spin.py (original) +++ branches/mol_res_spin_module_rename/generic_fns/spin.py Sun May 4 11:46:52 2008 @@ -33,20 +33,6 @@ """ -def name_spin(spin_id=None, name=None): - """Name the spins. - - @param spin_id: The spin identification string. - @type spin_id: str - @param name: The new spin name. - @type name: str - """ - - # Rename the spin. - for spin in spin_loop(spin_id): - spin.name = name - - def number_spin(spin_id=None, number=None): """Number the spins.