Author: bugman Date: Tue Oct 31 08:59:50 2006 New Revision: 2709 URL: http://svn.gna.org/viewcvs/relax?rev=2709&view=rev Log: Implemented the 'pymol.cartoon()' user function. This was modified from the 'molmol.ribbon()' user function. The molmol commands have been replaced with commands to hide everything, show the cartoon, and colour the cartoon by secondary structure. Modified: branches/tensor_pdb/generic_fns/pymol.py branches/tensor_pdb/prompt/pymol.py Modified: branches/tensor_pdb/generic_fns/pymol.py URL: http://svn.gna.org/viewcvs/relax/branches/tensor_pdb/generic_fns/pymol.py?rev=2709&r1=2708&r2=2709&view=diff ============================================================================== --- branches/tensor_pdb/generic_fns/pymol.py (original) +++ branches/tensor_pdb/generic_fns/pymol.py Tue Oct 31 08:59:50 2006 @@ -32,6 +32,29 @@ # Initialise the command history (for reopening Molmol pipes). self.clear_history() + + + def cartoon(self, run=None): + """Apply the PyMOL cartoon style and colour by secondary structure.""" + + # Arguments. + self.run = run + + # Test if the run exists. + if not self.run in self.relax.data.run_names: + raise RelaxNoRunError, self.run + + # Identifier. + id = self.relax.data.pdb[self.run].file_name[:-4] + + # Hide everything. + self.pipe_write("cmd.hide('everything'," + `id` + ")") + + # Show the cartoon style. + self.pipe_write("cmd.show('cartoon'," + `id` + ")") + + # Colour by secondary structure. + self.pipe_write("util.cbss(" + `id` + ", 'red', 'yellow', 'green')") def clear_history(self): @@ -164,27 +187,6 @@ # Place the command in the command history. if store_command: self.command_history = self.command_history + command + "\n" - - - def ribbon(self, run=None): - """Apply the Molmol ribbon style.""" - - # Arguments. - self.run = run - - # Test if the run exists. - if not self.run in self.relax.data.run_names: - raise RelaxNoRunError, self.run - - # Calculate the protons. - self.pipe_write("CalcAtom 'H'") - self.pipe_write("CalcAtom 'HN'") - - # Calculate the secondary structure. - self.pipe_write("CalcSecondary") - - # Execute the ribbon macro. - self.pipe_write("XMacStand ribbon.mac") def tensor_pdb(self, run=None, file=None): Modified: branches/tensor_pdb/prompt/pymol.py URL: http://svn.gna.org/viewcvs/relax/branches/tensor_pdb/prompt/pymol.py?rev=2709&r1=2708&r2=2709&view=diff ============================================================================== --- branches/tensor_pdb/prompt/pymol.py (original) +++ branches/tensor_pdb/prompt/pymol.py Tue Oct 31 08:59:50 2006 @@ -207,26 +207,28 @@ Description ~~~~~~~~~~~ - This function applies the Molmol ribbon style which is equivalent to clicking on 'ribbon' in - the Molmol side menu. To do this, the following commands are executed: - - CalcAtom 'H' - CalcAtom 'HN' - CalcSecondary - XMacStand ribbon.mac + This function applies the PyMOL cartoon style which is equivalent to hiding everything and + clicking on show cartoon. It also colours the cartoon with red helices, yellow strands, and + green loops. The following commands are executed: + + cmd.hide('everything', file) + cmd.show('cartoon', file) + util.cbss(file, 'red', 'yellow', 'green') + + where file is the file name without the '.pdb' extension. Example ~~~~~~~ - To apply the ribbon style to the PDB file loaded for the run 'final', type: - - relax> pymol.ribbon("final") - """ - - # Function intro text. - if self.__relax__.interpreter.intro: - text = sys.ps3 + "pymol.ribbon(" + To apply this user function to the run 'final', type: + + relax> pymol.cartoon("final") + """ + + # Function intro text. + if self.__relax__.interpreter.intro: + text = sys.ps3 + "pymol.cartoon(" text = text + "run=" + `run` + ")" print text @@ -235,7 +237,7 @@ raise RelaxStrError, ('run', run) # Execute the functional code. - self.__relax__.generic.pymol.ribbon(run=run) + self.__relax__.generic.pymol.cartoon(run=run) def tensor_pdb(self, run=None, file=None):