Flashpoint avatar Flashpoint committed 157e69d

The opened files are now directly imported as custom genesets in OWCustomSets.py

Comments (0)

Files changed (1)

_bioinformatics/widgets/prototypes/OWCustomSets.py

 
 
 class OWCustomSets(OWWidget):
-    settingsList = ["recent_files"]
 
     def __init__(self, parent=None, signalManager=None,
                  title="Custom Geneset File (*.gmt) Manager"):
         self.inputs = []
         self.outputs = []
         self.new_geneset = set()
+        self.selected_file = "" 
 
         # List of recent opened files.
         self.recent_files = []
         self.loadSettings()
-        try:
-            self.recent_files = filter(os.path.exists, self.recent_files)
-        except:
-            pass
-
+        self.recent_files = filter(os.path.exists, self.recent_files)
 
         layout = QHBoxLayout()
         box = OWGUI.widgetBox(self.controlArea, "File", orientation=layout)
         self.preview_view.setWordWrapMode(0)
 
         box.layout().addWidget(self.preview_view)
-
-        
+       
         # The geneset table
         ma = self.mainArea
 
 
         self.populate_table()
 
-        
-        self.selected_file = None 
-
-        self.resize(450, 500)
+        self.resize(800, 500)
         if self.recent_files:
             QTimer.singleShot(1,
                     lambda: self.set_selected_file(self.recent_files[0])
 
         info_box.layout().addWidget(self.info)       
         
-        OWGUI.button(self.controlArea, self, "Import", callback=self.import_data)
         OWGUI.button(self.controlArea, self, "Delete", callback=self.delete_data)
 
     def selection(self): 
         if path:
             self.set_selected_file(path)
 
-    def on_reload_file(self):
-        if self.recent_files:
-            self.set_selected_file(self.recent_files[0])
-
     def set_selected_file(self, filename):
         basedir, name = os.path.split(filename)
         self.selected_file = filename
         if index_to_remove is not None:
             self.recent_combo.removeItem(index_to_remove + 1)
             self.recent_files.pop(index_to_remove + 1)
-        
+            
+        self.import_data()
+                                                                    
     def update_preview(self):
         if self.listView.selectedItems():
             final_text = ""
                     sets = pickle.load(open(the_file, "rb"))
                     break
             for geneset in sets:
-                final_text += geneset.id + "(%d genes)\n" % len(geneset.genes)
+                final_text += geneset.id + " (%d genes)\n" % len(geneset.genes)
                 final_text += ", ".join([geneset.genes.pop() for i in range(5)]) + ", ...\n\n"
             final_text += "..."
             self.preview_view.setPlainText(final_text)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.