def delete_atoms_by_range(self): for_deleting = [] for item in self.selectedItems(): for range_name, range_list in app.ranges_list.items(): if range_name == item.my_range['range_number']: for atom_name in app.ranges_list[range_name]['range']: if atom_name['atomname'] == app.main_window.atom_input: for_deleting.append(atom_name['atomval']) for index, val in enumerate(app.atom_val_list): for point in for_deleting: if point == val: del app.atom_val_list[index] for index, atom in enumerate( app.ranges_list[range_name]['current_atoms']): if atom == app.main_window.atom_input: del app.ranges_list[range_name]['current_atoms'][ index] app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order self.redraw_range_list() app.main_window.selected_residues_list_object.redraw_res_list() app.main_window.graph_object.redraw_graph() app.log_update()
def add_all_atoms_by_range(self): for item in self.selectedItems(): for range_name, range_list in app.ranges_list.items(): if range_name == item.my_range['range_number']: for atom_name in app.ranges_list[range_name]['range']: if not [ point for point in app.atom_val_list if point == atom_name['atomval'] ]: app.atom_val_list.append(atom_name['atomval']) app.atom_val_list = sorted( app.atom_val_list, key=lambda item: atom_name['atomval']) if not [ point for point in app.ranges_list[range_name] ["current_atoms"] if point == atom_name['atomname'] ]: app.ranges_list[range_name][ "current_atoms"].append(atom_name['atomname']) app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order self.redraw_range_list() app.main_window.selected_residues_list_object.redraw_res_list() app.log_update()
def all_button_clicked(self): for item in app.selected_residues: if not [ point for point in app.atom_val_list if point == item['atomval'] ]: app.atom_val_list.append(item['atomval']) app.atom_val_list = sorted(app.atom_val_list, key=lambda item: item) app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order app.main_window.selected_residues_list_object.redraw_res_list() app.main_window.select_ranges_list_object.redraw_range_list() app.log_update()
def all_delete_button_clicked(self): for_deleting = [] for item in app.selected_residues: for_deleting.append(item['atomval']) for index, val in enumerate(app.atom_val_list): for point in for_deleting: if point == val: del app.atom_val_list[index] app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order app.main_window.selected_residues_list_object.redraw_res_list() app.main_window.select_ranges_list_object.redraw_range_list() app.log_update()
def default_button_clicked(self): for atom in app.default_atoms: for item in app.selected_residues: if item["atomname"] == atom: if not [ point for point in app.atom_val_list if point == item['atomval'] ]: app.atom_val_list.append(item['atomval']) app.atom_val_list = sorted(app.atom_val_list, key=lambda item: item) # for range_name, range_list in app.ranges_list.items(): # if range_name == item['resval']: # for atom_name in app.ranges_list[range_name]['range']: # # for atom in app.default_atoms: # if atom_name['atomname'] == atom: # if not [point for point in app.atom_val_list if point == atom_name['atomval']]: # app.atom_val_list.append( atom_name['atomval']) # app.atom_val_list = sorted(app.atom_val_list, key=lambda item: atom_name['atomval']) # if not [point for point in app.ranges_list[range_name]["current_atoms"] if point == atom_name['atomname']]: # app.ranges_list[range_name]["current_atoms"].append(atom_name['atomname']) app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order app.main_window.selected_residues_list_object.redraw_res_list() app.main_window.select_ranges_list_object.redraw_range_list() app.log_update()
def keyPressEvent(self, event): super(SelectedResiduesList, self).keyPressEvent(event) # add desired atoms to app.atom_val_list by pressing 'v' if event.key() == QtCore.Qt.Key_V: for item in self.selectedItems(): item.setTextColor(QtGui.QColor("red")) if not [ point for point in app.atom_val_list if point == item.my_res_atom['atomval'] ]: app.atom_val_list.append(item.my_res_atom['atomval']) app.atom_val_list = sorted(app.atom_val_list, key=lambda item: item) app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order app.main_window.select_ranges_list_object.redraw_range_list() app.log_update() # delete desired atoms from the atom list by pressing 'b' if event.key() == QtCore.Qt.Key_B: for item in self.selectedItems(): item.setTextColor(QtGui.QColor("black")) # update the selected atoms list when deleting for index, atm in enumerate(app.atom_val_list): if (atm == item.my_res_atom['atomval']): del app.atom_val_list[index] app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order app.main_window.select_ranges_list_object.redraw_range_list() app.log_update() # print and save the atom values by pressing 'p' if event.key() == QtCore.Qt.Key_P: print('Saved atom list') app.main_window.reply_log_object.append("Saved atom list") app.saving_and_output() # quit the program by pressing 'q' if event.key() == QtCore.Qt.Key_Q: print('Hamster ran out!') app.qapp.quit() if event.key() == QtCore.Qt.Key_S: app.save_variables() if event.key() == QtCore.Qt.Key_L: app.open_variables()
def keyPressEvent(self, event): super(SelectedRangeList, self).keyPressEvent(event) for_deleting = [] if event.key() == QtCore.Qt.Key_Delete: for item in self.selectedItems(): # update the selected ranges list when deleting for range_name, range_list in app.ranges_list.items(): if range_name == item.my_range['range_number']: for atom_name in app.ranges_list[range_name]['range']: for_deleting.append(atom_name['atomval']) for index, val in enumerate(app.atom_val_list): for point in for_deleting: print(point) if point == val: del app.atom_val_list[index] print(app.atom_val_list) # print(for_deleting) del app.ranges_list[range_name] self.takeItem(self.row(item)) # delete the row visually app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order self.redraw_range_list() app.main_window.graph_object.redraw_graph() app.main_window.selected_residues_list_object.redraw_res_list() app.log_update() # atom numbers printing and saving shortcut if event.key() == QtCore.Qt.Key_P: print('Saved atom list') app.main_window.reply_log_object.append("Saved atom list") app.saving_and_output() # quit the program shortcut if event.key() == QtCore.Qt.Key_Q: print('Hamster ran out!') app.qapp.quit() if event.key() == QtCore.Qt.Key_S: app.save_variables() if event.key() == QtCore.Qt.Key_L: app.open_variables()
def keyPressEvent(self, event): super(SelectedPointsList, self).keyPressEvent(event) for_deleting = [] if event.key() == QtCore.Qt.Key_Delete: for item in self.selectedItems(): # update the selected points list when deleting for index, point in enumerate(app.selected_points): if (point['x'] == item.my_point['x']): del app.selected_points[index] self.takeItem(self.row(item)) # delete the row visually # update list of atoms in the window for index, vals in enumerate(app.selected_residues): # print(vals) if (vals['resval'] == item.my_point['x']): # print(item.my_point['x']) for_deleting.append(app.selected_residues[index]) # print(for_deleting) for index, val in enumerate(app.atom_val_list): for point in for_deleting: if point['atomval'] == val: del app.atom_val_list[index] for point in for_deleting: for index, atoms in enumerate(app.selected_residues): if atoms['atomval'] == point['atomval']: del app.selected_residues[index] # for index, atoms in enumerate(app.selected_residues): # for point in for_deleting: # print(point) # if point['atomval'] == vals['atomval']: # del vals[index] # del app.selected_residues[index] # for index, atom in enumerate(app.atom_val_list): # for point in for_deleting: # if point['atomval'] == atom: # del app.atom_val_list[index] # for index, point in enumerate(app.selected_points): # if( point['x'] == item.my_point['x']): # del app.selected_points[index] # del app.selected_residues[index] # for index, point in enumerate(app.selected_points): # if( point['x'] == item.my_point['x']): # del app.selected_points[index] # temp_res_list = [] # # update the selected residues list when deleting # for index, vals in enumerate(app.selected_residues): # if (vals['resval'] != item.my_point['x']): # temp_res_list.append( app.selected_residues[index] ) # # app.selected_residues = temp_res_list # for index, vals in enumerate(app.selected_residues): # if (vals['resval'] == item.my_point['x']): # for_deleting.append( app.selected_residues[index] ) # # print(for_deleting) # # clear corresponding atoms out of memory # temp_atom_list = [] # for index, atom in enumerate(app.atom_val_list): # for point in for_deleting: # if point['atomval'] == atom: # del app.atom_val_list[index] # for val in app.selected_residues: # if atom == val['atomval']: # temp_atom_list.append(app.atom_val_list[index]) # app.atom_val_list = temp_atom_list app.atom_val_list_out = ( ' '.join(str(e) for e in app.atom_val_list) ) # exclude brackets, keep the list sorted in ascending order app.main_window.graph_object.redraw_graph() app.main_window.selected_residues_list_object.redraw_res_list() app.main_window.select_ranges_list_object.redraw_range_list() app.log_update() # atom numbers printing and saving shortcut if event.key() == QtCore.Qt.Key_P: print('Saved atom list from selction window') app.main_window.reply_log_object.append( "Saved atom list from selection window") app.saving_and_output() # quit the program shortcut if event.key() == QtCore.Qt.Key_Q: print('Hamster ran out!') app.qapp.quit() if event.key() == QtCore.Qt.Key_S: app.save_variables() if event.key() == QtCore.Qt.Key_L: app.open_variables()