Author: bugman Date: Sun May 4 11:41:39 2008 New Revision: 6061 URL: http://svn.gna.org/viewcvs/relax?rev=6061&view=rev Log: Shifted all the delete 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=6061&r1=6060&r2=6061&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:41:39 2008 @@ -778,6 +778,127 @@ res_to_cont.spin.add_item(spin_num=spin_num, spin_name=spin_name) +def delete_molecule(mol_id=None): + """Function for deleting molecules from the current data pipe. + + @param mol_id: The molecule identifier string. + @type mol_id: 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 + + # Parse the token. + molecules = parse_token(mol_token) + + # Alias the current data pipe. + cdp = relax_data_store[relax_data_store.current_pipe] + + # List of indecies to delete. + indecies = [] + + # Loop over the molecules. + for i in xrange(len(cdp.mol)): + # Remove the residue is there is a match. + if cdp.mol[i].name in molecules: + indecies.append(i) + + # Reverse the indecies. + indecies.reverse() + + # Delete the molecules. + for index in indecies: + cdp.mol.pop(index) + + # Create an empty residue container if no residues remain. + if len(cdp.mol) == 0: + cdp.mol.add_item() + + +def delete_residue(res_id=None): + """Function for deleting residues from the current data pipe. + + @param res_id: The molecule and residue identifier string. + @type res_id: 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) + + # Molecule loop. + for mol in molecule_loop(mol_token): + # List of indecies to delete. + indecies = [] + + # Loop over the residues of the molecule. + for i in xrange(len(mol.res)): + # Remove the residue is there is a match. + if mol.res[i].num in residues or mol.res[i].name in residues: + indecies.append(i) + + # Reverse the indecies. + indecies.reverse() + + # Delete the residues. + for index in indecies: + mol.res.pop(index) + + # Create an empty residue container if no residues remain. + if len(mol.res) == 0: + mol.res.add_item() + + +def delete_spin(spin_id=None): + """Function for deleting spins from the current data pipe. + + @param spin_id: The molecule, residue, and spin identifier string. + @type spin_id: str + """ + + # Split up the selection string. + mol_token, res_token, spin_token = tokenise(spin_id) + + # Parse the tokens. + spins = parse_token(spin_token) + + # Residue loop. + for res in residue_loop(spin_id): + # List of indecies to delete. + indecies = [] + + # Loop over the spins of the residue. + for i in xrange(len(res.spin)): + # Store the spin indecies for deletion. + if res.spin[i].num in spins or res.spin[i].name in spins: + indecies.append(i) + + # Reverse the indecies. + indecies.reverse() + + # Delete the spins. + for index in indecies: + res.spin.pop(index) + + # Create an empty spin container if no spins remain. + if len(res.spin) == 0: + res.spin.add_item() + + def exists_mol_res_spin_data(): """Function for determining if any molecule-residue-spin data exists. 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=6061&r1=6060&r2=6061&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:41:39 2008 @@ -31,51 +31,6 @@ This touches part of the molecule-residue-spin data structure. """ - - -def delete_molecule(mol_id=None): - """Function for deleting molecules from the current data pipe. - - @param mol_id: The molecule identifier string. - @type mol_id: 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 - - # Parse the token. - molecules = parse_token(mol_token) - - # Alias the current data pipe. - cdp = relax_data_store[relax_data_store.current_pipe] - - # List of indecies to delete. - indecies = [] - - # Loop over the molecules. - for i in xrange(len(cdp.mol)): - # Remove the residue is there is a match. - if cdp.mol[i].name in molecules: - indecies.append(i) - - # Reverse the indecies. - indecies.reverse() - - # Delete the molecules. - for index in indecies: - cdp.mol.pop(index) - - # Create an empty residue container if no residues remain. - if len(cdp.mol) == 0: - cdp.mol.add_item() def display_molecule(mol_id=None): 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=6061&r1=6060&r2=6061&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:41:39 2008 @@ -31,46 +31,6 @@ This touches part of the molecule-residue-spin data structure. """ - - -def delete_residue(res_id=None): - """Function for deleting residues from the current data pipe. - - @param res_id: The molecule and residue identifier string. - @type res_id: 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) - - # Molecule loop. - for mol in molecule_loop(mol_token): - # List of indecies to delete. - indecies = [] - - # Loop over the residues of the molecule. - for i in xrange(len(mol.res)): - # Remove the residue is there is a match. - if mol.res[i].num in residues or mol.res[i].name in residues: - indecies.append(i) - - # Reverse the indecies. - indecies.reverse() - - # Delete the residues. - for index in indecies: - mol.res.pop(index) - - # Create an empty residue container if no residues remain. - if len(mol.res) == 0: - mol.res.add_item() def display_residue(res_id=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=6061&r1=6060&r2=6061&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:41:39 2008 @@ -31,42 +31,6 @@ This touches part of the molecule-residue-spin data structure. """ - - -def delete_spin(spin_id=None): - """Function for deleting spins from the current data pipe. - - @param spin_id: The molecule, residue, and spin identifier string. - @type spin_id: str - """ - - # Split up the selection string. - mol_token, res_token, spin_token = tokenise(spin_id) - - # Parse the tokens. - spins = parse_token(spin_token) - - # Residue loop. - for res in residue_loop(spin_id): - # List of indecies to delete. - indecies = [] - - # Loop over the spins of the residue. - for i in xrange(len(res.spin)): - # Store the spin indecies for deletion. - if res.spin[i].num in spins or res.spin[i].name in spins: - indecies.append(i) - - # Reverse the indecies. - indecies.reverse() - - # Delete the spins. - for index in indecies: - res.spin.pop(index) - - # Create an empty spin container if no spins remain. - if len(res.spin) == 0: - res.spin.add_item() def display_spin(spin_id=None):