def getDeltaEnergyValuesByFile(self): files = get_all_files_from_with_extension(self.path, 'out') energies_by_file = {} for file in files: report = Report( getPathFromFile(file), getFileFromPath(file), '_'.join(getFileFromPath(file).split('_')[:-1]) + '_', None) dEs = self._getDeltaEnergiesFromReport(report) energies_by_file[file] = dEs return energies_by_file
def _getAllAlchemicalBondsInfo(self, lambda_, constant_lambda, link): bonds = [] lengths = [] f_indexes = [] core_atoms = self.alchemicalTemplateCreator.getCoreAtoms() template_atoms = self.ligand_template.list_of_atoms # Bonds need to be retrived from the current template # (may be modified) current_template = TemplateOPLS2005( self.settings.general_path + pele_co.HETEROATOMS_TEMPLATE_PATH + getFileFromPath(self.ligand_template.path_to_template)) list_of_bonds = current_template.list_of_bonds for ((atom_id1, atom_id2), bond) in \ self.ligand_template.get_list_of_fragment_bonds(): atom1 = template_atoms[atom_id1] atom2 = template_atoms[atom_id2] # Select the bond in the template that contains information about # the current state of the bond bond = list_of_bonds[(atom_id1, atom_id2)] bonds.append((atom1.pdb_atom_name, atom2.pdb_atom_name)) lengths.append(bond.eq_dist) f_indexes.append(self._getFixedIndex(atom1, atom2, core_atoms)) self.alchemicalTemplateCreator.reset() return bonds, lengths, f_indexes
def getDeltaEnergyValues(self): if (self.__delta_energies is not None): return self.__delta_energies files = get_all_files_from_with_extension(self.path, 'out') energies = [] for file in files: report = Report( getPathFromFile(file), getFileFromPath(file), '_'.join(getFileFromPath(file).split('_')[:-1]) + '_', None) energies += self._getDeltaEnergiesFromReport(report) self.__delta_energies = energies return energies
def _writeMinimizationControlFile(self): cf_creator = ControlFileFromTemplateCreator( self.settings.min_control_file) cf_creator.replaceFlag("INPUT_PDB_NAME", self.settings.input_pdb) cf_creator.replaceFlag("SOLVENT_TYPE", self.settings.solvent_type) cf_creator.replaceFlag( "LOG_PATH", self.settings.minimization_path + co.SINGLE_LOGFILE_NAME) cf_creator.replaceFlag( "TRAJECTORY_PATH", self.settings.minimization_path + getFileFromPath(self.settings.input_pdb)) cf_creator.write(self.settings.minimization_path + co.MINIMIZATION_CF_NAME)
def _writeControlFile(self, input_pdb_name, solvent_type): cf_creator = ControlFileFromTemplateCreator( self.settings.pp_control_file) cf_creator.replaceFlag("INPUT_PDB_NAME", input_pdb_name) cf_creator.replaceFlag("SOLVENT_TYPE", solvent_type) cf_creator.replaceFlag( "LOG_PATH", self.settings.minimization_path + co.LOGFILE_NAME.format('')) cf_creator.replaceFlag( "TRAJECTORY_PATH", self.settings.minimization_path + getFileFromPath(input_pdb_name) + '.pdb') cf_creator.write(self.settings.minimization_path + co.MINIMIZATION_CF_NAME)
def _writeSimulationControlFile(self, path, name): cf_creator = ControlFileFromTemplateCreator( self.settings.sim_control_file) cf_creator.replaceFlag( "INPUT_PDB_NAME", self.settings.minimization_path + getFileFromPath(self.settings.input_pdb)) cf_creator.replaceFlag("SOLVENT_TYPE", self.settings.solvent_type) cf_creator.replaceFlag("LOG_PATH", path + co.SINGLE_LOGFILE_NAME) cf_creator.replaceFlag("REPORT_PATH", path + co.SINGLE_REPORT_NAME) cf_creator.replaceFlag("TRAJECTORY_PATH", path + co.SINGLE_TRAJECTORY_NAME) cf_creator.replaceFlag("SEED", random.randint(0, 999999)) cf_creator.replaceFlag("TOTAL_PELE_STEPS", self.settings.total_PELE_steps) cf_creator.write(path + name)
def _preparePDB(self, pdb_path, general_path, lambda_, shif_lambda, constant_lambda): if ((shif_lambda.type == Lambda.DUAL_LAMBDA) or (shif_lambda.type == Lambda.STERIC_LAMBDA)): pdb = PDBParser(pdb_path) link = pdb.getLinkWithId(self._getPerturbingLinkId()) modifier = PDBModifier(pdb) modifier.setLinkToModify(link, self.ligand_template) bonds, lengths, f_indexes = self._getAllAlchemicalBondsInfo( lambda_, constant_lambda, link) for bond, length, f_index in zip(bonds, lengths, f_indexes): modifier.modifyBond(bond, length, f_index) modifier.write(general_path + getFileFromPath(pdb_path)) else: copyFile(pdb_path, general_path)
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)
def final_template_name(self): return getFileFromPath(self.__final_template)
def initial_template_name(self): return getFileFromPath(self.__initial_template)
def _getEnergiesFrom(self, path): report = Report(getPathFromFile(path), getFileFromPath(path), '_'.join(getFileFromPath(path).split('_')[:-1]) + '_', None) return report.getMetric(co.PP_ABSOLUTE_ENERGIES_COL)