def test_write(self): """ test writing a pdbqs file """ writer = PdbqsWriter() writer.write('test_pdbqsWriter.pdbqs', self.mol, bondOrigin=('File',)) ans, errors = self.compare('Data/1crn.pdbqs', 'test_pdbqsWriter.pdbqs') self.assertEquals(errors, None) self.assertEquals(ans, True)
if not filename: print('rotate_molecule: filename must be specified.') usage() sys.exit() mol = Read(filename)[0] if verbose: print('read ', filename) filetype = os.path.splitext(os.path.basename(filename))[1] if verbose: print("filetype=", filetype) writer = None if filetype == '.pdbqt': writer = PdbqtWriter() elif filetype == '.pdbq': writer = PdbqWriter() elif filetype == '.pdbqs': writer = PdbqsWriter() elif filetype == '.pdb': writer = PdbWriter() else: print('Sorry! Unable to write this filetype->', filetype) center = numpy.add.reduce(mol.allAtoms.coords) / len(mol.allAtoms) crds = numpy.array(mol.allAtoms.coords) center = numpy.add.reduce(crds) / len(mol.allAtoms) crds = crds - center crds = crds.tolist() mol.allAtoms.updateCoords(crds) lenCoords = len(crds) #rotate the atoms here if axis is not None and angle is not None: rot = (float(angle) * 3.14159 / 180.) % (2 * numpy.pi)
mols = Read(pdbqt_filename) if verbose: print "read ", pdbqt_filename mol = mols[0] # fix number for problem files with alternative positions mol.allAtoms.number = range(1, len(mol.allAtoms) + 1) # possible clean-up??? # need to type atoms + assign babel_types solparer = SolvationParameterizer() solparer.addParameters(mol.allAtoms) if verbose: print "set autodock3 solvation parameters for ", mol.name # pdbqs_filename = mol.name + '.pdbqs' writer = PdbqsWriter() fptr = open(pdbqs_filename, "w") ctr = 0 for line in mol.parser.allLines: if find(line, "ATOM") < 0 and find(line, "HETA") < 0: fptr.write(line) else: this_atom = mol.allAtoms[ctr] writer.write_atom(fptr, this_atom) ctr = ctr + 1 fptr.close() if verbose: print "wrote ", ctr, " atoms to", pdbqs_filename # To execute this command type:
if len(item.name) == 1: item.name = 'A' else: item.name = 'A' + item.name[1:] elif hasattr(item, 'autodock_element'): item.autodock_element = item.autodock_element if splitAcceptors and item.autodock_element in self.acceptorList: #if item has a bond to a hydrogen: # change acceptor type 'XA' to 'XB' for 'B'oth 'A'cceptor and 'D'onor if 'H' in item.bonds.getAtoms().element: #O->OB;N->NB;S->SB item.autodock_element = item.element + 'B' d[item.autodock_element] = 1 type_list = d.keys() type_list.sort() mol.types = type_list if __name__ == "__main__": from MolKit import Read m = Read("/mgl/work4/rhuey/dev23/hsg1_no_conects.pdbq")[0] solP = SolvationParameterizer() ll = solP.addParameters(m.allAtoms) #NB: hydrogens get 0.0 0.0 print "len(notfound) = ", len(ll) for i in ll: print i.full_name(), from MolKit.pdbWriter import PdbqsWriter writer = PdbqsWriter() writer.write("/mgl/work4/rhuey/dev23/test_hsg1.pdbqs", m.allAtoms)
mols = Read(pdbqt_filename) if verbose: print 'read ', pdbqt_filename mol = mols[0] #fix number for problem files with alternative positions mol.allAtoms.number = range(1, len(mol.allAtoms) + 1) #possible clean-up??? #need to type atoms + assign babel_types solparer = SolvationParameterizer() solparer.addParameters(mol.allAtoms) if verbose: print "set autodock3 solvation parameters for ", mol.name #pdbqs_filename = mol.name + '.pdbqs' writer = PdbqsWriter() fptr = open(pdbqs_filename, 'w') ctr = 0 for line in mol.parser.allLines: if find(line, 'ATOM') < 0 and find(line, "HETA") < 0: fptr.write(line) else: this_atom = mol.allAtoms[ctr] writer.write_atom(fptr, this_atom) ctr = ctr + 1 fptr.close() if verbose: print "wrote ", ctr, " atoms to", pdbqs_filename # To execute this command type: # pdbqt_to_pdbqs.py -s pdbqt_filename_stem -v
item.name = 'A' else: item.name = 'A' + item.name[1:] elif hasattr(item, 'autodock_element'): item.autodock_element = item.autodock_element if splitAcceptors and item.autodock_element in self.acceptorList: #if item has a bond to a hydrogen: # change acceptor type 'XA' to 'XB' for 'B'oth 'A'cceptor and 'D'onor if 'H' in item.bonds.getAtoms().element: #O->OB;N->NB;S->SB item.autodock_element = item.element + 'B' d[item.autodock_element] = 1 type_list = d.keys() type_list.sort() mol.types = type_list if __name__ == "__main__": from MolKit import Read m = Read("/mgl/work4/rhuey/dev23/hsg1_no_conects.pdbq")[0] solP = SolvationParameterizer() ll = solP.addParameters(m.allAtoms) #NB: hydrogens get 0.0 0.0 print "len(notfound) = ", len(ll) for i in ll: print i.full_name(), from MolKit.pdbWriter import PdbqsWriter writer = PdbqsWriter() writer.write("/mgl/work4/rhuey/dev23/test_hsg1.pdbqs", m.allAtoms)