# YASARA MACRO # TOPIC: 5. Structure prediction # TITLE: Showing the docking results interactively # REQUIRES: Structure # AUTHOR: Elmar Krieger # LICENSE: GPL # DESCRIPTION: This macro provides an interactive player to cycle through the docking poses and clusters # You can either set the target structure by clicking on Options > Macro > Set target, # or by uncommenting the line below and specifying it directly. #MacroTarget='/home/myname/projects/docking/1sdf' # Set playback waittime (1 is maximum playback speed) waittime=12 # Normally no change required below this point # Sanity checks if MacroTarget=='' RaiseError "This macro requires a target. Either edit the macro file or click Options > Macro > Set target to choose a target structure" Console off # PART 1 - DOCKING POSE ANALYSIS DockingPoses: # Load the result scene Clear LoadSce (MacroTarget) # Determine if this was a single receptor or a receptor ensemble for receptors=1 to 999 found = CountObj Receptor(receptors+1) if not found break if receptors==1 # Single receptor # The ligand object contains one molecule for each docking run receptorruns = CountMol Obj Ligand else # Receptor ensemble receptorruns = CountMol Obj Ligand1 runs=receptors*receptorruns if !runs RaiseError "No object named 'Ligand' or 'Ligand1' found. This macro must be applied to a docking scene created with one of the 'dock_run*' macros" # Create the user interface ShowPlayer 'Pose' run=0 step=1 delay=waittime mainloop='PoseMainLoop' # Loop through the docking poses PoseMainLoop: while 1 if run<0 or run>=runs Go RewindToStart # Determine names of receptor and ligand objects if receptors>1 rec=(run//receptorruns)+1 recobj='Receptor(rec)' ligobj='Ligand(rec)' else recobj='Receptor' ligobj='Ligand' recrun=001+(run%receptorruns) # Show the corresponding receptor and ligand SwitchObj !SimCell,off SwitchObj (recobj) (ligobj),On HideObj (ligobj) ShowAtom Segment C(recrun) Obj (ligobj) # Update the player # The segment names of the ligand conformations are C001, C002 etc. UpdatePlayer run,runs,'Segment C(recrun) Obj (ligobj)' # Proceed to next pose run=run+step if step # Wait a bit Wait (delay) else # Pause mode, wait until next click Wait forever # PART 2 - DOCKING CLUSTER ANALYSIS DockingClusters: Clear # Count the clusters for runs=000 to 999 exists = FileSize (MacroTarget)_(runs+1).yob if !exists break if runs<1 RaiseError "No docking clusters have been found. This macro must be applied to a docking project created with one of the 'dock_run*' macros" # Create the user interface ShowPlayer 'Cluster' run=0 step=1 delay=waittime posorilist=0,0,50,0,0,0 mainloop='ClusterMainLoop' # Loop through the docking clusters ClusterMainLoop: while 1 if run<0 or run>=runs Go RewindToStart if Atoms # Remember current position and orientation posorilist() = PosOriObj 1 DelAll LoadYOb (MacroTarget)_(001+run) CenterAtom CA PosOriObj 1,(posorilist) Style Ribbon,Stick BallRes Segment C??? FreeAll ShowHBoAll ColorAll Element # Update the player # The ligand is selected via the last atom in the soup */ UpdatePlayer run,runs,'(atoms)' # Proceed to next pose run=run+step if step # Wait a bit Wait (delay) else # Pause mode, wait until next click Wait forever # CREATE PLAYER USER INTERFACE # ============================ # 'type' is 'Pose' or 'Cluster' def ShowPlayer type global gpos PrintHUD FillRect Font Arial,Height=20,Color=White PosText X=160,Y=8,Justify=Center Print 'Docking (type) Player' FillRect X=15,Y=30,Width=290,Height=1,Color=White Font Height=14,Spacing=1.3 PosText X=25,Y=46,Justify=Left if type=='Pose' Print 'Docking run:\n' else Print 'Cluster:\n' Print 'Binding energy:\nInhib. constant:' # Create the clickable color gradient on the right. # Its position 'gpos' is made global, so that it can be used by function UpdatePlayer Font MonoSpaced,Spacing=1 gpos=240,120 FillRect (gpos1),(gpos2+5),Width=32,Height=241,Color=White for i=0 to 10 PosText (gpos1/8+6),(gpos2/12+i*2+1),Justify=Left Print '(i*10)%' FillRect (gpos1+32),(gpos2+i*24+5),Width=8,Height=1,Color=White # Top and bottom button have half the height if !i y=gpos2+6 h=12 else y=gpos2+i*24-7 h=24-12*(i==10) ShowButton X=(gpos1+16),Y=(y),Width=30,Height=(h),Border=0, Color=(i*320/11),Action='Go ClickGradient,GoPar=(i)' PosText (gpos1/8+3),(gpos2/12+22),Justify=Center Print 'Click' PosText (gpos1/8+3),(gpos2/12+23),Justify=Center Print 'above' # Create the buttons Font Arial,Height=14,Spacing=1.3 ShowButton 'Play',X=70,Y=120 ShowButton 'Pause',X=160,Y=120 ShowButton 'Step backward',X=120,Y=170 ShowButton 'Step forward',X=120,Y=220 ShowButton 'Fast backward',X=120,Y=270 ShowButton 'Fast forward',X=120,Y=320 ShowButton 'Rewind to start',X=120,Y=370 if type=='Pose' ShowButton 'Proceed to cluster analysis',X=174,Y=420,Color=404040,Action='Go DockingClusters' else ShowButton 'Return to docking poses',X=174,Y=420,Color=404040,Action='Go DockingPoses' # UPDATE PLAYER USER INTERFACE # ============================ def UpdatePlayer run,runs,ligandsel global gpos # The atomic B-factor contains the free binding energy in kcal/mol (positive is better). bindnrg = BFactorAtom (ligandsel) # The atomic property contains the picomolar [pM] inhibition constant. inhibconst = PropAtom (ligandsel) if bindnrg<=0 inhibconst='None' elif inhibconst>=100000000 inhibconst='Gigantic' elif inhibconst>=100000 inhibconst=0+inhibconst else inhibconst=0.000+inhibconst # Display run, binding energy and inhibition constant FillRect X=170,Y=44,Width=150,Height=70 PosText X=170,Y=46,Justify=Left Print '(1+run)/(0+runs)\n(0.00+bindnrg) kcal/mol\n(inhibconst) pM' if runs>1 # Show the '>' at the color gradient FillRect X=(gpos1-20),Y=(gpos2),Width=15,Height=260 PosText X=(gpos1-20),Y=(gpos2+240*run/(runs-1)) Print '>' # HANDLE THE PLAYER BUTTONS # ========================= # Press the Play button Play: step=1 delay=waittime Go (mainloop) # Press the Pause button Pause: step=0 delay=waittime Go (mainloop) # Press the step forward button StepForward: run=run+1 Go (mainloop) # Press the step backward button StepBackward: run=run-1 Go (mainloop) # Press the fast forward button FastForward: step=1 delay=1 Go (mainloop) # Press the fast backward button FastBackward: step=-1 delay=1 Go (mainloop) # Press the rewind to start button RewindToStart: run=0 if step<0 Go Play Go (mainloop) # Click the color gradient on the right ClickGradient: run=(runs-1)*GoPar/10 Go (mainloop)