Author: bugman Date: Fri Mar 22 17:34:27 2013 New Revision: 19002 URL: http://svn.gna.org/viewcvs/relax?rev=19002&view=rev Log: Next block of the manual merger of the frame_order_testing branch. The commands used were: svn merge -r18860:18861 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . svn merge -r18861:18862 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . svn merge -r18862:18863 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . svn merge -r18863:18864 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . svn merge -r18864:18865 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . The console messages were: [edau@localhost relax-trunk]$ svn merge -r18860:18861 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . --- Merging r18861 into '.': U auto_analyses/frame_order.py [edau@localhost relax-trunk]$ svn merge -r18861:18862 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . --- Merging r18862 into '.': G auto_analyses/frame_order.py [edau@localhost relax-trunk]$ svn merge -r18862:18863 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . --- Merging r18863 into '.': U specific_fns/frame_order.py U user_functions/frame_order.py [edau@localhost relax-trunk]$ svn merge -r18863:18864 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . --- Merging r18864 into '.': G specific_fns/frame_order.py [edau@localhost relax-trunk]$ svn merge -r18864:18865 svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/frame_order_testing . --- Merging r18865 into '.': G specific_fns/frame_order.py [edau@localhost relax-trunk]$ Modified: trunk/auto_analyses/frame_order.py trunk/specific_fns/frame_order.py trunk/user_functions/frame_order.py Modified: trunk/auto_analyses/frame_order.py URL: http://svn.gna.org/viewcvs/relax/trunk/auto_analyses/frame_order.py?rev=19002&r1=19001&r2=19002&view=diff ============================================================================== --- trunk/auto_analyses/frame_order.py (original) +++ trunk/auto_analyses/frame_order.py Fri Mar 22 17:34:27 2013 @@ -129,7 +129,7 @@ # Execute the full protocol. try: # The nested model optimisation protocol. - self.optimise() + self.nested_models() # The final results does not already exist. if not self.read_results(model='final', pipe_name='final'): @@ -148,10 +148,10 @@ self.interpreter.monte_carlo.error_analysis() # Finish. - self.interpreter.results.write(file='results', force=True) - - # Results visualisation. - self.visualisation() + self.interpreter.results.write(file='results', dir=self.results_dir+'final', force=True) + + # Visualisation of the final results. + self.visualisation(model='final') # Clean up. finally: @@ -159,7 +159,7 @@ status.exec_lock.release() # Save the final program state. - self.interpreter.state.save('final_state', force=True) + self.interpreter.state.save('final_state', dir=self.results_dir, force=True) def check_vars(self): @@ -316,7 +316,7 @@ cdp.cone_theta_y = pipe.cone_theta - def optimise(self): + def nested_models(self): """Protocol for the nested optimisation of the frame order models.""" # First optimise the rigid model using all data. @@ -343,6 +343,9 @@ # Re-perform model elimination just in case. self.interpreter.eliminate() + # The PDB representation of the model and visualisation script (in case this was not completed correctly). + self.visualisation(model=model) + # Skip to the next model. continue @@ -384,7 +387,10 @@ self.interpreter.eliminate() # Save the results. - self.interpreter.results.write(dir=model, force=True) + self.interpreter.results.write(dir=self.results_dir+model, force=True) + + # The PDB representation of the model and visualisation script. + self.visualisation(model=model) def optimise_rigid(self): @@ -406,6 +412,10 @@ # The results file already exists, so read its contents instead. if self.read_results(model=model, pipe_name=self.pipe_name_dict[model]): + # The PDB representation of the model (in case this was not completed correctly). + self.interpreter.frame_order.pdb_model(dir=self.results_dir+model, force=True) + + # Nothing more to do. return # Create the data pipe using the full data set, and switch to it. @@ -439,7 +449,10 @@ self.print_results() # Save the results. - self.interpreter.results.write(dir=model, force=True) + self.interpreter.results.write(dir=self.results_dir+model, force=True) + + # The PDB representation of the model. + self.interpreter.frame_order.pdb_model(dir=self.results_dir+model, force=True) def print_results(self): @@ -538,7 +551,7 @@ """ # The file name. - path = model + sep + 'results.bz2' + path = self.results_dir + model + sep + 'results.bz2' # The file does not exist. if not access(path, F_OK): @@ -557,37 +570,33 @@ return True - def visualisation(self): - """Create visual representations of the frame order results. + def visualisation(self, model=None): + """Create visual representations of the frame order results for the given model. This includes a PDB representation of the motions (the 'cone.pdb' file located in each model directory) together with a relax script for displaying the average domain positions together with the cone/motion representation in PyMOL (the 'pymol_display.py' file, also created in the model directory). + + @keyword model: The frame order model to visualise. This should match the model of the current data pipe, unless the special value of 'final' is used to indicate the visualisation of the final results. + @type model: str """ - # Loop over all models. - for pipe_name in self.pipe_name_list + ['final']: - # Switch to the data pipe. - self.interpreter.pipe.switch(pipe_name) - - # The directory to place files into. - if pipe_name == 'final': - results_dir = pipe_name - else: - results_dir = cdp.model - - # Create a PDB file representation of the motions. - self.interpreter.frame_order.pdb_model(file='frame_order.pdb', dist_file='frame_order_distribution.pdb', dir=results_dir, force=True) - - # Create the visualisation script. - script = open_write_file(file_name='pymol_display.py', dir=results_dir, force=True) - - # Add a comment for the user. - script.write("# relax script for displaying the frame order results of this '%s' model in PyMOL.\n\n" % results_dir) - - # The script contents. - script.write("# PyMOL visualisation.\n") - script.write("pymol.view()\n") - script.write("pymol.command('show spheres')\n") - script.write("pymol.frame_order(file='frame_order.pdb', dist_file='frame_order_distribution.pdb')\n") - - # Close the file. - script.close() + # Sanity check. + if model != 'final' and model != cdp.model: + raise RelaxError("The model '%s' does not match the model '%s' of the current data pipe." % (model, cdp.model)) + + # The PDB representation of the model. + self.interpreter.frame_order.pdb_model(dir=self.results_dir+model, force=True) + + # Create the visualisation script. + script = open_write_file(file_name='pymol_display.py', dir=self.results_dir+model, force=True) + + # Add a comment for the user. + script.write("# relax script for displaying the frame order results of this '%s' model in PyMOL.\n\n" % model) + + # The script contents. + script.write("# PyMOL visualisation.\n") + script.write("pymol.view()\n") + script.write("pymol.command('show spheres')\n") + script.write("pymol.frame_order(file='frame_order.pdb', dist_file='frame_order_distribution.pdb')\n") + + # Close the file. + script.close() Modified: trunk/specific_fns/frame_order.py URL: http://svn.gna.org/viewcvs/relax/trunk/specific_fns/frame_order.py?rev=19002&r1=19001&r2=19002&view=diff ============================================================================== --- trunk/specific_fns/frame_order.py (original) +++ trunk/specific_fns/frame_order.py Fri Mar 22 17:34:27 2013 @@ -946,30 +946,66 @@ return num - def _pdb_model(self, file=None, dist_file=None, dir=None, size=30.0, inc=36, force=False, neg_cone=True): - """Create a PDB file containing a geometric object representing the Frame Order cone models. - - @keyword file: The name of the file of the PDB representation of the frame order dynamics to create. - @type file: str - @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 - @keyword dir: The name of the directory to place the PDB file into. - @type dir: str - @keyword size: The size of the geometric object in Angstroms. - @type size: float - @keyword inc: The number of increments for the filling of the cone objects. - @type inc: int - @keyword force: Flag which if set to True will cause any pre-existing file to be overwritten. - @type force: bool - @keyword neg_cone: A flag which if True will cause the negative cone to be added to the representation. - @type neg_cone: bool - """ - - # Test if the current data pipe exists. - pipes.test() - - # Negative cone flag. - neg_cone = True + def _pdb_ave_pos(self, file=None, dir=None, force=False): + """Create a PDB file of the molecule with the moving domains shifted to the average position. + + @keyword file: The name of the file for the average molecule structure. + @type file: str + @keyword dir: The name of the directory to place the PDB file into. + @type dir: str + @keyword force: Flag which if set to True will cause any pre-existing file to be overwritten. + @type force: bool + """ + + # Make a copy of the structural object (so as to preserve the original structure). + structure = deepcopy(cdp.structure) + + # First rotate the moving domain to the average position. + R = zeros((3, 3), float64) + if hasattr(cdp, 'ave_pos_alpha'): + euler_to_R_zyz(cdp.ave_pos_alpha, cdp.ave_pos_beta, cdp.ave_pos_gamma, R) + else: + euler_to_R_zyz(0.0, cdp.ave_pos_beta, cdp.ave_pos_gamma, R) + structure.rotate(R=R, origin=cdp.pivot, atom_id=self._domain_moving()) + + # Then translate the moving domain. + if not self._translation_fixed(): + structure.translate(T=[cdp.ave_pos_x, cdp.ave_pos_y, cdp.ave_pos_z], atom_id=self._domain_moving()) + + # Write out the PDB file. + file = open_write_file(file_name=file, dir=dir, force=force) + structure.write_pdb(file=file) + file.close() + + + def _pdb_distribution(self, file=None, dir=None, force=False): + """Create a PDB file of a distribution of positions coving the full dynamics of the moving domain. + + @keyword file: The name of the file which will contain multiple models spanning the full dynamics distribution of the frame order model. + @type file: str + @keyword dir: The name of the directory to place the PDB file into. + @type dir: str + @keyword force: Flag which if set to True will cause any pre-existing file to be overwritten. + @type force: bool + """ + + + def _pdb_geometric_rep(self, file=None, dir=None, size=30.0, inc=36, force=False, neg_cone=True): + """Create a PDB file containing a geometric object representing the frame order dynamics. + + @keyword file: The name of the file of the PDB representation of the frame order dynamics to create. + @type file: str + @keyword dir: The name of the directory to place the PDB file into. + @type dir: str + @keyword size: The size of the geometric object in Angstroms. + @type size: float + @keyword inc: The number of increments for the filling of the cone objects. + @type inc: int + @keyword force: Flag which if set to True will cause any pre-existing file to be overwritten. + @type force: bool + @keyword neg_cone: A flag which if True will cause the negative cone to be added to the representation. + @type neg_cone: bool + """ # Monte Carlo simulation flag. sim = False @@ -1142,6 +1178,44 @@ pdb_file = open_write_file(file, dir, force=force) structure.write_pdb(pdb_file) pdb_file.close() + + + def _pdb_model(self, ave_pos_file="ave_pos.pdb", rep_file="frame_order.pdb", dist_file="domain_distribution.pdb", dir=None, size=30.0, inc=36, force=False, neg_cone=True): + """Create 3 different PDB files for representing the frame order dynamics of the system. + + @keyword ave_pos_file: The name of the file for the average molecule structure. + @type ave_pos_file: str + @keyword rep_file: The name of the file of the PDB representation of the frame order dynamics to create. + @type rep_file: str + @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 + @keyword dir: The name of the directory to place the PDB file into. + @type dir: str + @keyword size: The size of the geometric object in Angstroms. + @type size: float + @keyword inc: The number of increments for the filling of the cone objects. + @type inc: int + @keyword force: Flag which if set to True will cause any pre-existing file to be overwritten. + @type force: bool + @keyword neg_cone: A flag which if True will cause the negative cone to be added to the representation. + @type neg_cone: bool + """ + + # Test if the current data pipe exists. + pipes.test() + + # Create the average position structure. + self._pdb_ave_pos(file=ave_pos_file, dir=dir, force=force) + + # Nothing more to do for the rigid model. + if cdp.model == 'rigid': + return + + # Create the geometric representation. + self._pdb_geometric_rep(file=rep_file, dir=dir, size=size, inc=inc, force=force, neg_cone=neg_cone) + + # Create the distribution. + self._pdb_distribution(file=dist_file, dir=dir, force=force) def _pivot(self, pivot=None, fix=None): Modified: trunk/user_functions/frame_order.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/frame_order.py?rev=19002&r1=19001&r2=19002&view=diff ============================================================================== --- trunk/user_functions/frame_order.py (original) +++ trunk/user_functions/frame_order.py Fri Mar 22 17:34:27 2013 @@ -98,18 +98,28 @@ uf.title = "Create a PDB file representation of the frame order dynamics." uf.title_short = "Frame order dynamics PDB representation." uf.add_keyarg( - name = "file", - default = "frame_order.pdb", + name = "ave_pos_file", + default = "ave_pos.pdb", py_type = "str", arg_type = "file sel", - desc_short = "file name", - desc = "The name of the file of the PDB representation of the frame order dynamics to create.", + 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.", wiz_filesel_wildcard = "PDB files (*.pdb)|*.pdb;*.PDB", wiz_filesel_style = FD_SAVE ) 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.", + wiz_filesel_wildcard = "PDB files (*.pdb)|*.pdb;*.PDB", + wiz_filesel_style = FD_SAVE +) +uf.add_keyarg( name = "dist_file", - default = "frame_order_distribution.pdb", + default = "domain_distribution.pdb", py_type = "str", arg_type = "file sel", desc_short = "distribution file name",