def find_similar_atomtype_params(cls, atom_type, tried): """ :Description: If some atom_type is not found in the SGB_paramaters() func the param/similarity.param is parsed to look for the next most similar atom type. If that is not found as well, we append the tried atom_types to tried [] for efficiency and keep looking for other similar atom types. :Input: -atom_type: atom_type of the atom not found. - tried: similar atom_types that we try to obtain its parameters but they are not contained in the f14_sgbnp.param file. :Output: - new_params: [ similar_atom_type, SGB_radius, Van der Waals radius, Solvatation gamma factor, Solvatation alpha factor ] """ new_atom_type = False similarity = 0 #Search for the most similar atom lines = preproces_file_lines(SIMILARITY_PATH) for line in lines: line = line.split() if (line[0] == atom_type and float(line[2]) > float(similarity) and line[1] not in tried): similarity = line[2] new_atom_type = line[1] elif (line[1] == atom_type and float(line[2]) > float(similarity) and line[0] not in tried): similarity = line[2] new_atom_type = line[0] if new_atom_type: tried.append(new_atom_type) lines = preproces_file_lines(PARAM_PATH) for line in lines: if not line.startswith('#'): line = line.split() atom_type_file = line[1] if (atom_type == atom_type_file): return (line) new_params = cls.find_similar_atomtype_params(new_atom_type, tried) return new_params else: return []
def retrieve_atom_names(OPLS_CONVERSION_FILE): """ :Description: parse the param.data and retrieve the atom names of the molecule :Input: OPLS_CONVERSION_FILE: ffldserver output file cointaining the system parameters :Output: atom_names: Atom_names of the systems :Author: Daniel Soler """ atom_names = [] lines = preproces_file_lines(OPLS_CONVERSION_FILE) start_found_NBND = False for line in lines: if not line.startswith("----------"): if (line.startswith("atom type vdw")): start_found_NBND = True elif (start_found_NBND): try: line = line.split() atom_names.append(line[0]) except IndexError: return atom_names
def SGB_paramaters(cls, atom_types, tried=[]): """ :Description: Parse the param/f14_sgbnp.param file to obtain all the SGB Nonbonded parameters to build the template file. If some atom_type is not found the param/similarity.param is parsed to look for the next most similar atom type. If that is not found as well, we append the tried atom_types to tried [] for efficiency and keep looking for other similar atom types. :Arguments: - atom_types: atom_types of the system - tried: atom_types that we try to obtain its parameters but they are not contained in the f14_sgbnp.param file. :Returns: - radius: Atoms SGB radius - vdw_r: Atoms Van der Waals - gammas: Atoms gamma solvatation factor - alphas: Atoms alpha solvatation factor For more information on this parameters refer to the PELE documentation. Example with one atom_type (ONN): 1- We look whether or not its in the conversion atom dictionary 1.1- If it is we change the atom type to the one in the dict 2- We search the SGB parameters in the PARAM_PATH file 2.1- If found return them separately 2.2 -If not found call find_similar_atomtype_params to look for similar atom types parameters 3- We return the similar SGB parameters or a default if they were not found :Author: Daniel Soler """ radius = [] vdw_r = [] gammas = [] alphas = [] lines = preproces_file_lines(PARAM_PATH) for atom_type in atom_types: if atom_type in CONVERSION: atom_type = CONVERSION[atom_type] found = False for line in lines: if not line.startswith('#'): line = line.split() atom_type_file = line[1] if (atom_type == atom_type_file): radius.append(line[4]) vdw_r.append(line[5]) gammas.append(line[6]) alphas.append(line[7]) found = True break if not found: new_params = cls.find_similar_atomtype_params(atom_type, tried=[]) if (new_params): radius.append(new_params[4]) vdw_r.append(new_params[5]) gammas.append(new_params[6]) alphas.append(new_params[7]) # warnings.warn("Paramaters of {} used for {}.".format( # new_params[1], atom_type)) else: # warnings.warn("Defaults Paramaters used for{}.".format(atom_type)) radius.append(DEFAULT_ATOMTYPE[2]) vdw_r.append(DEFAULT_ATOMTYPE[3]) gammas.append(DEFAULT_ATOMTYPE[4]) alphas.append(DEFAULT_ATOMTYPE[5]) return (radius, vdw_r, gammas, alphas)