# YASARA MACRO # TOPIC: 3. Molecular Dynamics # TITLE: Convert between SIM and XTC simulation trajectories # REQUIRES: Dynamics # AUTHOR: Elmar Krieger # LICENSE: GPL # DESCRIPTION: This macro converts an existing MD trajectory from SIM to XTC format and vice versa # Parameter section - adjust as needed # ==================================== # The trajectory to convert must be present with a .sim or .xtc extension. # The starting scene *_water.sce is also required. # You can either set the target by clicking on Options > Macro > Set target, # or by uncommenting the line below and specifying it directly. #MacroTarget = 'c:\MyProject\1crn' # Source format is 'sim', destination format is 'xtc', swap if needed. srcformat='sim' dstformat='xtc' # ============================================== # 'savesteps', 'timestep' and 'Boundary' must be # exactly the same as in the source trajectory! # ============================================== # Save destination trajectory snapshots every 3000 steps savesteps = 3000 # Multiple timestep: 1.25 femtoseconds for intramolecular and 2*1.25 fs for intermolecular forces timestep = '2,1.25' # Cell boundary Boundary periodic # Forcefield to use (these are all YASARA commands, so no '=' used) ForceField Amber99 # Cutoff Cutoff 7.86 # Use longrange coulomb forces (particle-mesh Ewald) Longrange Coulomb # No changes required below this point! # 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" Clear # Load starting structure LoadSce (MacroTarget)_water TimeStep (timestep) # Save the destination trajectory i=00000 Save(dstformat) (MacroTarget)(i),(savesteps) Console Off # As saving is done automatically, all we need to do is load the snapshots # from the source trajectory. This will adjust the current simulation time, # which in turn triggers the save events. The 'Wait 1' is essential to # suspend the macro for one cycle, so that the simulation continues and can # be saved. (Snapshots are only saved while the simulation is running!). if srcformat=='sim' do LoadSim (MacroTarget)(i) i = i+1 ShowMessage 'Converting SIM snapshot (i) to XTC format' found = FileSize (MacroTarget)(i).sim Wait 1 while found else do i = i+1 ShowMessage 'Converting XTC snapshot (i) to SIM format' last = LoadXTC (MacroTarget)00000,(i) Wait 1 while !last HideMessage Sim Off