mailr11599 - in /branches/bieri_gui/gui_bieri: relax_gui.py settings.py


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

Header


Content

Posted by edward on September 17, 2010 - 11:06:
Author: bugman
Date: Fri Sep 17 11:06:43 2010
New Revision: 11599

URL: http://svn.gna.org/viewcvs/relax?rev=11599&view=rev
Log:
Clean up of the sequence file loading.

The settings.load_sequence() function has been improved and now checks if a 
file is actually
selected.  The relax_gui import_seq() method has also been cleaned up and now 
meets relax's coding
standards.


Modified:
    branches/bieri_gui/gui_bieri/relax_gui.py
    branches/bieri_gui/gui_bieri/settings.py

Modified: branches/bieri_gui/gui_bieri/relax_gui.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/relax_gui.py?rev=11599&r1=11598&r2=11599&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/relax_gui.py (original)
+++ branches/bieri_gui/gui_bieri/relax_gui.py Fri Sep 17 11:06:43 2010
@@ -27,7 +27,7 @@
 # Python module imports.
 import __main__
 import os
-from os import F_OK, access, getcwd, mkdir, sep
+from os import F_OK, access, getcwd, mkdir, path, sep
 import platform
 from re import search
 from string import lower, lowercase, replace
@@ -474,31 +474,40 @@
             self.Destroy()
 
 
-    def import_seq(self, event): # open load sequence panel
-        temp = load_sequence(self)
-        if not temp == None:
-            sequencefile = str(temp) #set sequence file
-
-            # Set entries in pdb text box.
-            structure_file_pdb = '!!! Sequence file selected !!!'
-            # Add file to NOE tabs.
-            
self.analysis_frames[self.hardcoded_index_noe_1].field_structure.SetValue(structure_file_pdb)
-            
self.analysis_frames[self.hardcoded_index_noe_2].field_structure.SetValue(structure_file_pdb)
-            
self.analysis_frames[self.hardcoded_index_noe_3].field_structure.SetValue(structure_file_pdb)
-
-            # Add file to R1 tabs.
-            
self.analysis_frames[self.hardcoded_index_r1_1].field_structure.SetValue(structure_file_pdb)
-            
self.analysis_frames[self.hardcoded_index_r1_2].field_structure.SetValue(structure_file_pdb)
-            
self.analysis_frames[self.hardcoded_index_r1_3].field_structure.SetValue(structure_file_pdb)
-
-            # Add file to R2 tabs.
-            
self.analysis_frames[self.hardcoded_index_r2_1].field_structure.SetValue(structure_file_pdb)
-            
self.analysis_frames[self.hardcoded_index_r2_2].field_structure.SetValue(structure_file_pdb)
-            
self.analysis_frames[self.hardcoded_index_r2_3].field_structure.SetValue(structure_file_pdb)
-
-            # Load sequencefile in relax data storage.
-            for i in range(10):
-             ds.relax_gui.analyses[i].sequence_file = sequencefile
+    def import_seq(self, event):
+        """Open sequence loading GUI element."""
+
+        # The dialog.
+        file = load_sequence(self)
+
+        # Nothing selected.
+        if file == None:
+            return
+
+        # The selected file.
+        sequencefile = str(file)
+
+        # Set entries in pdb text box.
+        structure_file_pdb = '!!! Sequence file selected !!!'
+
+        # Add file to NOE tabs.
+        
self.analysis_frames[self.hardcoded_index_noe_1].field_structure.SetValue(structure_file_pdb)
+        
self.analysis_frames[self.hardcoded_index_noe_2].field_structure.SetValue(structure_file_pdb)
+        
self.analysis_frames[self.hardcoded_index_noe_3].field_structure.SetValue(structure_file_pdb)
+
+        # Add file to R1 tabs.
+        
self.analysis_frames[self.hardcoded_index_r1_1].field_structure.SetValue(structure_file_pdb)
+        
self.analysis_frames[self.hardcoded_index_r1_2].field_structure.SetValue(structure_file_pdb)
+        
self.analysis_frames[self.hardcoded_index_r1_3].field_structure.SetValue(structure_file_pdb)
+
+        # Add file to R2 tabs.
+        
self.analysis_frames[self.hardcoded_index_r2_1].field_structure.SetValue(structure_file_pdb)
+        
self.analysis_frames[self.hardcoded_index_r2_2].field_structure.SetValue(structure_file_pdb)
+        
self.analysis_frames[self.hardcoded_index_r2_3].field_structure.SetValue(structure_file_pdb)
+
+        # Load sequence file into the relax data store.
+        for i in range(10):
+            ds.relax_gui.analyses[i].sequence_file = sequencefile
 
 
     def init_data(self):

Modified: branches/bieri_gui/gui_bieri/settings.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/gui_bieri/settings.py?rev=11599&r1=11598&r2=11599&view=diff
==============================================================================
--- branches/bieri_gui/gui_bieri/settings.py (original)
+++ branches/bieri_gui/gui_bieri/settings.py Fri Sep 17 11:06:43 2010
@@ -22,12 +22,13 @@
 
###############################################################################
 
 # Python module imports.
-from os import sep
+from os import F_OK, access, path, sep
 import sys
 import wx
 
 # relax GUI module imports.
 from filedialog import openfile
+from message import error_message
 from paths import IMAGE_PATH
 
 
@@ -52,7 +53,22 @@
 
 
 def load_sequence(self):
-    seqfile = openfile('Choose Sequence File', sys.path[-1], '', 'all files 
(*.*)|*.*')
+    """GUI element for loading the sequence file."""
+
+    # The dialog.
+    seqfile = openfile('Choose a sequence file', '', '', 'all files 
(*.*)|*.*')
+
+    # Does not exist.
+    if not access(seqfile, F_OK):
+        error_message("The file '%s' does not exist." % seqfile)
+        return None
+
+    # Not a file.
+    if path.isdir(seqfile):
+        error_message("The selection '%s' is a directory, not a file." % 
seqfile)
+        return None
+
+    # Return the file.
     return seqfile
 
 




Related Messages


Powered by MHonArc, Updated Fri Sep 17 11:20:01 2010