def run(self): self._start() print(" - Calculating energy difference of both lambda edges") clear_directory(self.path) c_lambdas = self.settings.c_lambdas s_lambdas = self.settings.lj_lambdas if (len(c_lambdas) < 1): c_lambdas = self.settings.lambdas if (len(s_lambdas) < 1): s_lambdas = self.settings.lambdas first_lambda_value = 0. last_lambda_value = 1. if (self.settings.splitted_lambdas): if (self.alchemicalTemplateCreator.explicit_is_final): first_lambda_value = min(s_lambdas) last_lambda_value = max(c_lambdas) else: first_lambda_value = min(c_lambdas) last_lambda_value = max(s_lambdas) first_lambda = Lambda.Lambda(first_lambda_value, lambda_type=Lambda.DUAL_LAMBDA) last_lambda = Lambda.Lambda(last_lambda_value, lambda_type=Lambda.DUAL_LAMBDA) initial_energy = self._run(first_lambda) final_energy = self._run(last_lambda) print(" - Relative Unbound Free Energy prediction " + "{:.2f} kcal/mol".format(final_energy - initial_energy))
def run(self): self._start() clear_directory(self.settings.minimization_path) runner = PELERunner(self.settings.serial_pele, number_of_processors=1) copyFile(self.settings.initial_template, pele_co.HETEROATOMS_TEMPLATE_PATH) print(" - Calculating Free Energy of initial ligand with PELE") initial_ligand_energy = self._calculateSolvationFreeEnergy( runner, self.settings.initial_ligand_pdb) print(" Done") copyFile(self.settings.final_template, pele_co.HETEROATOMS_TEMPLATE_PATH) print(" - Calculating Free Energy of final ligand with PELE") final_ligand_energy = self._calculateSolvationFreeEnergy( runner, self.settings.final_ligand_pdb) print(" Done") result = final_ligand_energy - initial_ligand_energy print(" - Relative Solvation Free Energy prediction " + "{:.2f} kcal/mol".format(result)) self._finish()
def _calculateOriginalEnergies(self, simulation, lmb, gap=''): print("{} - Calculating original energies".format(gap)) path = self.path + lmb.path clear_directory(path) for report in simulation.iterateOverReports: self._originalEnergiesCalculator(path, report)
def run(self): self._start() clear_directory(self.path) if (self.settings.splitted_lambdas): self._run_with_splitted_lambdas() else: self._run(self.settings.lambdas) self._finish()
def run(self): self._start() create_directory(self.path) atoms_to_minimize = self._getAtomIdsToMinimize() for lmb in self.lambdas: writeLambdaTitle(lmb) create_directory(self.path + str(self.PID) + '_' + co.MODELS_FOLDER) print(" - Splitting PELE models") simulation = self._getSimulation(lmb) self._splitModels(simulation) ctt_lmb = None if (lmb.index == 2): if (lmb.type == Lambda.COULOMBIC_LAMBDA): ctt_lmb = Lambda.Lambda(1.0, lambda_type=Lambda.STERIC_LAMBDA) elif (lmb.type == Lambda.STERIC_LAMBDA): ctt_lmb = Lambda.Lambda( 1.0, lambda_type=Lambda.COULOMBIC_LAMBDA) self._createAlchemicalTemplate(lmb, ctt_lmb) self._calculateOriginalEnergies(simulation, lmb) for shf_lmb in self.sampling_method.getShiftedLambdas(lmb): print(" - Applying delta lambda " + str(round(shf_lmb.value - lmb.value, 5))) self._createAlchemicalTemplate(shf_lmb, ctt_lmb, gap=' ') general_path = self._getGeneralPath(lmb, shf_lmb) clear_directory(general_path) self._minimize(simulation, lmb.type, general_path, atoms_to_minimize, gap=' ') self._dECalculation(simulation, lmb, general_path, gap=' ') remove_directory(self.path + str(self.PID) + '_' + co.MODELS_FOLDER) self._finish()
def _run(self, lambdas, lambdas_type=Lambda.DUAL_LAMBDA, num=0, constant_lambda=None): lambdas = self.lambdasBuilder.build(lambdas, lambdas_type) atoms_to_minimize = self._getAtomIdsToMinimize() for lambda_ in lambdas: if (self.checkPoint.check( (self.name, str(num) + str(lambda_.type) + str(lambda_.value)))): continue writeLambdaTitle(lambda_) clear_directory(self.path + co.MODELS_FOLDER) print(" - Splitting PELE models") simulation = self._getSimulation(lambda_, num) self._splitModels(simulation) self._createAlchemicalTemplate(lambda_, constant_lambda) self._calculateOriginalEnergies(simulation, lambda_, num) clear_directory(self.path) for shif_lambda in self.sampling_method.getShiftedLambdas(lambda_): print(" - Applying delta lambda " + str(round(shif_lambda.value - lambda_.value, 5))) self._createAlchemicalTemplate(shif_lambda, constant_lambda, gap=' ') general_path = self._getGeneralPath(lambda_, num, shif_lambda) clear_directory(general_path) self._minimize(simulation, lambdas_type, general_path, atoms_to_minimize, gap=' ') self._dECalculation(simulation, lambda_, shif_lambda, general_path, num, gap=' ') self.checkPoint.save( (self.name, str(num) + str(lambda_.type) + str(lambda_.value))) clear_directory(self.path) return []
def _calculateOriginalEnergies(self, simulation, lambda_, num, gap=''): print("{} - Calculating original energies".format(gap)) path = self.path if (lambda_.type != Lambda.DUAL_LAMBDA): path += str(num) + '_' + lambda_.type + "/" path += lambda_.folder_name + '/' clear_directory(path) originalEnergiesCalculator = partial( self._parallelOriginalEnergiesCalculator, path) with Pool(self.settings.number_of_processors) as pool: pool.map(originalEnergiesCalculator, simulation.iterateOverReports)
def _minimize(self): path = self.settings.minimization_path clear_directory(path) self._writeMinimizationControlFile() runner = PELERunner(self.settings.serial_pele, number_of_processors=1) try: runner.run(self.settings.minimization_path + co.MINIMIZATION_CF_NAME) except SystemExit as exception: print("LambdasSimulation error: \n" + str(exception)) sys.exit(1)
def _minimize(self, runner, lambda_): clear_directory(self.settings.minimization_path) self._writeMinimizationControlFile(lambda_, self.path) try: output = runner.run(self.settings.minimization_path + co.MINIMIZATION_CF_NAME) except SystemExit as exception: print("UnboundLambdasSimulation error: \n" + str(exception)) sys.exit(1) for line in output.split('\n'): if line.startswith(pele_co.ENERGY_RESULT_LINE): energy = float(line.strip().split()[-1]) break else: print("Error: energy calculation failed") return energy
def _simulate(self, lmb, num): path = self.path if (lmb.type != Lambda.DUAL_LAMBDA): path += str(num) + '_' + lmb.type + "/" path += str(lmb.value) + "/" control_file_name = getFileFromPath(self.settings.sim_control_file) clear_directory(path) self._writeSimulationControlFile(path, control_file_name) runner = PELERunner( self.settings.mpi_pele, number_of_processors=self.settings.number_of_processors) try: runner.run(path + control_file_name) except SystemExit as exception: print("LambdasSimulation error: \n" + str(exception)) sys.exit(1)