def set_types_from_directory(self, directory): if self.verbose: print("reading directory ", directory) filelist = glob.glob(directory + "/*.pdb*") if self.verbose: print("len(filelist)=", len(filelist)) ad4_typer = AutoDock4_AtomTyper() type_dict = {} all_types = "" for f in filelist: ftype = os.path.splitext(f)[-1] if ftype != ".pdbqt": print("skipping ", f, " not in PDBQT format!") continue m = Read(f)[0] m_types = "" m_types = " ".join(list(set(m.allAtoms.autodock_element))) self.getSideLengths(m) # sets ligand.center npts = m.npts # only make the box bigger, do NOT make it smaller for ix, val in enumerate(self.gpo['npts']['value']): if npts[ix] > val: self.gpo['npts']['value'][ix] = npts[ix] if self.verbose: print(m.name, " increased grid dimension ", ix, " to ", npts[ix]) all_types = all_types + m_types if self.verbose: print("added ", m_types, " atom types in directory ", directory) print("end: all_types = ", all_types) self.gpo['ligand_types']['value'] = all_types if self.verbose: print("all ligand_types for ", directory, "= ", self.gpo['ligand_types']['value'])
def set_types_from_directory(self, directory): if self.verbose: print "reading directory ", directory filelist = glob.glob(directory + "/*.pdb*") if self.verbose: print "len(filelist)=", len(filelist) ad4_typer = AutoDock4_AtomTyper() type_dict = {} for f in filelist: m = Read(f)[0] m.buildBondsByDistance() ad4_typer.setAutoDockElements(m) for a in m.allAtoms: type_dict[a.autodock_element] = 1 self.getSideLengths(m) #sets ligand.center npts = m.npts #only make the box bigger, do NOT make it smaller for ix, val in enumerate(self.gpo['npts']['value']): if npts[ix] > val: self.gpo['npts']['value'][ix] = npts[ix] if self.verbose: print m.name, " increased grid dimension ", ix, " to ", npts[ ix] d_types = type_dict.keys() if self.verbose: print "found ", d_types, " atom types in directory ", directory self.gpo['ligand_types']['value'] = string.join(d_types) if self.verbose: print "now ligand_types is ", self.gpo['ligand_types']['value']
def getTypes(self, molecule): if not len(molecule.allAtoms.bonds[0]): molecule.buildBondsByDistance() ad4_typer = AutoDock4_AtomTyper(verbose=self.verbose) ad4_typer.setAutoDockElements(molecule) dict = {} for a in molecule.allAtoms: dict[a.autodock_element] = 1 d_types = dict.keys() d_types.sort() mol_types = d_types[0] for t in d_types[1:]: mol_types = mol_types + " " + t if self.verbose: print "end of getTypes: types=", mol_types, ' class=', mol_types.__class__ return mol_types
def set_ligand4(self, ligand_filename, types=None): #this should set ligand_types #print "in set_ligand4: types=", types if types is None: ligand = Read(ligand_filename)[0] ligand.buildBondsByDistance() ad4_typer = AutoDock4_AtomTyper() ad4_typer.setAutoDockElements(ligand) dict = {} for a in ligand.allAtoms: dict[a.autodock_element] = 1 d_types = dict.keys() d_types.sort() types = d_types[0] for t in d_types[1:]: types = types + " " + t self['ligand_types']['value'] = types #print "set_ligand4: self['ligand_types']['value']=", self['ligand_types']['value'] self.ligand_filename = os.path.basename(ligand_filename) #print "GPO: set ligand_filename to ", self.ligand_filename self.ligand_stem = os.path.splitext(self.ligand_filename)[0]
def set_receptor4(self, receptor_filename, types=None): #this should set receptor_types if types is None: receptor = Read(receptor_filename)[0] receptor.buildBondsByDistance() ad4_typer = AutoDock4_AtomTyper() ad4_typer.setAutoDockElements(receptor) dict = {} for a in receptor.allAtoms: dict[a.autodock_element] = 1 d_types = dict.keys() d_types.sort() types = d_types[0] for t in d_types[1:]: types = types + " " + t self['receptor_types']['value'] = types basename = os.path.basename(receptor_filename) self.receptor_filename = basename self.receptor_stem = os.path.splitext(basename)[0] if receptor_filename != '': self['receptor']['value'] = basename self['gridfld']['value'] = self.receptor_stem + '.maps.fld' self['elecmap']['value'] = self.receptor_stem + '.e.map' self['dsolvmap']['value'] = self.receptor_stem + '.d.map'
sys.exit() if not pdbqs_filename: print('pdbqs_to_pdbqt: pdbqs_filename_stem must be specified.') usage() sys.exit() #what about nucleic acids??? mols = Read(pdbqs_filename) if verbose: print('read ', pdbqs_filename) mol = mols[0] #fix number for problem files with alternative positions mol.allAtoms.number = list(range(1, len(mol.allAtoms) + 1)) #possible clean-up??? #need to type atoms + assign babel_types AD4_typer = AutoDock4_AtomTyper(set_aromatic_carbons=False) AD4_typer.setAutoDockElements(mol) if verbose: print("set autodock4 autodock_element for ", mol.name) if charges_to_add is not None: preserved = {} preserved_types = preserve_charge_types.split(',') for t in preserved_types: if not len(t): continue ats = mol.allAtoms.get(lambda x: x.autodock_element == t) for a in ats: if a.chargeSet is not None: preserved[a] = [a.chargeSet, a.charge] if charges_to_add == 'gasteiger': GasteigerChargeCalculator().addCharges(mol.allAtoms)
if not pdbq_filename: print('pdbq_to_pdbqt: stem of pdbq_filename must be specified.') usage() sys.exit() #what about nucleic acids??? mols = Read(pdbq_filename) if verbose: print('read ', pdbq_filename) mol = mols[0] mol.buildBondsByDistance() #possible clean-up??? #need to type atoms + assign babel_types AD4_typer = AutoDock4_AtomTyper() AD4_typer.setAutoDockElements(mol) if verbose: print("set autodock4 autodock_element for ", mol.name) writer = PdbqtWriter() fptr = open(pdbqt_filename, 'w') ctr = 0 for line in mol.parser.allLines: #for at in mol.allAtoms: if find(line, 'ATOM') < 0 and find(line, "HETA") < 0: fptr.write(line) else: name = strip(line[12:16]) #ats = mol.allAtoms.get(lambda x: x.name==name) ##there could be (?) two atoms with the same name