Author: bugman Date: Mon Jul 7 22:58:23 2008 New Revision: 6813 URL: http://svn.gna.org/viewcvs/relax?rev=6813&view=rev Log: Swapped the generic_fns.relax_re.search() arg order, and fixed all calls to it. Modified: 1.3/generic_fns/mol_res_spin.py 1.3/generic_fns/relax_re.py Modified: 1.3/generic_fns/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/mol_res_spin.py?rev=6813&r1=6812&r2=6813&view=diff ============================================================================== --- 1.3/generic_fns/mol_res_spin.py (original) +++ 1.3/generic_fns/mol_res_spin.py Mon Jul 7 22:58:23 2008 @@ -221,7 +221,7 @@ select_mol = True # A true match. - elif relax_re.search(mol.name, self.molecules): + elif relax_re.search(self.molecules, mol.name): select_mol = True else: # No molecule container sent in, therefore the molecule is assumed to match. @@ -234,7 +234,7 @@ select_res = True # A true match. - elif relax_re.search(res.name, self.residues) or res.num in self.residues: + elif relax_re.search(self.residues, res.name) or res.num in self.residues: select_res = True else: # No residue container sent in, therefore the residue is assumed to match. @@ -247,7 +247,7 @@ select_spin = True # A true match. - elif relax_re.search(spin.name, self.spins) or spin.num in self.spins: + elif relax_re.search(self.spins, spin.name) or spin.num in self.spins: select_spin = True else: # No spin container sent in, therefore the spin is assumed to match. @@ -299,7 +299,7 @@ return self._intersect[0].contains_mol(mol) and self._intersect[1].contains_mol(mol) # The check. - if relax_re.search(mol, self.molecules): + if relax_re.search(self.molecules, mol): return True # Nothingness. @@ -339,7 +339,7 @@ select_res = False # The residue checks. - if res_num in self.residues or relax_re.search(res_name, self.residues): + if res_num in self.residues or relax_re.search(self.residues, res_name): select_res = True # Nothingness. @@ -386,7 +386,7 @@ select_spin = False # The spin checks. - if spin_num in self.spins or relax_re.search(spin_name, self.spins): + if spin_num in self.spins or relax_re.search(self.spins, spin_name): select_spin = True # Nothingness. Modified: 1.3/generic_fns/relax_re.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/relax_re.py?rev=6813&r1=6812&r2=6813&view=diff ============================================================================== --- 1.3/generic_fns/relax_re.py (original) +++ 1.3/generic_fns/relax_re.py Mon Jul 7 22:58:23 2008 @@ -28,8 +28,8 @@ from string import replace -def search(id, patterns): - """Determine if id is in the list of patterns, or vice versa, allowing for regular expressions. +def search(pattern, id): + """Determine if id matches the pattern, or vice versa, allowing for regular expressions. This method converts from relax's RE syntax to that of the re python module. @@ -38,15 +38,16 @@ 1. All '*' to '.*'. 2. The identifier is bracketed, '^' is added to the start and '$' to the end. - After conversion of both the id and patterns, the comparison is then performed both ways from - the converted string matching the original string (using re.search()). + After conversion of both the string and patterns, the comparison is then performed both ways + from the converted string matching the original string (using re.search()). + @param pattern: The pattern to match the string to. This can be a list of patterns. All + elements will be converted to strings, so the pattern or list can consist of + anything. + @type pattern: anything @param id: The identification object. @type id: None, str, or number - @param patterns: A list of patterns to match. The elements will be converted to strings, - so the list can consist of anything. - @type patterns: list @return: True if there is a match, False otherwise. @rtype: bool """ @@ -58,6 +59,12 @@ # If a number, convert to a string. if type(id) == int or type(id) == float: id = str(id) + + # If pattern is not a list, convert it to one. + if type(pattern) != list: + patterns = [pattern] + else: + patterns = pattern # Loop over the patterns. for pattern in patterns: