# ============================================================================== # PREPARE YANK CALCULATION # ============================================================================== from yank.yank import Yank # Initialize YANK object. yank = Yank(store_dir) # Set options. options = dict() options['number_of_iterations'] = niterations options['number_of_equilibration_iterations'] = nequiliterations options['nsteps_per_iteration'] = nsteps_per_iteration options['online_analysis'] = False yank.restraint_type = None options['randomize_ligand'] = False options['minimize'] = True options['timestep'] = timestep options['collision_rate'] = collision_rate options['platform'] = platform if not is_periodic: yank.restraint_type = 'harmonic' # Prepare phases of calculation. phase_prefixes = ['solvent', 'complex'] # list of calculation phases (thermodynamic legs) to set up components = ['ligand', 'receptor', 'solvent'] # components of the binding system phase_prefixes = ['complex'] # DEBUG, since 'solvent' doesn't work yet systems = dict() # systems[phase] is the System object associated with phase 'phase' positions = dict() # positions[phase] is a list of coordinates associated with phase 'phase'
def dispatch_binding(args): """ Set up a binding free energy calculation. Parameters ---------- args : dict Command-line arguments from docopt. """ verbose = args['--verbose'] # # Determine simulation options. # # Specify thermodynamic parameters. temperature = process_unit_bearing_argument(args, '--temperature', unit.kelvin) pressure = process_unit_bearing_argument(args, '--pressure', unit.atmospheres) thermodynamic_state = ThermodynamicState(temperature=temperature, pressure=pressure) # Create systems according to specified setup/import method. if args['amber']: [phases, systems, positions, atom_indices] = setup_binding_amber(args) elif args['systembuilder']: [phases, systems, positions, atom_indices] = setup_binding_systembuilder(args) else: print "No valid binding free energy calculation setup command specified: Must be one of ['amber', 'systembuilder']." # Trigger help argument to be returned. return False # Report some useful properties. if verbose: if 'complex-explicit' in atom_indices: phase = 'complex-explicit' else: phase = 'complex-implicit' print " TOTAL ATOMS : %9d" % len(atom_indices[phase]['complex']) print " receptor : %9d" % len(atom_indices[phase]['receptor']) print " ligand : %9d" % len(atom_indices[phase]['ligand']) if phase == 'complex-explicit': print " solvent and ions : %9d" % len(atom_indices[phase]['solvent']) # Initialize YANK object. yank = Yank(args['--store'], verbose=verbose) # Set options. options = dict() if args['--iterations']: options['number_of_iterations'] = int(args['--iterations']) if args['--online-analysis']: options['online_analysis'] = True if args['--restraints']: yank.restraint_type = args['--restraints'] if args['--randomize-ligand']: options['randomize_ligand'] = True if args['--minimize']: options['minimize'] = True # Create new simulation. yank.create(phases, systems, positions, atom_indices, thermodynamic_state, options=options) # Report success. return True
# ============================================================================== # PREPARE YANK CALCULATION # ============================================================================== from yank.yank import Yank # Initialize YANK object. yank = Yank(store_dir) # Set options. options = dict() options['number_of_iterations'] = niterations options['number_of_equilibration_iterations'] = nequiliterations options['nsteps_per_iteration'] = nsteps_per_iteration options['online_analysis'] = False yank.restraint_type = None options['randomize_ligand'] = False options['minimize'] = True options['timestep'] = timestep options['collision_rate'] = collision_rate options['platform'] = platform if not is_periodic: yank.restraint_type = 'harmonic' # Prepare phases of calculation. phase_prefixes = [ 'solvent', 'complex' ] # list of calculation phases (thermodynamic legs) to set up components = ['ligand', 'receptor', 'solvent'] # components of the binding system
def dispatch_binding(args): """ Set up a binding free energy calculation. Parameters ---------- args : dict Command-line arguments from docopt. """ verbose = args['--verbose'] store_dir = args['--store'] utils.config_root_logger(verbose, log_file_path=os.path.join( store_dir, 'prepare.log')) # # Determine simulation options. # # Specify thermodynamic parameters. temperature = process_unit_bearing_argument(args, '--temperature', unit.kelvin) pressure = process_unit_bearing_argument(args, '--pressure', unit.atmospheres) thermodynamic_state = ThermodynamicState(temperature=temperature, pressure=pressure) # Create systems according to specified setup/import method. if args['amber']: [phases, systems, positions, atom_indices] = setup_binding_amber(args) elif args['gromacs']: [phases, systems, positions, atom_indices] = setup_binding_gromacs(args) else: logger.error( "No valid binding free energy calculation setup command specified: Must be one of ['amber', 'systembuilder']." ) # Trigger help argument to be returned. return False # Report some useful properties. if verbose: if 'complex-explicit' in atom_indices: phase = 'complex-explicit' else: phase = 'complex-implicit' logger.info("TOTAL ATOMS : %9d" % len(atom_indices[phase]['complex'])) logger.info("receptor : %9d" % len(atom_indices[phase]['receptor'])) logger.info("ligand : %9d" % len(atom_indices[phase]['ligand'])) if phase == 'complex-explicit': logger.info("solvent and ions : %9d" % len(atom_indices[phase]['solvent'])) # Initialize YANK object. yank = Yank(store_dir) # Set options. options = dict() if args['--nsteps']: options['nsteps_per_iteration'] = int(args['--nsteps']) if args['--iterations']: options['number_of_iterations'] = int(args['--iterations']) if args['--equilibrate']: options['number_of_equilibration_iterations'] = int( args['--equilibrate']) if args['--online-analysis']: options['online_analysis'] = True if args['--restraints']: yank.restraint_type = args['--restraints'] if args['--randomize-ligand']: options['randomize_ligand'] = True if args['--minimize']: options['minimize'] = True # Allow platform to be optionally specified in order for alchemical tests to be carried out. if args['--platform'] not in [None, 'None']: options['platform'] = openmm.Platform.getPlatformByName( args['--platform']) if args['--precision']: # We need to modify the Platform object. if args['--platform'] is None: raise Exception( "The --platform argument must be specified in order to specify platform precision." ) # Set platform precision. precision = args['--precision'] platform_name = args['--platform'] logger.info( "Setting %s platform to use precision model '%s'." % platform_name, precision) if precision is not None: if platform_name == 'CUDA': options['platform'].setPropertyDefaultValue( 'CudaPrecision', precision) elif platform_name == 'OpenCL': options['platform'].setPropertyDefaultValue( 'OpenCLPrecision', precision) elif platform_name == 'CPU': if precision != 'mixed': raise Exception( "CPU platform does not support precision model '%s'; only 'mixed' is supported." % precision) elif platform_name == 'Reference': if precision != 'double': raise Exception( "Reference platform does not support precision model '%s'; only 'double' is supported." % precision) else: raise Exception( "Platform selection logic is outdated and needs to be updated to add platform '%s'." % platform_name) # Create new simulation. yank.create(phases, systems, positions, atom_indices, thermodynamic_state, options=options) # Report success. return True
def dispatch_binding(args): """ Set up a binding free energy calculation. Parameters ---------- args : dict Command-line arguments from docopt. """ verbose = args['--verbose'] # Specify simulation parameters. nonbondedMethod = getattr(app, args['--nbmethod']) implicitSolvent = getattr(app, args['--gbsa']) if args['--constraints'] == None: args[ '--constraints'] = None # Necessary because there is no 'None' in simtk.openmm.app constraints = getattr(app, args['--constraints']) removeCMMotion = False # Specify thermodynamic parameters. temperature = process_unit_bearing_argument(args, '--temperature', unit.kelvin) pressure = process_unit_bearing_argument(args, '--pressure', unit.atmospheres) thermodynamic_state = ThermodynamicState(temperature=temperature, pressure=pressure) # Create systems according to specified setup/import method. if args['amber']: [phases, systems, positions, atom_indices] = setup_binding_amber(args) elif args['systembuilder']: [phases, systems, positions, atom_indices] = setup_binding_systembuilder(args) else: print "No valid binding free energy calculation setup command specified: Must be one of ['amber', 'systembuilder']." # Trigger help argument to be returned. return False # Report some useful properties. if verbose: if 'complex-explicit' in atom_indices: phase = 'complex-explicit' else: phase = 'complex-implicit' print " TOTAL ATOMS : %9d" % len(atom_indices[phase]['complex']) print " receptor : %9d" % len(atom_indices[phase]['receptor']) print " ligand : %9d" % len(atom_indices[phase]['ligand']) if phase == 'complex-explicit': print " solvent and ions : %9d" % len( atom_indices[phase]['solvent']) # Initialize YANK object. yank = Yank(args['--store'], verbose=verbose) # Set options. options = dict() if args['--iterations']: options['number_of_iterations'] = int(args['--iterations']) if args['--online-analysis']: options['online_analysis'] = True if args['--restraints']: yank.restraint_type = args['--restraints'] if args['--randomize-ligand']: options['randomize_ligand'] = True if args['--platform'] != 'None': options['platform'] = openmm.Platform.getPlatformByName( args['--platform']) if args['--minimize']: options['minimize'] = True # Create new simulation. yank.create(phases, systems, positions, atom_indices, thermodynamic_state, options=options) # Report success. return True