Author: bugman Date: Wed Jul 2 14:53:21 2014 New Revision: 24410 URL: http://svn.gna.org/viewcvs/relax?rev=24410&view=rev Log: Redesign of the pymol.frame_order user function to match the redesign of frame_order.pdb_model. The file names are no longer given but rather the file root. Then all PDB files matching that file root in the given directory will be loaded into PyMOL. Modified: branches/frame_order_cleanup/pipe_control/pymol_control.py branches/frame_order_cleanup/user_functions/pymol_control.py Modified: branches/frame_order_cleanup/pipe_control/pymol_control.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/pipe_control/pymol_control.py?rev=24410&r1=24409&r2=24410&view=diff ============================================================================== --- branches/frame_order_cleanup/pipe_control/pymol_control.py (original) +++ branches/frame_order_cleanup/pipe_control/pymol_control.py Wed Jul 2 14:53:21 2014 @@ -30,7 +30,7 @@ import pymol from math import pi from numpy import float64, transpose, zeros -from os import F_OK, access, pardir, sep +from os import F_OK, access, getcwd, pardir, sep PIPE, Popen = None, None if dep_check.subprocess_module: from subprocess import PIPE, Popen @@ -41,6 +41,7 @@ from lib.errors import RelaxError, RelaxNoPdbError, RelaxNoSequenceError from lib.geometry.rotations import euler_to_R_zyz, R_to_axis_angle from lib.io import delete, file_root, get_file_path, open_read_file, open_write_file, test_binary +from lib.structure.files import find_pdb_files from pipe_control import pipes from pipe_control.mol_res_spin import exists_mol_res_spin_data from pipe_control.result_files import add_result_file @@ -316,87 +317,106 @@ return commands -def frame_order(ave_pos_file="ave_pos.pdb", rep_file="frame_order.pdb", dist_file="domain_distribution.pdb", dir=None): +def frame_order(ave_pos="ave_pos", rep="frame_order", dist="domain_distribution", dir=None): """Display the frame order results (the geometric object, average position and distribution). - @keyword ave_pos_file: The name of the file for the average molecule structure. - @type ave_pos_file: str or None - @keyword rep_file: The name of the file of the PDB representation of the frame order dynamics to create. - @type rep_file: str or None - @keyword dist_file: The name of the file which will contain multiple models spanning the full dynamics distribution of the frame order model. - @type dist_file: str or None - @keyword dir: The name of the directory to place the PDB file into. - @type dir: str or None + @keyword ave_pos: The file root of the average molecule structure. + @type ave_pos: str or None + @keyword rep: The file root of the PDB representation of the frame order dynamics to create. + @type rep: str or None + @keyword dist: The file root which will contain multiple models spanning the full dynamics distribution of the frame order model. + @type dist: str or None + @keyword dir: The name of the directory to place the PDB file into. + @type dir: str or None """ # The path. - path = '' + path = getcwd() if dir != None: path = dir + sep # Set up the respective objects. - if ave_pos_file: - frame_order_ave_pos(file=path+ave_pos_file) - if rep_file: - frame_order_geometric(file=path+rep_file) - if dist_file: - frame_order_distribution(file=path+dist_file) - - -def frame_order_ave_pos(file=None): + if ave_pos: + frame_order_ave_pos(root=ave_pos, path=path) + if rep: + frame_order_geometric(root=rep, path=path) + if dist: + frame_order_distribution(root=dist, path=path) + + +def frame_order_ave_pos(root=None, path=None): """Display the PDB structure for the frame order average domain position. - @keyword file: The name of the PDB file containing the frame order average structure. - @type file: str - """ - - # Read in the PDB file. - pymol_obj.exec_cmd("load " + file) - - # The object ID. - id = file_root(file) - - -def frame_order_distribution(file=None): + @keyword root: The file root of the PDB file containing the frame order average structure. + @type root: str + """ + + # Find all PDB files. + pdb_files = find_pdb_files(path=path, file_root=root) + + # Read in the PDB files. + print pdb_files + for file in pdb_files: + pymol_obj.exec_cmd("load " + file) + + # The object ID. + id = file_root(file) + + +def frame_order_distribution(root=None, path=None): """Display the PDB structure for the frame order distribution of domain positions. - @keyword file: The name of the PDB file containing the frame order distribution of domain positions. - @type file: str - """ - - # Read in the PDB file. - pymol_obj.exec_cmd("load " + file) - - -def frame_order_geometric(file=None): + @keyword root: The file root of the PDB file containing the frame order distribution of domain positions. + @type root: str + """ + + # Find all PDB files. + pdb_files = find_pdb_files(path=path, file_root=root) + + # Read in the PDB files. + for file in pdb_files: + pymol_obj.exec_cmd("load " + file) + + +def frame_order_geometric(root=None, path=None): """Display the frame order geometric object. - @keyword file: The name of the PDB file containing the frame order geometric object. - @type file: str - """ - - # Read in the PDB file. - pymol_obj.exec_cmd("load " + file) - - # The object ID. - id = file_root(file) - - # First hide everything. - pymol_obj.exec_cmd("select %s" % id) - pymol_obj.exec_cmd("hide ('sele')") - pymol_obj.exec_cmd("cmd.delete('sele')") - - # Set up the pivot points. - represent_pivots(id=id) - - # Set up the rotor objects. - represent_rotor_object(id=id) - - # Set up the cone axis. - represent_cone_axis(id=id) - - # Set up the cone object. - represent_cone_object(id=id) + @keyword root: The file root of the PDB file containing the frame order geometric object. + @type root: str + """ + + # Find all PDB files. + pdb_files = find_pdb_files(path=path, file_root=root) + pdb_files += find_pdb_files(path=path, file_root=root+'_pos') + pdb_files += find_pdb_files(path=path, file_root=root+'_neg') + pdb_files += find_pdb_files(path=path, file_root=root+'_sim') + pdb_files += find_pdb_files(path=path, file_root=root+'_sim_pos') + pdb_files += find_pdb_files(path=path, file_root=root+'_sim_neg') + + # Read in the PDB files. + for file in pdb_files: + # Read in the PDB file. + pymol_obj.exec_cmd("load " + file) + + # The object ID. + id = file_root(file) + + # First hide everything. + pymol_obj.exec_cmd("select %s" % id) + pymol_obj.exec_cmd("hide ('sele')") + pymol_obj.exec_cmd("cmd.delete('sele')") + + # Set up the pivot points. + represent_pivots(id=id) + + # Set up the rotor objects. + represent_rotor_object(id=id) + + # Set up the cone axis. + represent_cone_axis(id=id) + + # Set up the cone object. + represent_cone_object(id=id) def macro_apply(data_type=None, style="classic", colour_start_name=None, colour_start_rgb=None, colour_end_name=None, colour_end_rgb=None, colour_list=None): Modified: branches/frame_order_cleanup/user_functions/pymol_control.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/user_functions/pymol_control.py?rev=24410&r1=24409&r2=24410&view=diff ============================================================================== --- branches/frame_order_cleanup/user_functions/pymol_control.py (original) +++ branches/frame_order_cleanup/user_functions/pymol_control.py Wed Jul 2 14:53:21 2014 @@ -149,36 +149,33 @@ uf.title = "Display the frame order results from the frame_order.pdb_model user function." uf.title_short = "Frame order results display." uf.add_keyarg( - name = "ave_pos_file", - default = "ave_pos.pdb", - py_type = "str", - arg_type = "file sel", - desc_short = "average structure file name", - desc = "The name of the 3D structure PDB file for the molecular structure with the moving domains shifted to the average position.", + name = "ave_pos", + default = "ave_pos", + py_type = "str", + arg_type = "str", + desc_short = "average structure file root", + desc = "The file root of the 3D structure PDB file for the molecular structure with the moving domains shifted to the average position.", wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, - wiz_filesel_style = FD_OPEN, - can_be_none = True -) -uf.add_keyarg( - name = "rep_file", - default = "frame_order.pdb", - py_type = "str", - arg_type = "file sel", - desc_short = "PDB representation file name", - desc = "The name of the PDB file for the geometric object representation of the frame order dynamics.", + can_be_none = True +) +uf.add_keyarg( + name = "rep", + default = "frame_order", + py_type = "str", + arg_type = "str", + desc_short = "PDB representation file root", + desc = "The file root of the PDB file for the geometric object representation of the frame order dynamics.", wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, - wiz_filesel_style = FD_OPEN, - can_be_none = True -) -uf.add_keyarg( - name = "dist_file", - default = "domain_distribution.pdb", - py_type = "str", - arg_type = "file sel", - desc_short = "distribution file name", - desc = "The name of the file which will contain multiple models spanning the full dynamics distribution of the frame order model.", + can_be_none = True +) +uf.add_keyarg( + name = "dist", + default = "domain_distribution", + py_type = "str", + arg_type = "str", + desc_short = "distribution file root", + desc = "The file root of the file which will contain multiple models spanning the full dynamics distribution of the frame order model.", wiz_filesel_wildcard = WILDCARD_STRUCT_PDB_ALL, - wiz_filesel_style = FD_OPEN, can_be_none = True ) uf.add_keyarg( @@ -191,7 +188,8 @@ ) # Description. uf.desc.append(Desc_container()) -uf.desc[-1].add_paragraph("This user function is designed to be combined with the frame_order.pdb_model user function. It will take the three PDB files created by frame_order.pdb_model - the molecular structure with the averaged domain positions, the frame order dynamics representation file, and the moving domain distribution file - and display them in PyMOL. Rather than loading the three files into PyMOL manually, this user function will change the representation to significantly improve the visualisation.") +uf.desc[-1].add_paragraph("This user function is designed to be combined with the frame_order.pdb_model user function. It will take the three PDB representations created by frame_order.pdb_model - the molecular structure with the averaged domain positions, the frame order dynamics representation files, and the moving domain distribution file - and display them in PyMOL. Rather than loading the three representations into PyMOL manually, this user function will change the representation to significantly improve the visualisation.") +uf.desc[-1].add_paragraph("For the frame order representation files,if the file root is left to the default of 'frame_order' then all of the following files will be loaded: 'frame_order.pdb', 'frame_order_pos.pdb', 'frame_order_neg.pdb', 'frame_order_sim.pdb', 'frame_order_sim_pos.pdb', 'frame_order_sim_neg.pdb'. The user function will not only search for these files, but also all *.gz and *.bz2 versions of these files. This is to support all output files from the frame_order.pdb_model user function.") uf.backend = pymol_control.frame_order uf.menu_text = "&frame_order" uf.gui_icon = "relax.frame_order"