) parms = {} parms['simulated_annealing_list4'] = simulated_annealing_list4 parms['genetic_algorithm_list4'] = genetic_algorithm_list4 parms[ 'genetic_algorithm_local_search_list4'] = genetic_algorithm_local_search_list4 parms['local_search_list4'] = local_search_list4 #what about nucleic acids??? DPO4 = DockingParameters() print("default: ligand_types=", DPO4['ligand_types']['value']) orig_compute_unbound_extended_flag = DPO4['compute_unbound_extended_flag'][ 'value'] if dpf3_filename: DPO4.read(dpf3_filename) if verbose: print('read ', dpf3_filename) DPO4['compute_unbound_extended_flag'][ 'value'] = orig_compute_unbound_extended_flag else: if verbose: print('using dpo defaults') DPO4.set_ligand(ligand_filename) DPO4.set_version("4.1") DPO4['set_sw1']['value'] = 0 DPO4['set_sw1_flag']['value'] = 0 DPO4['set_psw1']['value'] = 1 DPO4['set_psw1_flag']['value'] = 1 res = DPO4.set_ligand_types_from_filename(ligand_filename) if res == "ERROR": raise Exception('unreadable file' + ligand_filename) if verbose: print("ligand_types=", DPO4['ligand_types']['value'])
print "dpf3_to_dpf4: using default receptor_filename:", receptor_filename if not dpf3_filename: print 'dpf3_to_dpf4: no dpf3_filename specified using GridParameter defaults' parms= {} parms['simulated_annealing_list4'] = simulated_annealing_list4 parms['genetic_algorithm_list4'] = genetic_algorithm_list4 parms['genetic_algorithm_local_search_list4'] = genetic_algorithm_local_search_list4 parms['local_search_list4'] = local_search_list4 #what about nucleic acids??? DPO4 = DockingParameters() print "default: ligand_types=", DPO4['ligand_types']['value'] orig_compute_unbound_extended_flag = DPO4['compute_unbound_extended_flag']['value'] if dpf3_filename: DPO4.read(dpf3_filename) if verbose: print 'read ', dpf3_filename DPO4['compute_unbound_extended_flag']['value'] = orig_compute_unbound_extended_flag else: if verbose: print 'using dpo defaults' DPO4.set_ligand(ligand_filename) DPO4.set_version("4.1") DPO4['set_sw1']['value'] = 0 DPO4['set_sw1_flag']['value'] = 0 DPO4['set_psw1']['value'] = 1 DPO4['set_psw1_flag']['value'] = 1 res = DPO4.set_ligand_types_from_filename(ligand_filename) if res=="ERROR": raise 'unreadable file', ligand_filename if verbose: print "ligand_types=", DPO4['ligand_types']['value'] print 'set ligand to ', ligand_filename
# @@ from docking directory name @@ dpf_pathname = os.path.join(docking_pathname, docking_name) + ".dpf" dpf_filename = os.path.basename(dpf_pathname) # remove "faahNNNN_ from docking name gpf_pathname = os.path.join(docking_pathname, docking_name[9:]) + ".gpf" gpf_filename = os.path.basename(gpf_pathname) # # get filenames from the dpf and gpf # from AutoDockTools.DockingParameters import DockingParameters from AutoDockTools.GridParameters import GridParameters dpo = DockingParameters() log.info("reading dpf: %s" % dpf_pathname) dpo.read(dpf_pathname) ligand_filename = dpo["move"]["value"] ligand_pathname = os.path.join(docking_pathname, ligand_filename) log.info("ligand_filename: %s" % ligand_filename) log.debug("ligand_pathname: %s" % ligand_pathname) gpo = GridParameters() log.info("reading gpf: %s" % gpf_pathname) gpo.read(gpf_pathname) receptor_filename = gpo["receptor"]["value"] receptor_pathname = os.path.join(docking_pathname, receptor_filename) log.info("receptor_filename: %s" % receptor_filename) log.debug("receptor_pathname: %s" % receptor_pathname) # docking log pathnames dlg_pathname_list = glob.glob(os.path.join(docking_pathname, '*.dlg'))
class LibraryDpfWriter: def __init__(self, dpffile, extension='pdbq', \ err_file="write_lib_dpf_errors", prefix='', verbose=0): self.verbose = verbose if verbose: print("self.verbose = ", verbose) self.prefix = prefix self.setup(dpffile) self.parm_list_dict = {} self.parm_list_dict['GALS'] = genetic_algorithm_local_search_list self.parm_list_dict['GA'] = genetic_algorithm_list self.parm_list_dict['LS'] = local_search_list self.parm_list_dict['SA'] = simulated_annealing_list self.ligandfilenames = [] self.extension = extension self.error_file = open(err_file, 'w') def setup(self, dpffile): self.dpffile = dpffile self.dpo = DockingParameters() self.dpo.read(dpffile) def getligands(self, extension, name=''): typeDict = {} key = name + '*.' + extension self.ligandfilenames = glob.glob(key) return self.ligandfilenames def write(self, dpo, style='GALS'): #one file per ligand dpffiles = [] receptor_stem = self.dpo.receptor_stem parm_list = self.parm_list_dict[style] if not len(self.ligandfilenames): self.getligands(self.extension) #print "len(self.ligandfilenames)=", len(self.ligandfilenames) for ligand_file in self.ligandfilenames: #get the types typeDict = {} m = Read(ligand_file)[0] for a in m.allAtoms: typeDict[a.autodock_element] = 1 type_list = list(typeDict.keys()) #check that there is a map for each type ok = 1 for t in type_list: mapfile = receptor_stem + '.' + t + '.map' try: assert os.path.exists(mapfile) except: ok = 0 ostr = ligand_file + " missing map " + t + "\n" self.error_file.write(ostr) break #try to continue 'for' statement with next filename #update dpo with ligand specific values if not ok: if self.verbose: print("problem with ", ligand_file) continue types = string.join(type_list,'') self.dpo['move']['value'] = ligand_file if self.verbose: print("set types to ", types) self.dpo['types']['value'] = types #CAUTION: dpo['torsdof']['value'] is [0,0.3113] self.dpo['torsdof']['value'][0] = m.TORSDOF if hasattr(m, 'ndihe'): ndihe = m.ndihe elif hasattr(m, 'torscount'): ndihe = m.torscount elif hasattr(m, 'torTree'): ndihe = len(m.torTree.torsionMap) else: msg = ligand_file + " is not properly formatted: no torsions!" raise AttributeError(msg) self.dpo['ndihe']['value'] = ndihe outputfilename = self.prefix + m.name + "_" + style + ".dpf" if self.verbose: print("writing ", outputfilename) self.dpo.write(outputfilename, parm_list) dpffiles.append(outputfilename) return dpffiles
# @@ from docking directory name @@ dpf_pathname = os.path.join(docking_pathname, docking_name) + ".dpf" dpf_filename = os.path.basename(dpf_pathname) # remove "faahNNNN_ from docking name gpf_pathname = os.path.join(docking_pathname, docking_name[9:]) + ".gpf" gpf_filename = os.path.basename(gpf_pathname) # # get filenames from the dpf and gpf # from AutoDockTools.DockingParameters import DockingParameters from AutoDockTools.GridParameters import GridParameters dpo = DockingParameters() log.info("reading dpf: %s" % dpf_pathname) dpo.read(dpf_pathname) ligand_filename = dpo["move"]["value"] ligand_pathname = os.path.join(docking_pathname, ligand_filename) log.info ("ligand_filename: %s" % ligand_filename) log.debug("ligand_pathname: %s" % ligand_pathname) gpo = GridParameters() log.info("reading gpf: %s" % gpf_pathname) gpo.read(gpf_pathname) receptor_filename = gpo["receptor"]["value"] receptor_pathname = os.path.join(docking_pathname, receptor_filename) log.info ("receptor_filename: %s" % receptor_filename) log.debug("receptor_pathname: %s" % receptor_pathname) # docking log pathnames dlg_pathname_list = glob.glob(os.path.join( docking_pathname, '*.dlg'))
class LibraryDpfWriter: def __init__(self, dpffile, extension='pdbq', \ err_file="write_lib_dpf_errors", prefix='', verbose=0): self.verbose = verbose if verbose: print "self.verbose = ", verbose self.prefix = prefix self.setup(dpffile) self.parm_list_dict = {} self.parm_list_dict['GALS'] = genetic_algorithm_local_search_list self.parm_list_dict['GA'] = genetic_algorithm_list self.parm_list_dict['LS'] = local_search_list self.parm_list_dict['SA'] = simulated_annealing_list self.ligandfilenames = [] self.extension = extension self.error_file = open(err_file, 'w') def setup(self, dpffile): self.dpffile = dpffile self.dpo = DockingParameters() self.dpo.read(dpffile) def getligands(self, extension, name=''): typeDict = {} key = name + '*.' + extension self.ligandfilenames = glob.glob(key) return self.ligandfilenames def write(self, dpo, style='GALS'): #one file per ligand dpffiles = [] receptor_stem = self.dpo.receptor_stem parm_list = self.parm_list_dict[style] if not len(self.ligandfilenames): self.getligands(self.extension) #print "len(self.ligandfilenames)=", len(self.ligandfilenames) for ligand_file in self.ligandfilenames: #get the types typeDict = {} m = Read(ligand_file)[0] for a in m.allAtoms: typeDict[a.autodock_element] = 1 type_list = typeDict.keys() #check that there is a map for each type ok = 1 for t in type_list: mapfile = receptor_stem + '.' + t + '.map' try: assert os.path.exists(mapfile) except: ok = 0 ostr = ligand_file + " missing map " + t + "\n" self.error_file.write(ostr) break #try to continue 'for' statement with next filename #update dpo with ligand specific values if not ok: if self.verbose: print "problem with ", ligand_file continue types = string.join(type_list,'') self.dpo['move']['value'] = ligand_file if self.verbose: print "set types to ", types self.dpo['types']['value'] = types #CAUTION: dpo['torsdof']['value'] is [0,0.3113] self.dpo['torsdof']['value'][0] = m.TORSDOF if hasattr(m, 'ndihe'): ndihe = m.ndihe elif hasattr(m, 'torscount'): ndihe = m.torscount elif hasattr(m, 'torTree'): ndihe = len(m.torTree.torsionMap) else: msg = ligand_file + " is not properly formatted: no torsions!" raise AttributeError, msg self.dpo['ndihe']['value'] = ndihe outputfilename = self.prefix + m.name + "_" + style + ".dpf" if self.verbose: print "writing ", outputfilename self.dpo.write(outputfilename, parm_list) dpffiles.append(outputfilename) return dpffiles