Пример #1
0
	def refreshJobs(self, button_refresh=None, data=None, update_job_info=None):
		"""
		2009-11-10
			split out of on_button_refresh_clicked()
		"""
		if self.backend_ins is None:
			sys.stderr.write("Backend is not selected yet! Select one.\n")
			return False	# 2009-11-10 to stop the timeout
		
		update_node_info = self.checkbutton_update_node_info.get_active()
		if update_job_info is None:	#if it's none, get it from the checkbutton
			update_job_info = self.checkbutton_update_job_info.get_active()
		username = self.entry_username.get_text()
		jobs_since = self.entry_jobs_since.get_text()
		jobs_since = datetime.strptime(jobs_since, '%Y-%m-%d %H:%M')
		only_running = self.checkbutton_running.get_active()
		"""
		real_node_range = self.parse_node_range(self.entry_node_range.get_text())
		node2ps = self.node_process_instance.get_processes(real_node_range, self.ps_command, username, self.tmp_fname)
		
		if node2ps=={}:
			sys.stderr.write("No process data fetched.\n")
			return
		
		if self.no_of_refreshes == 0:
			#extra work is needed in the first refresh
			self.create_columns(node2ps.values()[0].label_list)
		self.liststore = gtk.ListStore(str, str, str, str, str, str, str, str, str)	#nine columns
		
		for node in node2ps:
			for ps_output in node2ps[node].ps_output_list:
				if len(ps_output)==8:	#cmd is not null
					self.liststore.append([node]+ps_output)
		"""
		yh_gnome.create_columns(self.treeview1, self.backend_ins.display_job_label_ls)
		self.liststore = gtk.ListStore(*self.backend_ins.display_job_label_type_ls)
		list_2d = self.backend_ins.refresh(username, update_node_info, jobs_since, only_running, \
										update_job_info=update_job_info)
		yh_gnome.fill_treeview(self.treeview1, self.liststore, list_2d, reorderable=True, multi_selection=True)
		"""
		# set the TreeView mode to be liststore
		self.treeview1.set_model(self.liststore)

		
		for i in range(len(ps_output)+1):
			# make it searchable
			self.treeview1.set_search_column(i)
			
		# Allow drag and drop reordering of rows
		self.treeview1.set_reorderable(True)
		#setting the selection mode
		self.treeselection.set_mode(gtk.SELECTION_MULTIPLE)
		"""
		self.no_of_refreshes += 1
		return True	#2009-11-10 return True in order for the timeout to continue
Пример #2
0
    def canvas_diff_matrix_item_event(self, widget, event=None):
        """
		2009-5-19
			when an entry in the canvas of diff matrix is selected, fill up the treeview_diff_details with details (which accession, which SNP etc.)
		"""
        if event.type == gtk.gdk.BUTTON_PRESS:
            if event.button == 1:
                previous_selected_item = self.canvas_diff_matrix.get_data(
                    'item_selected')
                if previous_selected_item != None:
                    previous_selected_item.set(
                        fill_color='black'
                    )  #change the previous selected widget color back to black
                widget.set(fill_color='red'
                           )  #change the current selected widget color to red
                self.canvas_diff_matrix.set_data(
                    'item_selected',
                    widget)  #remember the current selected widget
                widget_name = widget.get_data('name')
                self.app1_appbar1.push(widget_name)

                yh_gnome.create_columns(
                    self.treeview_diff_details,
                    ["row-id1", "col-id1", "nt1", "row-id2", "col-id2", "nt2"])
                liststore_diff_details = gtk.ListStore(str, str, str, str, str,
                                                       str)

                diff_code_pair = widget.get_data('diff_code_pair')
                diff_details_ls = self.diff_code_pair2diff_details_ls.get(
                    diff_code_pair)
                if diff_details_ls is None:
                    diff_details_ls = []

                list_2d = []
                for row in diff_details_ls:
                    list_2d.append(row)

                yh_gnome.fill_treeview(self.treeview_diff_details,
                                       liststore_diff_details,
                                       list_2d,
                                       reorderable=True)

                return True
        elif event.type == gtk.gdk.ENTER_NOTIFY:
            # Make the outline heavy
            widget.set_data('original_weight', widget.get_property('weight'))
            widget.set(weight=1200)
            return True
        elif event.type == gtk.gdk.LEAVE_NOTIFY:
            # Make the outline light
            original_weight = widget.get_data('original_weight')
            widget.set(weight=original_weight)
            return True
        return False
Пример #3
0
	def displayQueueWindow(self):
		"""
		2010-5-25
			display the node_queue_app
			split out of on_menuitem_show_node_q_window_activate() to avoid looping.
		"""
		if self.backend_ins is None:
			sys.stderr.write("Backend is not selected yet! Select one.\n")
			return False	# 2009-11-10 to stop the timeout
		
		yh_gnome.create_columns(self.treeview_node_queue, self.backend_ins.display_node_label_ls)
		self.liststore_node_queue = gtk.ListStore(*self.backend_ins.display_node_label_type_ls)
		list_2d = self.backend_ins.returnQueueNodeInfo()
		yh_gnome.fill_treeview(self.treeview_node_queue, self.liststore_node_queue, list_2d, reorderable=True, multi_selection=True)
		self.node_queue_app.show_all()
Пример #4
0
	def show_nodes_of_this_job(self, widget, event=None, data=None):
		"""
		2008-11-06
			fill in the treeview_nodes
			execute upon clicking the 'show nodes' in the popup menu
		"""
		if self.backend_ins is None:
			sys.stderr.write("Backend is not selected yet! Select one.\n")
			return
		
		yh_gnome.create_columns(self.treeview_nodes, self.backend_ins.display_node_label_ls)
		self.liststore_nodes = gtk.ListStore(*self.backend_ins.display_node_label_type_ls)
		job_id_ls = self.get_selected_job_id_ls()
		list_2d = self.backend_ins.returnNodeInfoGivenJobs(job_id_ls)
		yh_gnome.fill_treeview(self.treeview_nodes, self.liststore_nodes, list_2d, reorderable=True, multi_selection=True)
Пример #5
0
	def canvas_diff_matrix_item_event(self, widget, event=None):
		"""
		2009-5-19
			when an entry in the canvas of diff matrix is selected, fill up the treeview_diff_details with details (which accession, which SNP etc.)
		"""
		if event.type == gtk.gdk.BUTTON_PRESS:
			if event.button == 1:
				previous_selected_item = self.canvas_diff_matrix.get_data('item_selected')
				if previous_selected_item != None:
					previous_selected_item.set(fill_color='black')	#change the previous selected widget color back to black
				widget.set(fill_color='red')	#change the current selected widget color to red
				self.canvas_diff_matrix.set_data('item_selected', widget)	#remember the current selected widget
				widget_name = widget.get_data('name')
			 	self.app1_appbar1.push(widget_name)
			 	
			 	yh_gnome.create_columns(self.treeview_diff_details, ["row-id1", "col-id1", "nt1", "row-id2", "col-id2", "nt2"])
				liststore_diff_details = gtk.ListStore(str, str, str, str, str, str)
				
				diff_code_pair = widget.get_data('diff_code_pair')
				diff_details_ls = self.diff_code_pair2diff_details_ls.get(diff_code_pair)
				if diff_details_ls is None:
					diff_details_ls = []
				
				list_2d = []
				for row in diff_details_ls:
					list_2d.append(row)
				
				yh_gnome.fill_treeview(self.treeview_diff_details, liststore_diff_details, list_2d, reorderable=True)
				
				return True
		elif event.type == gtk.gdk.ENTER_NOTIFY:
			# Make the outline heavy
			widget.set_data('original_weight', widget.get_property('weight'))
			widget.set(weight=1200)
			return True
		elif event.type == gtk.gdk.LEAVE_NOTIFY:
			# Make the outline light
			original_weight = widget.get_data('original_weight')
			widget.set(weight=original_weight)
			return True
		return False
Пример #6
0
	def on_button_input_run_clicked(self, widget, event=None, data=None):
		"""
		2009-5-18
			add one more column: row category from dataset1
		2008-02-06
			fix a bug. self.class_chosen could be 0
		"""
		if self.class_chosen!=None:
			self.hostname = self.entry_hostname.get_text()
			self.dbname = self.entry_dbname.get_text()
			self.schema = self.entry_schema.get_text()
			import MySQLdb
			self.conn = MySQLdb.connect(db=self.dbname,host=self.hostname)
			self.curs = self.conn.cursor()
			self.input_fname1 = os.path.expanduser(self.entry_1st_input_fname.get_text())
			self.input_fname2 = os.path.expanduser(self.entry_2nd_input_fname.get_text())
			self.ecotype_table = self.entry_ecotype_table.get_text()
			self.ecotype2accession_table = self.entry_ecotype2accession_table.get_text()
			self.diff_details_table = self.entry_diff_details_table.get_text()
			self.qc_cross_match_table = self.entry_qc_cross_match_table.get_text()
			self.latex_output_fname = os.path.expanduser(self.entry_latex_output_fname.get_text())
			if self.qc_class_ins!=None:
				del self.qc_class_ins	#release memory (maybe it works by 'del')
				self.qc_class_ins = None
			if self.class_chosen == 2:
				self.qc_class_ins = self.qc_class_dict[self.class_chosen](self.curs, self.input_fname1, self.input_fname2, \
																		self.latex_output_fname, self.ecotype2accession_table, \
																		self.diff_details_table, self.qc_cross_match_table)
			elif self.class_chosen==0:
				self.qc_class_ins = self.qc_class_dict[self.class_chosen](curs=self.curs, input_fname1=self.input_fname1, input_fname2=self.input_fname2)
			else:
				self.qc_class_ins = self.qc_class_dict[self.class_chosen](self.curs, self.input_fname1, self.input_fname2)
			self.qc_class_ins.load_dstruc()
			
			if self.qc_class_ins.header1[0]:
				dataset1_row_id = self.qc_class_ins.header1[0]
			else:
				dataset1_row_id = 'dataset1 row id'
			if self.qc_class_ins.header1[1]:
				dataset1_row_category = self.qc_class_ins.header1[1]
			else:
				dataset1_row_category = 'dataset1 row category'
			if self.qc_class_ins.header2[0]:
				dataset2_row_id = self.qc_class_ins.header2[0]
			else:
				dataset2_row_id = 'dataset2 row id'
			if self.qc_class_ins.header2[1]:
				dataset2_row_category = self.qc_class_ins.header2[1]
			else:
				dataset2_row_category = 'dataset2 row category'
			
			yh_gnome.create_columns(self.treeview_strains1, ['Index', dataset1_row_id, dataset1_row_category, dataset2_row_id, dataset2_row_category])
			self.strain_index2row_id1 = {}
			self.liststore_strains1 = gtk.ListStore(int, str, str, str, str)
			strain_acc_list1_2d = [[0, 'ALL', '', '', '']]
			self.strain_index2row_id1[0] = 'ALL'
			
			row_id22category = {}	#row_id2 's category offers some info on row_id2
			for row_id2, row_index2 in self.qc_class_ins.row_id2row_index2.iteritems():
				row_id22category[row_id2] = self.qc_class_ins.category_list2[row_index2]
			
			row_id12category = {}
			for row_id1, row_index1 in self.qc_class_ins.row_id2row_index1.iteritems():
				row_id12category[row_id1] = self.qc_class_ins.category_list1[row_index1]
			
			strain_index = len(self.strain_index2row_id1) #starting from 1
			for row_id1, row_id2 in self.qc_class_ins.row_id12row_id2.iteritems():
				if row_id2 in row_id22category:
					row_id2_category = row_id22category[row_id2]
				else:
					row_id2_category = ''
				if row_id1 in row_id12category:
					row_id1_category = row_id12category[row_id1]
				else:
					row_id1_category = ''
				
				strain_acc_list1_2d.append([strain_index, repr(row_id1), repr(row_id1_category), repr(row_id2), row_id2_category])
				self.strain_index2row_id1[strain_index] = row_id1
				strain_index += 1
			
			yh_gnome.fill_treeview(self.treeview_strains1, self.liststore_strains1, strain_acc_list1_2d, reorderable=True)
			
			"""
			#2008-01-24
			yh_gnome.create_columns(self.treeview_strains2, [self.qc_class_ins.header2[0], self.qc_class_ins.header2[1]])
			self.liststore_strains2 = gtk.ListStore(str, str)
			strain_acc_list2_2d = [['ALL', '']]
			for i in range(len(self.qc_class_ins.strain_acc_list2)):
				strain_acc_list2_2d.append([self.qc_class_ins.strain_acc_list2[i], self.qc_class_ins.category_list2[i]])
			yh_gnome.fill_treeview(self.treeview_strains2, self.liststore_strains2, strain_acc_list2_2d, reorderable=True)
			"""
			self.app_input_appbar.push("Check the other window for available strains.")
			self.app1.show_all()
		else:
			self.app_input_appbar.push("Error: Can't Run cuz No Class Chosen!")
Пример #7
0
    def on_button_input_run_clicked(self, widget, event=None, data=None):
        """
		2009-5-18
			add one more column: row category from dataset1
		2008-02-06
			fix a bug. self.class_chosen could be 0
		"""
        if self.class_chosen != None:
            self.hostname = self.entry_hostname.get_text()
            self.dbname = self.entry_dbname.get_text()
            self.schema = self.entry_schema.get_text()
            import MySQLdb
            self.conn = MySQLdb.connect(db=self.dbname, host=self.hostname)
            self.curs = self.conn.cursor()
            self.input_fname1 = os.path.expanduser(
                self.entry_1st_input_fname.get_text())
            self.input_fname2 = os.path.expanduser(
                self.entry_2nd_input_fname.get_text())
            self.ecotype_table = self.entry_ecotype_table.get_text()
            self.ecotype2accession_table = self.entry_ecotype2accession_table.get_text(
            )
            self.diff_details_table = self.entry_diff_details_table.get_text()
            self.qc_cross_match_table = self.entry_qc_cross_match_table.get_text(
            )
            self.latex_output_fname = os.path.expanduser(
                self.entry_latex_output_fname.get_text())
            if self.qc_class_ins != None:
                del self.qc_class_ins  #release memory (maybe it works by 'del')
                self.qc_class_ins = None
            if self.class_chosen == 2:
                self.qc_class_ins = self.qc_class_dict[self.class_chosen](self.curs, self.input_fname1, self.input_fname2, \
                              self.latex_output_fname, self.ecotype2accession_table, \
                              self.diff_details_table, self.qc_cross_match_table)
            elif self.class_chosen == 0:
                self.qc_class_ins = self.qc_class_dict[self.class_chosen](
                    curs=self.curs,
                    input_fname1=self.input_fname1,
                    input_fname2=self.input_fname2)
            else:
                self.qc_class_ins = self.qc_class_dict[self.class_chosen](
                    self.curs, self.input_fname1, self.input_fname2)
            self.qc_class_ins.load_dstruc()

            if self.qc_class_ins.header1[0]:
                dataset1_row_id = self.qc_class_ins.header1[0]
            else:
                dataset1_row_id = 'dataset1 row id'
            if self.qc_class_ins.header1[1]:
                dataset1_row_category = self.qc_class_ins.header1[1]
            else:
                dataset1_row_category = 'dataset1 row category'
            if self.qc_class_ins.header2[0]:
                dataset2_row_id = self.qc_class_ins.header2[0]
            else:
                dataset2_row_id = 'dataset2 row id'
            if self.qc_class_ins.header2[1]:
                dataset2_row_category = self.qc_class_ins.header2[1]
            else:
                dataset2_row_category = 'dataset2 row category'

            yh_gnome.create_columns(self.treeview_strains1, [
                'Index', dataset1_row_id, dataset1_row_category,
                dataset2_row_id, dataset2_row_category
            ])
            self.strain_index2row_id1 = {}
            self.liststore_strains1 = gtk.ListStore(int, str, str, str, str)
            strain_acc_list1_2d = [[0, 'ALL', '', '', '']]
            self.strain_index2row_id1[0] = 'ALL'

            row_id22category = {
            }  #row_id2 's category offers some info on row_id2
            for row_id2, row_index2 in self.qc_class_ins.row_id2row_index2.iteritems(
            ):
                row_id22category[row_id2] = self.qc_class_ins.category_list2[
                    row_index2]

            row_id12category = {}
            for row_id1, row_index1 in self.qc_class_ins.row_id2row_index1.iteritems(
            ):
                row_id12category[row_id1] = self.qc_class_ins.category_list1[
                    row_index1]

            strain_index = len(self.strain_index2row_id1)  #starting from 1
            for row_id1, row_id2 in self.qc_class_ins.row_id12row_id2.iteritems(
            ):
                if row_id2 in row_id22category:
                    row_id2_category = row_id22category[row_id2]
                else:
                    row_id2_category = ''
                if row_id1 in row_id12category:
                    row_id1_category = row_id12category[row_id1]
                else:
                    row_id1_category = ''

                strain_acc_list1_2d.append([
                    strain_index,
                    repr(row_id1),
                    repr(row_id1_category),
                    repr(row_id2), row_id2_category
                ])
                self.strain_index2row_id1[strain_index] = row_id1
                strain_index += 1

            yh_gnome.fill_treeview(self.treeview_strains1,
                                   self.liststore_strains1,
                                   strain_acc_list1_2d,
                                   reorderable=True)
            """
			#2008-01-24
			yh_gnome.create_columns(self.treeview_strains2, [self.qc_class_ins.header2[0], self.qc_class_ins.header2[1]])
			self.liststore_strains2 = gtk.ListStore(str, str)
			strain_acc_list2_2d = [['ALL', '']]
			for i in range(len(self.qc_class_ins.strain_acc_list2)):
				strain_acc_list2_2d.append([self.qc_class_ins.strain_acc_list2[i], self.qc_class_ins.category_list2[i]])
			yh_gnome.fill_treeview(self.treeview_strains2, self.liststore_strains2, strain_acc_list2_2d, reorderable=True)
			"""
            self.app_input_appbar.push(
                "Check the other window for available strains.")
            self.app1.show_all()
        else:
            self.app_input_appbar.push("Error: Can't Run cuz No Class Chosen!")