Author: bugman Date: Sun Nov 4 18:00:03 2007 New Revision: 3420 URL: http://svn.gna.org/viewcvs/relax?rev=3420&view=rev Log: Added the 'return_single_molecule_info()' function and fixed the 'return_molecule()' function. The 'return_molecule()' function was returning a molecule container when no molecule selection was given. Now None is returned. Modified: 1.3/generic_fns/selection.py Modified: 1.3/generic_fns/selection.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/selection.py?rev=3420&r1=3419&r2=3420&view=diff ============================================================================== --- 1.3/generic_fns/selection.py (original) +++ 1.3/generic_fns/selection.py Sun Nov 4 18:00:03 2007 @@ -473,6 +473,10 @@ # Parse the selection string. select_obj = Selection(selection) + # No selection. + if len(select_obj.molecules) == 0: + return None + # Loop over the molecules. mol = None mol_num = 0 @@ -549,6 +553,31 @@ # Return the residue container. return res_container + + +def return_single_molecule_info(molecule_token): + """Return the single molecule name corresponding to the molecule token. + + @param molecule_token: The molecule identification string. + @type molecule_token: str + @return: The molecule name. + @rtype: str + """ + + # Parse the molecule token for renaming and renumbering. + molecule_info = parse_token(molecule_token) + + # Determine the molecule name. + mol_name = None + for info in molecule_info: + # A molecule name identifier. + if mol_name == None: + mol_name = info + else: + raise RelaxError, "The molecule identifier " + `molecule_token` + " does not correspond to a single molecule." + + # Return the molecule name. + return mol_name def return_single_residue_info(residue_token):