Author: bugman Date: Mon Oct 31 10:45:33 2011 New Revision: 14943 URL: http://svn.gna.org/viewcvs/relax?rev=14943&view=rev Log: Created the structure.connect_atom user function to expose the back-end functionality. This works with atom indices, so is not ideal for a user function. In the future this should be modified to handle atom ID strings instead. Modified: 1.3/generic_fns/structure/internal.py 1.3/generic_fns/structure/main.py 1.3/prompt/structure.py Modified: 1.3/generic_fns/structure/internal.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/internal.py?rev=14943&r1=14942&r2=14943&view=diff ============================================================================== --- 1.3/generic_fns/structure/internal.py (original) +++ 1.3/generic_fns/structure/internal.py Mon Oct 31 10:45:33 2011 @@ -822,6 +822,33 @@ return data + def connect_atom(self, mol_name=None, index1=None, index2=None): + """Connect two atoms in the structural data object. + + @keyword mol_name: The name of the molecule. + @type mol_name: str + @keyword index1: The global index of the first atom. + @type index1: str + @keyword index2: The global index of the first atom. + @type index2: str + """ + + # Test if the current data pipe exists. + pipes.test() + + # Add the molecule, if it does not exist. + if cdp.structure.get_molecule(mol_name) == None: + cdp.structure.add_molecule(name=mol_name) + + # Loop over each model. + for model in self.structural_data: + # Specific molecule. + mol = cdp.structure.get_molecule(mol_name) + + # Add the atom. + mol.atom_connect(index1=index1, index2=index2) + + def delete(self): """Delete all the structural information.""" Modified: 1.3/generic_fns/structure/main.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/main.py?rev=14943&r1=14942&r2=14943&view=diff ============================================================================== --- 1.3/generic_fns/structure/main.py (original) +++ 1.3/generic_fns/structure/main.py Mon Oct 31 10:45:33 2011 @@ -77,6 +77,26 @@ # Add the atoms. cdp.structure.add_atom(mol_name=mol_name, atom_name=atom_name, res_name=res_name, res_num=res_num, pos=pos, element=element, atom_num=atom_num, chain_id=chain_id, segment_id=segment_id, pdb_record=pdb_record) + + +def connect_atom(index1=None, index2=None): + """Connect two atoms. + + @keyword index1: The global index of the first atom. + @type index1: str + @keyword index2: The global index of the first atom. + @type index2: str + """ + + # Test if the current data pipe exists. + pipes.test() + + # Place the structural object into the relax data store if needed. + if not hasattr(cdp, 'structure'): + cdp.structure = Internal() + + # Add the atoms. + cdp.structure.connect_atom(index1=index1, index2=index2) def delete(): Modified: 1.3/prompt/structure.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/structure.py?rev=14943&r1=14942&r2=14943&view=diff ============================================================================== --- 1.3/prompt/structure.py (original) +++ 1.3/prompt/structure.py Mon Oct 31 10:45:33 2011 @@ -78,9 +78,37 @@ ["pdb_record", "The optional PDB record name, e.g. 'ATOM' or 'HETATM'."] ] add_atom._doc_desc = """ - This allows + This allows atoms to be added to the internal structural object. """ _build_doc(add_atom) + + + def connect_atom(self, index1=None, index2=None): + # Function intro text. + if self._exec_info.intro: + text = self._exec_info.ps3 + "structure.connect_atom(" + text = text + "index1=" + repr(index1) + text = text + ", index2=" + repr(index2) + ")" + print(text) + + # The argument checks. + arg_check.is_int(index1, 'index 1') + arg_check.is_int(index2, 'index 2') + + # Execute the functional code. + generic_fns.structure.main.connect_atom(index1=index1, index2=index2) + + # The function doc info. + connect_atom._doc_title = "Connect two atoms." + connect_atom._doc_title_short = "Atom connection." + connect_atom._doc_args = [ + ["index1", "The global index of the first atom."], + ["index2", "The global index of the second atom."] + ] + connect_atom._doc_desc = """ + This allows atoms to be connected in the internal structural object. The global index is normally equal to the PDB atom number minus 1. + """ + _build_doc(connect_atom) def create_diff_tensor_pdb(self, scale=1.8e-6, file='tensor.pdb', dir=None, force=False):