mailr13255 - /branches/gui_testing/gui/analyses/auto_noe.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on June 28, 2011 - 12:28:
Author: bugman
Date: Tue Jun 28 12:28:06 2011
New Revision: 13255

URL: http://svn.gna.org/viewcvs/relax?rev=13255&view=rev
Log:
The higher level threading.Thread class is being used rather than 
thread.start_new_thread().

This will allow for better thread control.


Modified:
    branches/gui_testing/gui/analyses/auto_noe.py

Modified: branches/gui_testing/gui/analyses/auto_noe.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/analyses/auto_noe.py?rev=13255&r1=13254&r2=13255&view=diff
==============================================================================
--- branches/gui_testing/gui/analyses/auto_noe.py (original)
+++ branches/gui_testing/gui/analyses/auto_noe.py Tue Jun 28 12:28:06 2011
@@ -29,7 +29,7 @@
 from os.path import dirname
 from string import replace
 import sys
-import thread
+from threading import Thread
 import time
 import wx
 
@@ -302,20 +302,209 @@
 
         # Start the thread (if not debugging).
         if status.debug:
-            self.execute_thread(data)
+            self.thread = Execute(self.gui, data)
         else:
-            id = thread.start_new_thread(self.execute_thread, (data,))
+            self.thread = Execute_thread(self.gui, data)
+            self.thread.start()
 
         # Terminate the event.
         event.Skip()
 
 
-    def execute_thread(self, data):
-        """Execute the calculation in a thread.
-
+    def load_sequence(self, event):
+        """The sequence loading GUI element.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Select the file.
+        file = load_sequence()
+
+        # Nothing selected.
+        if file == None:
+            return
+
+        # Store the file.
+        self.field_sequence.SetValue(str_to_gui(file))
+
+        # Terminate the event.
+        event.Skip()
+
+
+    def ref_file(self, event):
+        """The results directory selection.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Store the original directory.
+        backup = gui_to_str(self.field_ref_noe.GetValue())
+
+        # The directory.
+        directory = None
+        if backup != None:
+            directory = dirname(backup)
+
+        # Select the file.
+        self.data.ref_file = openfile('Select reference NOE peak list', 
directory=directory, default = 'all files (*.*)|*')
+
+        # Restore the backup file if no file was chosen.
+        if not self.data.ref_file:
+            self.data.ref_file = backup
+
+        # Place the path in the text box.
+        self.field_ref_noe.SetValue(self.data.ref_file)
+
+        # Terminate the event.
+        event.Skip()
+
+
+    def results_directory(self, event):
+        """The results directory selection.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Store the original directory.
+        backup = self.field_results_dir.GetValue()
+
+        # Select the file.
+        self.data.save_dir = opendir('Select results directory', 
default=self.field_results_dir.GetValue())
+
+        # Restore the backup file if no file was chosen.
+        if not self.data.save_dir:
+            self.data.save_dir = backup
+
+        # Place the path in the text box.
+        self.field_results_dir.SetValue(self.data.save_dir)
+
+        # Terminate the event.
+        event.Skip()
+
+
+    def sat_file(self, event):
+        """The results directory selection.
+
+        @param event:   The wx event.
+        @type event:    wx event
+        """
+
+        # Store the original directory.
+        backup = gui_to_str(self.field_sat_noe.GetValue())
+
+        # The directory.
+        directory = None
+        if backup != None:
+            directory = dirname(backup)
+
+        # Select the file.
+        self.data.sat_file = openfile('Select saturated NOE peak list', 
directory=directory, default = 'all files (*.*)|*')
+
+        # Restore the backup file if no file was chosen.
+        if not self.data.sat_file:
+            self.data.sat_file = backup
+
+        # Place the path in the text box.
+        self.field_sat_noe.SetValue(self.data.sat_file)
+
+        # Terminate the event.
+        event.Skip()
+
+
+    def sync_ds(self, upload=False):
+        """Synchronise the noe analysis frame and the relax data store, both 
ways.
+
+        This method allows the frame information to be uploaded into the 
relax data store, or for the information in the relax data store to be 
downloaded by the frame.
+
+        @keyword upload:    A flag which if True will cause the frame to 
send data to the relax data store.  If False, data will be downloaded from 
the relax data store to update the frame.
+        @type upload:       bool
+        """
+
+        # The frequency.
+        if upload:
+            self.data.frq = gui_to_str(self.field_nmr_frq.GetValue())
+        else:
+            self.field_nmr_frq.SetValue(str_to_gui(self.data.frq))
+
+        # The results directory.
+        if upload:
+            self.data.save_dir = 
gui_to_str(self.field_results_dir.GetValue())
+        else:
+            self.field_results_dir.SetValue(str_to_gui(self.data.save_dir))
+
+        # The sequence file.
+        if upload:
+            file = gui_to_str(self.field_sequence.GetValue())
+            if file != self.gui.sequence_file_msg:
+                self.data.sequence_file = 
gui_to_str(self.field_sequence.GetValue())
+        elif hasattr(self.data, 'sequence_file'):
+            self.field_sequence.SetValue(str_to_gui(self.data.sequence_file))
+
+        # The structure file.
+        if upload:
+            file = gui_to_str(self.field_structure.GetValue())
+            if file != self.gui.structure_file_pdb_msg:
+                self.data.structure_file = 
gui_to_str(self.field_structure.GetValue())
+        elif hasattr(self.data, 'structure_file'):
+            
self.field_structure.SetValue(str_to_gui(self.data.structure_file))
+
+        # Unresolved residues.
+        if upload:
+            self.data.unresolved = 
gui_to_str(self.field_unresolved.GetValue())
+        elif hasattr(self.data, 'unresolved'):
+            self.field_unresolved.SetValue(str_to_gui(self.data.unresolved))
+
+        # Reference peak file.
+        if upload:
+            self.data.ref_file = gui_to_str(self.field_ref_noe.GetValue())
+        elif hasattr(self.data, 'ref_file'):
+            self.field_ref_noe.SetValue(str_to_gui(self.data.ref_file))
+
+        # Reference rmsd.
+        if upload:
+            self.data.ref_rmsd = gui_to_str(self.field_ref_rmsd.GetValue())
+        elif hasattr(self.data, 'ref_rmsd'):
+            self.field_ref_rmsd.SetValue(str_to_gui(self.data.ref_rmsd))
+
+        # Saturated peak file.
+        if upload:
+            self.data.sat_file = gui_to_str(self.field_sat_noe.GetValue())
+        elif hasattr(self.data, 'sat_file'):
+            self.field_sat_noe.SetValue(str_to_gui(self.data.sat_file))
+
+        # Saturated rmsd.
+        if upload:
+            self.data.sat_rmsd = gui_to_str(self.field_sat_rmsd.GetValue())
+        elif hasattr(self.data, 'sat_rmsd'):
+            self.field_sat_rmsd.SetValue(str_to_gui(self.data.sat_rmsd))
+
+
+
+class Execute:
+    """The NOE analysis execution object."""
+
+    def __init__(self, gui, data):
+        """Set up the NOE analysis execution object.
+
+        @param gui:     The GUI object.
+        @type gui:      wx object
         @param data:    The data container with all data for the analysis.
         @type data:     class instance
         """
+
+        # Store the args.
+        self.gui = gui
+        self.data = data
+
+        # Execute.
+        self.run()
+
+
+    def run(self):
+        """Execute the calculation."""
 
         # Controller.
         if not status.debug:
@@ -331,194 +520,44 @@
             time.sleep(0.5)
 
         # Execute.
-        NOE_calc(seq_args=data.seq_args, pipe_name=data.pipe_name, 
noe_ref=data.ref_file, noe_ref_rmsd=data.ref_rmsd, noe_sat=data.sat_file, 
noe_sat_rmsd=data.sat_rmsd, unresolved=data.unresolved, 
pdb_file=data.structure_file, output_file=data.filename, 
results_dir=data.save_dir, int_method='height', heteronuc=data.heteronuc, 
proton=data.proton, heteronuc_pdb='@N')
+        NOE_calc(seq_args=self.data.seq_args, pipe_name=self.data.pipe_name, 
noe_ref=self.data.ref_file, noe_ref_rmsd=self.data.ref_rmsd, 
noe_sat=self.data.sat_file, noe_sat_rmsd=self.data.sat_rmsd, 
unresolved=self.data.unresolved, pdb_file=self.data.structure_file, 
output_file=self.data.filename, results_dir=self.data.save_dir, 
int_method='height', heteronuc=self.data.heteronuc, proton=self.data.proton, 
heteronuc_pdb='@N')
 
         # Feedback about success.
         if not status.debug:
             wx.CallAfter(self.gui.controller.log_panel.AppendText, 
'\n\n__________________________________________________________\n\nSuccessfully
 calculated NOE 
values\n__________________________________________________________')
 
         # Add noe grace plot to results list.
-        self.gui.list_noe.Append(data.save_dir+sep+'grace'+sep+'noe.agr')
+        
self.gui.list_noe.Append(self.data.save_dir+sep+'grace'+sep+'noe.agr')
 
         # Add noe grace plot to relax data store.
-        
ds.relax_gui.results_noe.append(data.save_dir+sep+'grace'+sep+'noe.agr')
+        
ds.relax_gui.results_noe.append(self.data.save_dir+sep+'grace'+sep+'noe.agr')
 
         # Create color coded structure pymol macro.
-        color_code_noe(self, data.save_dir, data.structure_file)
+        color_code_noe(self.data.save_dir, self.data.structure_file)
 
         # add macro to results tab
-        self.gui.list_noe.Append(data.save_dir+sep+'noe.pml')
+        self.gui.list_noe.Append(self.data.save_dir+sep+'noe.pml')
 
         # Add noe macro to relax data store.
-        ds.relax_gui.results_noe.append(data.save_dir+sep+'noe.pml')
-
-
-    def load_sequence(self, event):
-        """The sequence loading GUI element.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Select the file.
-        file = load_sequence()
-
-        # Nothing selected.
-        if file == None:
-            return
-
-        # Store the file.
-        self.field_sequence.SetValue(str_to_gui(file))
-
-        # Terminate the event.
-        event.Skip()
-
-
-    def ref_file(self, event):
-        """The results directory selection.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Store the original directory.
-        backup = gui_to_str(self.field_ref_noe.GetValue())
-
-        # The directory.
-        directory = None
-        if backup != None:
-            directory = dirname(backup)
-
-        # Select the file.
-        self.data.ref_file = openfile('Select reference NOE peak list', 
directory=directory, default = 'all files (*.*)|*')
-
-        # Restore the backup file if no file was chosen.
-        if not self.data.ref_file:
-            self.data.ref_file = backup
-
-        # Place the path in the text box.
-        self.field_ref_noe.SetValue(self.data.ref_file)
-
-        # Terminate the event.
-        event.Skip()
-
-
-    def results_directory(self, event):
-        """The results directory selection.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Store the original directory.
-        backup = self.field_results_dir.GetValue()
-
-        # Select the file.
-        self.data.save_dir = opendir('Select results directory', 
default=self.field_results_dir.GetValue())
-
-        # Restore the backup file if no file was chosen.
-        if not self.data.save_dir:
-            self.data.save_dir = backup
-
-        # Place the path in the text box.
-        self.field_results_dir.SetValue(self.data.save_dir)
-
-        # Terminate the event.
-        event.Skip()
-
-
-    def sat_file(self, event):
-        """The results directory selection.
-
-        @param event:   The wx event.
-        @type event:    wx event
-        """
-
-        # Store the original directory.
-        backup = gui_to_str(self.field_sat_noe.GetValue())
-
-        # The directory.
-        directory = None
-        if backup != None:
-            directory = dirname(backup)
-
-        # Select the file.
-        self.data.sat_file = openfile('Select saturated NOE peak list', 
directory=directory, default = 'all files (*.*)|*')
-
-        # Restore the backup file if no file was chosen.
-        if not self.data.sat_file:
-            self.data.sat_file = backup
-
-        # Place the path in the text box.
-        self.field_sat_noe.SetValue(self.data.sat_file)
-
-        # Terminate the event.
-        event.Skip()
-
-
-    def sync_ds(self, upload=False):
-        """Synchronise the noe analysis frame and the relax data store, both 
ways.
-
-        This method allows the frame information to be uploaded into the 
relax data store, or for the information in the relax data store to be 
downloaded by the frame.
-
-        @keyword upload:    A flag which if True will cause the frame to 
send data to the relax data store.  If False, data will be downloaded from 
the relax data store to update the frame.
-        @type upload:       bool
-        """
-
-        # The frequency.
-        if upload:
-            self.data.frq = gui_to_str(self.field_nmr_frq.GetValue())
-        else:
-            self.field_nmr_frq.SetValue(str_to_gui(self.data.frq))
-
-        # The results directory.
-        if upload:
-            self.data.save_dir = 
gui_to_str(self.field_results_dir.GetValue())
-        else:
-            self.field_results_dir.SetValue(str_to_gui(self.data.save_dir))
-
-        # The sequence file.
-        if upload:
-            file = gui_to_str(self.field_sequence.GetValue())
-            if file != self.gui.sequence_file_msg:
-                self.data.sequence_file = 
gui_to_str(self.field_sequence.GetValue())
-        elif hasattr(self.data, 'sequence_file'):
-            self.field_sequence.SetValue(str_to_gui(self.data.sequence_file))
-
-        # The structure file.
-        if upload:
-            file = gui_to_str(self.field_structure.GetValue())
-            if file != self.gui.structure_file_pdb_msg:
-                self.data.structure_file = 
gui_to_str(self.field_structure.GetValue())
-        elif hasattr(self.data, 'structure_file'):
-            
self.field_structure.SetValue(str_to_gui(self.data.structure_file))
-
-        # Unresolved residues.
-        if upload:
-            self.data.unresolved = 
gui_to_str(self.field_unresolved.GetValue())
-        elif hasattr(self.data, 'unresolved'):
-            self.field_unresolved.SetValue(str_to_gui(self.data.unresolved))
-
-        # Reference peak file.
-        if upload:
-            self.data.ref_file = gui_to_str(self.field_ref_noe.GetValue())
-        elif hasattr(self.data, 'ref_file'):
-            self.field_ref_noe.SetValue(str_to_gui(self.data.ref_file))
-
-        # Reference rmsd.
-        if upload:
-            self.data.ref_rmsd = gui_to_str(self.field_ref_rmsd.GetValue())
-        elif hasattr(self.data, 'ref_rmsd'):
-            self.field_ref_rmsd.SetValue(str_to_gui(self.data.ref_rmsd))
-
-        # Saturated peak file.
-        if upload:
-            self.data.sat_file = gui_to_str(self.field_sat_noe.GetValue())
-        elif hasattr(self.data, 'sat_file'):
-            self.field_sat_noe.SetValue(str_to_gui(self.data.sat_file))
-
-        # Saturated rmsd.
-        if upload:
-            self.data.sat_rmsd = gui_to_str(self.field_sat_rmsd.GetValue())
-        elif hasattr(self.data, 'sat_rmsd'):
-            self.field_sat_rmsd.SetValue(str_to_gui(self.data.sat_rmsd))
+        ds.relax_gui.results_noe.append(self.data.save_dir+sep+'noe.pml')
+
+
+
+class Execute_thread(Execute, Thread):
+    """The NOE analysis thread execution object."""
+
+    def __init__(self, gui, data):
+        """Set up the NOE analysis thread execution object.
+
+        @param gui:     The GUI object.
+        @type gui:      wx object
+        @param data:    The data container with all data for the analysis.
+        @type data:     class instance
+        """
+
+        # Store the args.
+        self.gui = gui
+        self.data = data
+
+        # Set up the thread object.
+        Thread.__init__(self)




Related Messages


Powered by MHonArc, Updated Tue Jun 28 12:40:03 2011