# YASARA MACRO # TOPIC: 3. Molecular Dynamics # TITLE: Play back a molecular dynamics trajectory # REQUIRES: Dynamics # AUTHOR: Elmar Krieger # LICENSE: GPL # DESCRIPTION: This macro plays back a molecular dynamics simulation, looping back to the start. # 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 = 'c:\MyProject\1crn' # Forcefield to use (these are all YASARA commands, so no '=' used) ForceField Amber99 # Cell boundary Boundary periodic # Set playback waittime (1 is maximum playback speed) waittime = 25 # Choose trajectory format, sim or xtc format = 'sim' # Set to 1 if you want to center the structure in every frame to keep it from # crossing a periodic boundary. Use *only if absolutely needed*, since it may # cause an error message about a 'search grid overflow'. Also this only works # as long as a small part of the structure really crosses a boundary. centered = 0 # Do we have a target? if MacroTarget=='' RaiseError "This macro requires a target. Either edit the macro file or click Options > Macro > Set target to choose a target structure" # Do we have a scene with water? scene = FileSize (MacroTarget)_water.sce if not scene RaiseError 'Could not find initial scene file (MacroTarget)_water.sce' # Load the scene LoadSce (MacroTarget)_water # Pick a nice style Style Backbone=Ribbon,Sidechain=Stick Console off i=00000 filename = '(MacroTarget)(i).(format)' while 1 if format=='sim' # See if next snapshot is present sim = FileSize (MacroTarget)(i).sim if not sim # Loop back to start i=00000 # Load the snapshot LoadSim (MacroTarget)(i) i=i+1 else i=i+1 last = LoadXTC (filename),(i) if last # Loop back to start i=00000 # Show the simulation time simtime=Time ShowMessage 'Current simulation time is (0+simtime/1000) picoseconds.' if centered # We want to keep the protein at the center of the cell # Get cell center in cellinfo(7)-cellinfo(9) and the mean solute position in x,y,z cellinfo() = Cell x,y,z = PosAtom !Hetgroup,mean=Yes # Move everything back MoveAtom all,(cellinfo(7)-x),(cellinfo(8)-y),(cellinfo(9)-z) # Moving atoms around stops the simulation, restart OnError Continue Sim On OnError Stop Time (simtime) # Make sure that the simulation does not continue while we wait Sim Pause # Wait a bit Wait (waittime)