Author: bugman Date: Tue Apr 8 10:37:54 2008 New Revision: 5404 URL: http://svn.gna.org/viewcvs/relax?rev=5404&view=rev Log: Updated the macro_exec() function to the new relax design. Modified: 1.3/generic_fns/pymol.py Modified: 1.3/generic_fns/pymol.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/pymol.py?rev=5404&r1=5403&r2=5404&view=diff ============================================================================== --- 1.3/generic_fns/pymol.py (original) +++ 1.3/generic_fns/pymol.py Tue Apr 8 10:37:54 2008 @@ -191,8 +191,147 @@ return commands -def macro_exec(run=None, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None): - """Function for executing a PyMOL macro.""" +def macro_exec(data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None): + """Execute a PyMOL macro. + + @keyword data_type: The data type ot map to the structure. + @type data_type: str + @keyword style: The style of the macro. + @type style: str + @keyword colour_start: The starting colour of the linear gradient. + @type colour_start: str or RBG colour array (len 3 with vals from 0 to 1) + @keyword colour_end: The ending colour of the linear gradient. + @type colour_end: str or RBG colour array (len 3 with vals from 0 to 1) + @keyword colour_list: The colour list to search for the colour names. Can be either 'molmol' + or 'x11'. + @type colour_list: str or None + """ + + # Test if the current data pipe exists. + if not relax_data_store.current_pipe: + raise RelaxNoPipeError + + # Test if sequence data exists. + if not exists_mol_res_spin_data(): + raise RelaxNoSequenceError + + # Create the macro. + commands = create_macro(data_type=data_type, style=style, colour_start=colour_start, colour_end=colour_end, colour_list=colour_list) + + # Loop over the commands and execute them. + for command in commands: + pymol.pipe_write(command) + + +def tensor_pdb(run=None, file=None): + """Display the diffusion tensor geometric structure.""" + + # Arguments. + self.run = run + + # Test if the run exists. + if not self.run in relax_data_store.run_names: + raise RelaxNoPipeError, self.run + + # Read in the tensor PDB file. + self.pipe_write("load " + file) + + + # Centre of mass. + ################# + + # Select the COM residue. + self.pipe_write("select resn COM") + + # Show the centre of mass as the dots representation. + self.pipe_write("show dots, 'sele'") + + # Colour it blue. + self.pipe_write("color blue, 'sele'") + + + # The diffusion tensor axes. + ############################ + + # Select the AXS residue. + self.pipe_write("select resn AXS") + + # Hide everything. + self.pipe_write("hide ('sele')") + + # Show as 'sticks'. + self.pipe_write("show sticks, 'sele'") + + # Colour it cyan. + self.pipe_write("color cyan, 'sele'") + + # Select the N atoms of the AXS residue (used to display the axis labels). + self.pipe_write("select (resn AXS and elem N)") + + # Label the atoms. + self.pipe_write("label 'sele', name") + + + + # Monte Carlo simulations. + ########################## + + # Select the SIM residue. + self.pipe_write("select resn SIM") + + # Colour it. + self.pipe_write("colour cyan, 'sele'") + + + # Clean up. + ########### + + # Remove the selection. + self.pipe_write("cmd.delete('sele')") + + +def vector_dist(run=None, file=None): + """Display the XH bond vector distribution. + + @param run: The run + @type run: str + @param file: The vector distribution PDB file. + @type file: str + """ + + # Arguments. + self.run = run + + # Test if the run exists. + if not self.run in relax_data_store.run_names: + raise RelaxNoPipeError, self.run + + # The file root. + id = file_root(file) + + # Read in the vector distribution PDB file. + self.pipe_write("load " + file) + + + # Create a surface. + ################### + + # Select the vector distribution. + self.pipe_write("cmd.show('surface', " + `id` + ")") + + +def view(): + """Function for running PyMOL.""" + + # Open a PyMOL pipe. + if pymol.pipe_open_test(): + raise RelaxError, "The PyMOL pipe already exists." + else: + pymol.pipe_open() + + +def write(run=None, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None, file=None, dir=None, force=0): + """Function for creating a PyMOL macro.""" # Arguments. self.run = run @@ -216,143 +355,6 @@ # Create the macro. self.create_macro() - # Loop over the commands and execute them. - for command in self.commands: - self.pipe_write(command) - - -def tensor_pdb(run=None, file=None): - """Display the diffusion tensor geometric structure.""" - - # Arguments. - self.run = run - - # Test if the run exists. - if not self.run in relax_data_store.run_names: - raise RelaxNoPipeError, self.run - - # Read in the tensor PDB file. - self.pipe_write("load " + file) - - - # Centre of mass. - ################# - - # Select the COM residue. - self.pipe_write("select resn COM") - - # Show the centre of mass as the dots representation. - self.pipe_write("show dots, 'sele'") - - # Colour it blue. - self.pipe_write("color blue, 'sele'") - - - # The diffusion tensor axes. - ############################ - - # Select the AXS residue. - self.pipe_write("select resn AXS") - - # Hide everything. - self.pipe_write("hide ('sele')") - - # Show as 'sticks'. - self.pipe_write("show sticks, 'sele'") - - # Colour it cyan. - self.pipe_write("color cyan, 'sele'") - - # Select the N atoms of the AXS residue (used to display the axis labels). - self.pipe_write("select (resn AXS and elem N)") - - # Label the atoms. - self.pipe_write("label 'sele', name") - - - - # Monte Carlo simulations. - ########################## - - # Select the SIM residue. - self.pipe_write("select resn SIM") - - # Colour it. - self.pipe_write("colour cyan, 'sele'") - - - # Clean up. - ########### - - # Remove the selection. - self.pipe_write("cmd.delete('sele')") - - -def vector_dist(run=None, file=None): - """Display the XH bond vector distribution. - - @param run: The run - @type run: str - @param file: The vector distribution PDB file. - @type file: str - """ - - # Arguments. - self.run = run - - # Test if the run exists. - if not self.run in relax_data_store.run_names: - raise RelaxNoPipeError, self.run - - # The file root. - id = file_root(file) - - # Read in the vector distribution PDB file. - self.pipe_write("load " + file) - - - # Create a surface. - ################### - - # Select the vector distribution. - self.pipe_write("cmd.show('surface', " + `id` + ")") - - -def view(): - """Function for running PyMOL.""" - - # Open a PyMOL pipe. - if pymol.pipe_open_test(): - raise RelaxError, "The PyMOL pipe already exists." - else: - pymol.pipe_open() - - -def write(run=None, data_type=None, style="classic", colour_start=None, colour_end=None, colour_list=None, file=None, dir=None, force=0): - """Function for creating a PyMOL macro.""" - - # Arguments. - self.run = run - self.data_type = data_type - self.style = style - self.colour_start = colour_start - self.colour_end = colour_end - self.colour_list = colour_list - - # No coded yet. - raise RelaxImplementError - - # Test if the run exists. - if not self.run in relax_data_store.run_names: - raise RelaxNoPipeError, self.run - - # Test if the sequence data is loaded. - if not relax_data_store.res.has_key(self.run): - raise RelaxNoSequenceError, self.run - - # Create the macro. - self.create_macro() - # File name. if file == None: file = data_type + '.mac'