Author: bugman Date: Sun Nov 4 18:11:21 2007 New Revision: 3424 URL: http://svn.gna.org/viewcvs/relax?rev=3424&view=rev Log: Wrote the generic_fns.molecule.copy() function. Modified: 1.3/generic_fns/molecule.py Modified: 1.3/generic_fns/molecule.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/molecule.py?rev=3424&r1=3423&r2=3424&view=diff ============================================================================== --- 1.3/generic_fns/molecule.py (original) +++ 1.3/generic_fns/molecule.py Sun Nov 4 18:11:21 2007 @@ -23,6 +23,7 @@ # relax module imports. from data import Data as relax_data_store from relax_errors import RelaxError, RelaxFileEmptyError, RelaxNoPdbChainError, RelaxNoPipeError, RelaxNoSequenceError, RelaxSequenceError +from selection import return_molecule, return_single_molecule_info, tokenise # Module doc. @@ -60,42 +61,43 @@ raise RelaxNoPipeError, pipe_to # Split up the selection string. - mol_from_token, res_from_token, spin_from_token = tokenise(res_from) - mol_to_token, res_to_token, spin_to_token = tokenise(res_to) + mol_from_token, res_from_token, spin_from_token = tokenise(mol_from) + mol_to_token, res_to_token, spin_to_token = tokenise(mol_to) # Disallow spin selections. if spin_from_token != None or spin_to_token != None: raise RelaxSpinSelectDisallowError - # Parse the residue token for renaming and renumbering. - res_num_to, res_name_to = return_single_residue_info(res_to_token) - - # Test if the residue number already exists. - res_to_cont = return_residue(res_to, pipe_to) - if res_to_cont: - raise RelaxError, "The residue " + `res_to` + " already exists in the " + `pipe_from` + " data pipe." - - # Get the single residue data container. - res_from_cont = return_residue(res_from, pipe_from) - - # No residue to copy data from. - if res_from_cont == None: - raise RelaxError, "The residue " + `res_from` + " does not exist in the " + `pipe_from` + " data pipe." - - # Get the single molecule data container to copy the residue to. - mol_to_container = return_molecule(res_to, pipe_to) + # Disallow residue selections. + if res_from_token != None or res_to_token != None: + raise RelaxResSelectDisallowError + + # Parse the molecule token for renaming. + mol_name_to = return_single_molecule_info(mol_to_token) + + # Test if the molecule name already exists. + print relax_data_store[pipe_to].mol + mol_to_cont = return_molecule(mol_to, pipe_to) + print "mol_to_cont: " + `mol_to_cont` + if mol_to_cont: + raise RelaxError, "The molecule " + `mol_to` + " already exists in the " + `pipe_to` + " data pipe." + + # Get the single molecule data container. + mol_from_cont = return_molecule(mol_from, pipe_from) + + # No molecule to copy data from. + if mol_from_cont == None: + raise RelaxError, "The molecule " + `mol_from` + " does not exist in the " + `pipe_from` + " data pipe." # Copy the data. - if mol_to_container.res[0].num == None and mol_to_container.res[0].name == None and len(mol_to_container.res) == 1: - mol_to_container.res[0] = res_from_cont.__clone__() + if relax_data_store[pipe_to].mol[0].name == None and len(relax_data_store[pipe_to].mol) == 1: + relax_data_store[pipe_to].mol[0] = mol_from_cont.__clone__() else: - mol_to_container.res.append(res_from_cont.__clone__()) - - # Change the new residue number and name. - if res_num_to != None: - mol_to_container.res[-1].num = res_num_to - if res_name_to != None: - mol_to_container.res[-1].name = res_name_to + relax_data_store[pipe_to].mol.append(mol_from_cont.__clone__()) + + # Change the new molecule name. + if mol_name_to != None: + relax_data_store[pipe_to].mol[-1].name = mol_name_to def create(mol_name=None):