Package Pmv :: Module dashboard
[hide private]
[frames] | no frames]

Source Code for Module Pmv.dashboard

  1  from mglutil.gui.BasicWidgets.Tk.trees.TreeWithButtons import \ 
  2       ColumnDescriptor ,TreeWithButtons, NodeWithButtons 
  3  from MolKit.molecule import MolecularSystem 
  4  import Pmw, Tkinter 
  5   
  6  from MolKit.stringSelector import CompoundStringSelector 
  7   
8 -class MolFragTreeWithButtons(TreeWithButtons):
9 """Each node in the tree has an object associated in the node's .object 10 attribute. The objects are expected to have a .parent and a .children 11 attribute describing the hierarchy.""" 12
13 - def __init__(self, master, root, vf=None, iconsManager=None, 14 idleRedraw=True, nodeHeight=20, **kw):
15 # add a compound selector entry 16 self.vf = vf 17 kw['iconsManager'] = iconsManager 18 kw['idleRedraw'] = idleRedraw 19 kw['nodeHeight'] = nodeHeight 20 TreeWithButtons.__init__( *(self, master, root), **kw ) 21 22 # add selector entry 23 self.selector = CompoundStringSelector() 24 w = self.interior() 25 #self.selectorEntry = Pmw.EntryField( 26 # w, labelpos='w', label_text='Sel.:', 27 # entry_width=12, validate=None, command=self.selectFromString) 28 self.selectorEntry = Pmw.ComboBox( 29 w, labelpos='w', label_text='Sel.:', 30 ##scrolledlist_items = self.vf.sets.keys(), 31 selectioncommand=self.selectFromString) 32 33 cid = self.create_window( 2, 2, window=self.selectorEntry, 34 anchor='nw', width=100, height=25, 35 tags=('ColHeadersWidgets',)) 36 37 self.selectorHelp = """This entry is used to select entities in the Tree via a Pmv compound selector.\nOnly expanded nodes will be selected. Selected nodes are outlined with a\nyellow selection box. When a shape is clicked for a selected node, the\ncommand is applied to all selected nodes. The syntax for a compound selector\nis a ';' separated list of expressions. Each expression is a ':' separated list of\nselectors applying at the various levels of the Tree.\nFor instance: 38 :::CA selects all alpha carbon atoms 39 :A::CA selects all CA in chain A 40 ::CYS* selects all cysteines""" 41 self.balloon.bind(self.selectorEntry, self.selectorHelp) 42 # add backbone only widget 43 self.bbmodevar = Tkinter.StringVar() 44 self.bbmodevar.set("CMD") 45 self.bbmode_menu = Pmw.ComboBox( 46 w, selectioncommand= self.bbmodevar.set, 47 scrolledlist_items = ['CMD', 'BB', 'SC', 'SC+CA', 'ALL'], 48 entryfield_entry_width=4) 49 self.bbmode_menu.selectitem('CMD') 50 self.bbmodeHelp = """This option menu is used to specify whether commands should be applied to the 51 backbone atoms only (BB), the side chain atoms only (SC), the sidechain atoms 52 and CA atoms (SC+CA) or the full molecular fragment (ALL). 53 This setting can be overridden by each column (CMD)""" 54 self.balloon.bind(self.bbmode_menu, self.bbmodeHelp) 55 cid = self.create_window(104, 2, window=self.bbmode_menu, anchor='nw', 56 tags=('ColHeadersWidgets',))
57 58
59 - def addColumnDescriptor(self, columnDescr):
60 vf = columnDescr.vf 61 # load Pmv commands 62 for cmd, module, package in columnDescr.pmvCmdsToLoad: 63 #print 'loading', cmd, module, package 64 vf.browseCommands(module, commands=(cmd,), package='Pmv', log=0) 65 66 # register interest in Pmv commands 67 dashboardCmd = vf.dashboard 68 for cmd in columnDescr.pmvCmdsToHandle: 69 #print 'register', cmd, columnDescr.title 70 vf.cmdsWithOnRun[vf.commands[cmd]] = [dashboardCmd] 71 72 cmd = columnDescr.cmd 73 74 if isinstance(cmd[0], str): 75 columnDescr.cmd = (vf.commands[cmd[0]], cmd[1], {'callListener':False}) 76 #cmd[2]['callListener'] = False # prevents dashboard issues commands 77 # from calling dashboard.onCmdRun 78 if columnDescr.title is None: 79 columnDescr.title = name 80 81 TreeWithButtons.addColumnDescriptor(self, columnDescr)
82 83
84 - def expandParents(self, object):
85 """Expand all parents of the node""" 86 p = object.parent 87 if not self.objectToNode.has_key(p): 88 self.expandParents(p) 89 90 self.objectToNode[p].expand()
91 92
93 - def selectFromString(self, value):
94 #value = self.selectorEntry.getvalue() 95 molFrag = self.selector.select(self.root.object.children, value, 96 sets=self.vf.sets) 97 for obj in molFrag[0]: 98 try: 99 node = self.objectToNode[obj] 100 except KeyError: 101 self.expandParents(obj) 102 node = self.objectToNode[obj] 103 node.select(only=False)
104 105
106 - def rightButtonClick(self, columnDescr, event):
107 columnDescr.bbmodeOptMenu(event)
108 109 110 111 from MolKit.molecule import Atom, AtomSet, Molecule, MoleculeSet 112 from MolKit.protein import Chain, ChainSet, Residue, ResidueSet, Protein, ProteinSet 113
114 -class MolFragNodeWithButtons(NodeWithButtons):
115 116
117 - def deleteMolecule(self, event=None):
118 self.tree().vf.deleteMol(self.object)
119 120
121 - def postMoleculeMenu(self,event):
122 menu = Tkinter.Menu(tearoff=False) 123 menu.add_command(label='delete', command=self.deleteMolecule) 124 menu.add_command(label='dismiss') 125 menu.post(event.x_root, event.y_root)
126 127
128 - def button3OnLabel(self, event=None):
129 obj = self.object 130 if isinstance(obj, MolecularSystem): 131 self.tree().vf.readMolecule.guiCallback() 132 elif isinstance(obj, Protein) or isinstance(obj, Molecule): 133 self.postMoleculeMenu(event)
134 135
136 - def getIcon(self):
137 """return node's icons""" 138 iconsManager = self.tree().iconsManager 139 object = self.object 140 if isinstance(object, Atom): 141 icon = iconsManager.get("atom.png", self.tree().master) 142 elif isinstance(object, Residue): 143 icon = iconsManager.get("residue.png", self.tree().master) 144 elif isinstance(object, Chain): 145 icon = iconsManager.get("chain.png", self.tree().master) 146 elif isinstance(object, Molecule): 147 icon = iconsManager.get("ms.png", self.tree().master) 148 else: 149 icon = None 150 151 if icon: 152 self.iconWidth = icon.width() 153 else: 154 self.iconWidth = 0 155 return icon
156 157
158 - def getNodes(self, column):
159 tree = self.tree() 160 # return the objects associated with this node 161 # handle the backbone, sidechain and both value for the command 162 result = molFrag = self.object 163 if isinstance(result, MolecularSystem): 164 result = result.children 165 166 bbmode = tree.bbmodevar.get() 167 168 if bbmode=='CMD': 169 #print 'Cmd setting found' 170 bbmode = tree.columns[column].bbmode 171 172 #print 'bbmode in getNode', column, bbmode 173 if bbmode!='ALL': 174 if result.findType(Chain)[0].isProteic(): 175 atoms = result.findType(Atom) 176 if bbmode=='BB': 177 result = atoms.get('backbone') 178 elif bbmode=='SC+CA': 179 result = atoms.get('sidechain')+atoms.get('CA') 180 else: 181 result = atoms.get('sidechain') 182 try: 183 return result.setClass([result]) 184 except KeyError: 185 return result 186 187 if hasattr(result,'setClass') and result.setClass: 188 return result.setClass([result]) 189 else: 190 return result
191 192
193 - def getObjects(self, column):
194 # return a list of objects associated with this node and possibly 195 # other seleted nodes. For selection we return a list for each type 196 # ( i.e. Atom, Residue, etc..) 197 # if the node is selected, collect object from all other selected nodes 198 resultAtoms = AtomSet([]) 199 resultResidues = ResidueSet([]) 200 resultChains = ChainSet([]) 201 resultMolecules = MoleculeSet([]) 202 buttonValue = self.chkbtval[column] 203 tree = self.tree() 204 fill = tree.columns[column].buttonColors 205 if self.isSelected: 206 for node in tree.selectedNodes: 207 if node in tree.displayedNodes: 208 tree.canvas.itemconfigure(node.chkbtid[column], 209 fill=fill[buttonValue]) 210 node.chkbtval[column] = buttonValue 211 result = node.getNodes(column) 212 obj = result[0] 213 if isinstance(obj, Atom): 214 resultAtoms += result 215 elif isinstance(obj, Residue): 216 resultResidues += result 217 elif isinstance(obj, Chain): 218 resultChains += result 219 elif isinstance(obj, Molecule) or isinstance(obj, Protein): 220 resultMolecules += result 221 result = [] 222 if len(resultAtoms): result.append(resultAtoms) 223 if len(resultResidues): result.append(resultResidues) 224 if len(resultChains): result.append(resultChains) 225 if len(resultMolecules): result.append(resultMolecules) 226 return result 227 else: 228 return [self.getNodes(column)]
229 230 231 ##################################################################### 232 # 233 # Column Descriptors for common PMV commands 234 # 235 ##################################################################### 236 ColumnDescriptors = [] 237 238
239 -class MVColumnDescriptor(ColumnDescriptor):
240
241 - def __init__(self, name, cmd, btype='checkbutton', buttonSize=(15,15), 242 buttonShape='circle', buttonColors = ['white', 'green'], 243 inherited=True, title=None, color='black', 244 objClassHasNoButton=None, 245 pmvCmdsToLoad=[], pmvCmdsToHandle=[]):
246 247 ColumnDescriptor.__init__( 248 self, name, cmd, btype=btype, buttonSize=buttonSize, 249 buttonShape=buttonShape, buttonColors=buttonColors, 250 inherited=inherited, title=title, color=color, 251 objClassHasNoButton=objClassHasNoButton) 252 253 self.pmvCmdsToHandle = pmvCmdsToHandle #list of Pmv commands that 254 # this column wants to know about 255 256 self.pmvCmdsToLoad = pmvCmdsToLoad #list of Pmv commands that 257 # need to be loaded. Each one is (command, module, package) 258 259 self.bbmode = 'ALL' 260 self.bbmodeWidgetcid = None
261
262 - def onPmvCmd(self, command, column, *args, **kw):
263 pass
264
265 - def setBBmode(self, value):
266 assert value in ['BB', 'SC', 'SC+CA', 'ALL'] 267 self.bbmode = value 268 if self.bbmodeWidgetcid: 269 self.tree.delete(self.bbmodeWidgetcid) 270 self.bbmodeWidgetcid = None
271
272 - def bbmodeOptMenu(self, event):
273 self.bbmodeWidget = Pmw.ComboBox( 274 self.tree.interior(), selectioncommand=self.setBBmode, 275 scrolledlist_items=['BB', 'SC', 'SC+CA', 'ALL'], 276 entryfield_entry_width=4)#, dropdown=0) 277 self.bbmodeWidget.selectitem(self.bbmode) 278 279 self.bbmodeWidgetcid = self.tree.create_window(event.x, event.y, 280 window=self.bbmodeWidget, anchor='nw')
281 282 283 284 from MolKit.molecule import Molecule, MolecularSystem 285 from MolKit.protein import Residue, Chain 286
287 -class MVvisibilityColumnDescriptor(MVColumnDescriptor):
288
289 - def onPmvCmd(self, command, column, *args, **kw):
290 print 'fugu2', column 291 tree = self.tree 292 for molName in args[0]: # loop over molecule names 293 mol = self.vf.expandNodes(molName) 294 #try: 295 node = tree.objectToNode[mol[0]] 296 print molName, mol, node, not kw['negate'] 297 node.set(column, not kw['negate'])
298 #except KeyError: 299 # pass 300 301
302 - def isOn(self, node):
303 try: 304 return node.geomContainer.masterGeom.visible 305 except AttributeError: 306 return 1 # at first the master geom is not there yet
307 308 visibilityColDescr = MVvisibilityColumnDescriptor( 309 'showMolecules', ('showMolecules', (), {}), title='Show/\nHide', 310 buttonColors=['white', 'grey75'], inherited=False, 311 buttonShape='rectangle', buttonSize=(10, 14), color='black', 312 objClassHasNoButton = [Atom, Residue, Chain, MolecularSystem], 313 pmvCmdsToHandle = ['showMolecules'], 314 pmvCmdsToLoad = [('showMolecules', 'displayCommands', 'Pmv'), 315 ] ) 316 ColumnDescriptors.append(visibilityColDescr) 317 318
319 -class MVSelectColumnDescriptor(MVColumnDescriptor):
320 321
322 - def __init__(self, name, cmd, btype='checkbutton', buttonSize=(15,15), 323 buttonShape='circle', buttonColors = ['white', 'green'], 324 inherited=True, title=None, color='black', 325 objClassHasNoButton=None, 326 pmvCmdsToLoad=[], pmvCmdsToHandle=[]):
327 328 MVColumnDescriptor.__init__( 329 self, name, cmd, btype=btype, buttonSize=buttonSize, 330 buttonShape=buttonShape, buttonColors=buttonColors, 331 inherited=inherited, title=title, color=color, 332 objClassHasNoButton=objClassHasNoButton, 333 pmvCmdsToLoad=pmvCmdsToLoad, pmvCmdsToHandle=pmvCmdsToHandle) 334 335 self.selectionDict = {}
336 337
338 - def isOn(self, node):
339 return self.selectionDict.has_key(node.object)
340 341
342 - def onPmvCmd(self, command, column, *args, **kw):
343 # clear all selection buttons and check buttons corresponding to 344 # the curent slection 345 346 tree = self.tree 347 selDict = {} 348 349 n = tree.root 350 n.chkbtval[column] = 0 351 while 1: 352 n = n.nextNode() 353 if n is None: break 354 n.chkbtval[column] = 0 355 if self.vf.selection: 356 selection = self.vf.getSelection() 357 else: 358 selection = [] 359 360 if command!=self.vf.clearSelection: 361 val = 1 362 for o in selection: 363 selDict[o] = 1 364 else: 365 val = 0 366 self.selectionDict = selDict 367 368 # loop over visible nodes in tree 369 for obj in selection: 370 try: 371 tree.objectToNode[obj].chkbtval[column] = val 372 except KeyError: 373 pass 374 tree.redraw()
375 376 377 378 selectColDescr = MVSelectColumnDescriptor( 379 'select', ('select', (), {}), title='Sel.', 380 buttonColors=['white', '#FFEA60'], inherited=False, 381 buttonShape='rectangle', buttonSize=(10, 14), color='magenta', 382 pmvCmdsToHandle = ['select', 'clearSelection', 'selectFromString', 383 'invertSelection', 'selectInSphere', 384 'setSelectionLevel'], 385 pmvCmdsToLoad = [('select', 'selectionCommands', 'Pmv'), 386 ('clearSelection', 'selectionCommands', 'Pmv'), 387 ('selectFromString', 'selectionCommands', 'Pmv'), 388 ('invertSelection', 'selectionCommands', 'Pmv'), 389 ('selectInSphere', 'selectionCommands', 'Pmv'), 390 ] ) 391 ColumnDescriptors.append(selectColDescr) 392 393
394 -class MVDisplayColumnDescriptor(MVColumnDescriptor):
395
396 - def onPmvCmd(self, command, column, *args, **kw):
397 398 if self.commandType=='button': 399 return # only check buttons not managed upon PMV command 400 401 molFrag = args[0] 402 negate = kw['negate'] 403 for o in molFrag: 404 try: 405 node = self.tree.objectToNode[o] 406 if node.chkbtval[column]==negate: # if button needs to be checked 407 node.set(column, negate==False) 408 except KeyError: 409 #print 'Failed to find object in tree', o 410 pass
411 412 413 displayLinesColDescr = MVDisplayColumnDescriptor( 414 'display lines', ('displayLines', (), {}), 415 buttonColors=['white', '#FF4F44'], title='Lines', color='#5B49BF', 416 pmvCmdsToHandle = ['displayLines'], 417 pmvCmdsToLoad = [('displayLines', 'displayCommands', 'Pmv')]) 418 ColumnDescriptors.append(displayLinesColDescr) 419 420 421 displayCPKColDescr = MVDisplayColumnDescriptor( 422 'display CPK', ('displayCPK', (), {}), 423 buttonColors=['white', '#FF4F44'], title='CPK', color='#BF7C66', 424 pmvCmdsToHandle = ['displayCPK'], 425 pmvCmdsToLoad = [('displayCPK', 'displayCommands', 'Pmv')]) 426 ColumnDescriptors.append(displayCPKColDescr) 427 428 429 displaySandBColDescr = MVDisplayColumnDescriptor( 430 'display S&B', ('displaySticksAndBalls', (), {}), 431 buttonColors=['white', '#FF4F44'], title='S&B', color='purple', 432 pmvCmdsToHandle = ['displaySticksAndBalls'], 433 pmvCmdsToLoad = [('displaySticksAndBalls', 'displayCommands', 'Pmv')]) 434 ColumnDescriptors.append(displaySandBColDescr) 435 436 437
438 -class RibbonColumnDescriptor(MVDisplayColumnDescriptor):
439 440 # override Ribbon.optMenu_cb to display panel of extrude SS
441 - def optMenu_cb(self, node, column, event=None):
442 cmd = self.vf.extrudeSecondaryStructure 443 cmd.guiCallback()
444 445 446 displaySSColDescr = RibbonColumnDescriptor( 447 'display Second.Struct.', ('displayExtrudedSS', (), {}), 448 buttonColors=['white', '#FF4F44'], title='Rib.', color='#333333', 449 pmvCmdsToHandle = ['displayExtrudedSS'], 450 pmvCmdsToLoad = [('displayExtrudedSS', 'secondaryStructureCommands', 'Pmv')]) 451 452 453 ColumnDescriptors.append(displaySSColDescr) 454 455 456 import types
457 -class MSMSColumnDescriptor(MVDisplayColumnDescriptor):
458
459 - def __init__(self, name, cmd, btype='checkbutton', buttonSize=(15,15), 460 buttonShape='circle', buttonColors = ['white', 'green'], 461 inherited=True, title=None, color='black', 462 pmvCmdsToLoad=[], pmvCmdsToHandle=[]):
463 464 MVDisplayColumnDescriptor.__init__( 465 self, name, cmd, btype=btype, buttonSize=buttonSize, 466 buttonShape=buttonShape, buttonColors=buttonColors, 467 inherited=inherited, title=title, color=color, 468 pmvCmdsToLoad=pmvCmdsToLoad, pmvCmdsToHandle=pmvCmdsToHandle) 469 470 self.msmsDefaultValues = {} #cache used to decide if we re-compute
471 472
473 - def onPmvCmd(self, command, column, *args, **kw):
474 475 #print "MSMS dashboard. onPmvCommand", command.name 476 if command.name=='computeMSMS': 477 self.msmsDefaultValues.update( 478 self.vf.computeMSMS.getLastUsedValues()) 479 elif command.name=='displayMSMS': 480 MVDisplayColumnDescriptor.onPmvCmd( *((self,command,column)+args), 481 **kw)
482 483
484 - def execute(self, node, colInd):
485 486 val = node.chkbtval[colInd] 487 cmd = self.vf.computeMSMS 488 defaultValues = cmd.getLastUsedValues() 489 defaultValues = cmd.fixValues(defaultValues) 490 491 oldDefaultValues = self.msmsDefaultValues 492 recompute = False 493 if len(oldDefaultValues)==0: 494 recompute=True 495 else: 496 for k,v in oldDefaultValues.items(): 497 nv = defaultValues.get(k, None) 498 if nv!=v: 499 recompute=True 500 break 501 502 molat = {} 503 for obj in node.getObjects(colInd): 504 molecules, atmSets = self.vf.getNodesByMolecule(obj, Atom) 505 for mol, atoms in zip(molecules, atmSets): 506 try: 507 molat[mol] += atoms 508 except KeyError: 509 molat[mol] = atoms 510 511 for mol, atoms in molat.items(): 512 if not mol.geomContainer.geoms.has_key('MSMS-MOL'): 513 recompute=True 514 if len(defaultValues): 515 if defaultValues['perMol']==0 and val: 516 recompute=True 517 if type(defaultValues['surfName'])==types.TupleType: 518 defaultValues['surfName']=defaultValues['surfName'][0] 519 520 if recompute: 521 #print 'computing', defaultValues 522 apply( self.vf.computeMSMS, (atoms,), defaultValues) 523 else: 524 #print 'DSIPLAY', defaultValues 525 pmvcmd = self.vf.displayMSMS 526 #defaultValues = pmvcmd.getLastUsedValues() 527 defaultValues['callListener'] = False 528 pmvcmd(atoms, negate= not val, callListener=False) 529 if pmvcmd.lastUsedValues['default'].has_key('callListener'): 530 del pmvcmd.lastUsedValues['default']['callListener'] 531 532 if recompute: 533 self.msmsDefaultValues.update(defaultValues)
534 535 536 # override MSMScol.optMenu_cb
537 - def optMenu_cb(self, node, column, event=None):
538 cmd = self.vf.computeMSMS 539 values = cmd.showForm(posx=event.x_root, posy=event.y_root) 540 if len(values)==0: return # Cancel was pressed 541 values = cmd.fixValues(values) 542 cmd.lastUsedValues['default'].update(values) 543 node.buttonClick(column, val=1)
544 545 546 displayMSMSColDescr = MSMSColumnDescriptor( 547 'compute/display Molecular Surface', ('displayMSMS', (), {}), 548 buttonColors=['white', '#FF4F44'], title='MS', color='#333333', 549 pmvCmdsToHandle = ['displayMSMS', 'computeMSMS'], 550 pmvCmdsToLoad = [('displayMSMS', 'msmsCommands', 'Pmv'), 551 ('computeMSMS', 'msmsCommands', 'Pmv')]) 552 ColumnDescriptors.append(displayMSMSColDescr) 553 554
555 -class LabelColumnDescriptor(MVDisplayColumnDescriptor):
556 557 # override labelCol.optMenu_cb
558 - def optMenu_cb(self, node, column, event=None):
559 if node.object==self.vf.dashboard.system: return 560 cmd, args, kw = self.tree.columns[column].cmd 561 from MolKit.molecule import Atom, Molecule 562 from MolKit.protein import Residue, Chain 563 vi = self.vf.GUI.VIEWER 564 molName = node.object.top.name 565 if isinstance(node.object,Atom): 566 geom=vi.FindObjectByName('root|%s|AtomLabels'%molName) 567 elif isinstance(node.object,Residue): 568 geom=vi.FindObjectByName('root|%s|ResidueLabels'%molName) 569 elif isinstance(node.object,Chain): 570 geom=vi.FindObjectByName('root|%s|ChainLabels'%molName) 571 else: 572 geom=vi.FindObjectByName('root|%s|ProteinLabels'%molName) 573 574 geom.showOwnGui()
575 576 ## ## cmd, args, kw = self.tree.columns[column].cmd 577 ## ## from MolKit.molecule import Atom, Molecule 578 ## ## from MolKit.protein import Residue, Chain 579 ## ## if isinstance(node.object,Atom): 580 ## ## tag = 'Atom' 581 ## ## elif isinstance(node.object,Residue): 582 ## ## tag = 'Residue' 583 ## ## elif isinstance(node.object,Chain): 584 ## ## tag = 'Chain' 585 ## ## else: 586 ## ## tag = 'Molecule' 587 ## ## cmd.update_cb(tag, force=True) 588 ## ## values = cmd.showForm() 589 ## ## if values.has_key('level'): 590 ## ## del values['level'] 591 ## ## if values.has_key('display'): 592 ## ## del values['display'] 593 ## ## cmd.lastUsedValues['default'].update(values) 594 595 labelColDescr = LabelColumnDescriptor( 596 'label', ('labelByProperty', (), {'properties':['name']}), 597 buttonColors=['white', 'cyan'], buttonShape='square', 598 buttonSize=(15,15), inherited=False, title='Lab.', color='#268E23', 599 pmvCmdsToHandle = ['labelByProperty'], 600 pmvCmdsToLoad = [('labelByProperty', 'labelCommands', 'Pmv')]) 601 ColumnDescriptors.append(labelColDescr) 602 603 604 colAtColDescr = MVColumnDescriptor( 605 'color by atom types', ('colorByAtomType', (), {}), 606 title='Atom', color='magenta', 607 pmvCmdsToHandle = ['colorByAtomType'], 608 pmvCmdsToLoad = [('colorByAtomType', 'colorCommands', 'Pmv')], 609 btype='button', buttonShape='diamond', buttonSize=(18,18), 610 ) 611 ColumnDescriptors.append(colAtColDescr) 612 613 614 colMolColDescr = MVColumnDescriptor( 615 'color by molecule', ('colorByMolecules', (), {}), 616 title='Mol', color='#5B49BF', 617 pmvCmdsToHandle = ['colorByMolecules'], 618 pmvCmdsToLoad = [('colorByMolecules', 'colorCommands', 'Pmv')], 619 btype='button', buttonShape='diamond', buttonSize=(18,18), 620 ) 621 ColumnDescriptors.append(colMolColDescr) 622 623 624 colChainColDescr = MVColumnDescriptor( 625 'color by chains', ('colorByChains', (), {}), 626 title='Chain', color='#BF7C66', 627 pmvCmdsToHandle = ['colorByChains'], 628 pmvCmdsToLoad = [('colorByChains', 'colorCommands', 'Pmv')], 629 btype='button', buttonShape='diamond', buttonSize=(18,18), 630 ) 631 ColumnDescriptors.append(colChainColDescr) 632 633 634 colResRASColDescr = MVColumnDescriptor( 635 'color by residue (RASMOL)', ('colorByResidueType', (), {}), 636 title='RAS', color='purple', 637 pmvCmdsToHandle = ['colorByResidueType'], 638 pmvCmdsToLoad = [('colorByResidueType', 'colorCommands', 'Pmv')], 639 btype='button', buttonShape='diamond', buttonSize=(18,18), 640 ) 641 ColumnDescriptors.append(colResRASColDescr) 642 643 644 colResSHAColDescr = MVColumnDescriptor( 645 'color by residue (SHAPELY)', ('colorResiduesUsingShapely', (), {}), 646 title='SHA', color='#333333', 647 pmvCmdsToHandle = ['colorResiduesUsingShapely'], 648 pmvCmdsToLoad = [('colorResiduesUsingShapely', 'colorCommands', 'Pmv')], 649 btype='button', buttonShape='diamond', buttonSize=(18,18), 650 ) 651 ColumnDescriptors.append(colResSHAColDescr) 652 653 654 colDGColDescr = MVColumnDescriptor( 655 'color by DG', ('colorAtomsUsingDG', (), {}), 656 title='DG', color='#268E23', 657 pmvCmdsToHandle = ['colorAtomsUsingDG'], 658 pmvCmdsToLoad = [('colorAtomsUsingDG', 'colorCommands', 'Pmv')], 659 btype='button', buttonShape='diamond', buttonSize=(18,18), 660 ) 661 ColumnDescriptors.append(colDGColDescr) 662 663 664 colInstColDescr = MVColumnDescriptor( 665 'color by instance', ('colorByInstance', (), {}), 666 title='Inst.', color='black', 667 pmvCmdsToHandle = ['colorByInstance'], 668 pmvCmdsToLoad = [('colorByInstance', 'colorCommands', 'Pmv')], 669 btype='button', buttonShape='diamond', buttonSize=(18,18), 670 ) 671 ColumnDescriptors.append(colInstColDescr) 672 673 674 colSSColDescr = MVColumnDescriptor( 675 'color by second. struct.', ('colorBySecondaryStructure', (), {}), 676 title='Sec.\nStr.', color='magenta', 677 pmvCmdsToHandle = ['colorBySecondaryStructure'], 678 pmvCmdsToLoad = [('colorBySecondaryStructure', 679 'secondaryStructureCommands', 'Pmv')], 680 btype='button', buttonShape='diamond', buttonSize=(18,18), 681 ) 682 ColumnDescriptors.append(colInstColDescr) 683 684 685 ## ColDescr = MVColumnDescriptor( 686 ## '', ('', (), {}), 687 ## title='', color='', 688 ## pmvCmdsToHandle = [''], 689 ## pmvCmdsToLoad = [('', 'colorCommands', 'Pmv')], 690 ## btype='button', buttonShape='diamond', buttonSize=(18,18), 691 ## ) 692 ## ColumnDescriptors.append(ColDescr) 693 694 695 ## cmds = [ 696 ## ('color by atom types', 'Atom', 'colorByAtomType', (), {}, 697 ## 'magenta', 'colorCommands'), 698 ## ('color by molecule', 'Mol', 'colorByMolecules', (), {}, 699 ## '#5B49BF', 'colorCommands'), 700 701 ## ('color by chains', 'Chain', 'colorByChains', (), {}, 702 ## '#BF7C66', 'colorCommands'), 703 ## ('color by residue (RASMOL)', 'RAS', 704 ## 'colorByResidueType', (), {}, 'purple', 'colorCommands'), 705 706 ## ('color by residue (SHAPELY)', 'SHA', 707 ## 'colorResiduesUsingShapely', (), {}, '#333333', 'colorCommands'), 708 ## ('color by DG', 'DG', 'colorAtomsUsingDG',(), {}, '#268E23', 709 ## 'colorCommands'), 710 ## ('color by instance', 'Inst.', 'colorByInstance', (), {}, 711 ## 'black', 'colorCommands'), 712 ## ('color by second. struct.', 'Sec.\nStr.', 713 ## 'colorBySecondaryStructure', (), {}, 'magenta', 714 ## 'secondaryStructureCommands'), 715 ## ] 716 717 ## for name, title, cmd, args, opt, color, mod in cmds: 718 ## descr = MVColumnDescriptor( 719 ## name, (cmd, args, opt), title=title, color=color, 720 ## btype='button', buttonShape='diamond', buttonSize=(18,18), 721 ## pmvCmdsToHandle = [cmd], 722 ## pmvCmdsToLoad = [(cmd, mod, 'Pmv')] 723 ## ) 724 ## ColumnDescriptors.append(descr) 725
726 -def loadAllColunms(mv):
727 # adding columns to dashboard 728 mv.dashboardSuspendRedraw(True) 729 730 mv.addDashboardCmd(visibilityColDescr, log=0) 731 mv.addDashboardCmd(selectColDescr, log=0) 732 mv.addDashboardCmd(displayLinesColDescr, log=0) 733 mv.addDashboardCmd(displayCPKColDescr, log=0) 734 mv.addDashboardCmd(displaySandBColDescr, log=0) 735 mv.addDashboardCmd(displaySSColDescr, log=0) 736 mv.addDashboardCmd(displayMSMSColDescr, log=0) 737 mv.addDashboardCmd(labelColDescr, log=0) 738 mv.addDashboardCmd(colAtColDescr, log=0) 739 mv.addDashboardCmd(colMolColDescr, log=0) 740 mv.addDashboardCmd(colChainColDescr, log=0) 741 mv.addDashboardCmd(colResRASColDescr, log=0) 742 mv.addDashboardCmd(colResSHAColDescr, log=0) 743 mv.addDashboardCmd(colDGColDescr, log=0) 744 mv.addDashboardCmd(colSSColDescr, log=0) 745 mv.addDashboardCmd(colInstColDescr, log=0) 746 747 mv.dashboardSuspendRedraw(False)
748 749
750 -def moveTreeToWidget(oldtree, master):
751 # save columns 752 columns = oldtree.columns 753 754 # get handle to root node 755 rootnode = oldtree.root 756 757 # get handle to tree's objectToNode dict 758 objToNode = oldtree.objectToNode 759 selectedNodes = oldtree.selectedNodes 760 761 # destroy docked tree 762 oldtree.undisplay() 763 oldtree.destroy() 764 765 # create new tree 766 tree = oldtree.__class__(master, rootnode, selectionMode='multiple') 767 768 # change all references to Tree 769 oldtree.reparentNodes(tree) 770 771 tree.selectedNodes = selectedNodes 772 tree.objectToNode = objToNode 773 774 # put the columns back. This needs to be done by hand 775 # because addColumnDescriptor appends a chkbtval and resets nodes 776 tree.columns = columns 777 tree.nbCol = len(columns) 778 for i,c in enumerate(columns): 779 tree.createColHeader(c, i) 780 c.tree = tree 781 782 tree.pack(expand=1, fill="both") 783 tree.updateTreeHeight() 784 return tree
785