コード例 #1
0
 def test_write(self):
     """
     test writing a pdbqs file
     """
     writer = PdbqtWriter()
     writer.write('test_pdbqtWriter.pdbqt', self.mol, bondOrigin=('File',))
     ans, errors = self.compare('Data/hsg1.pdbqt', 'test_pdbqtWriter.pdbqt') 
     self.assertEquals(errors, None)
     self.assertEquals(ans, True)
コード例 #2
0
        if o in ('-h', '--'):
            usage()
            sys.exit()

    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)
コード例 #3
0
            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 charges_to_add is not None:
        #restore any previous charges
        for atom, chargeList in preserved.items():
            atom._charges[chargeList[0]] = chargeList[1]
            atom.chargeSet = chargeList[0]

    #pdbqt_filename = mol.name + '.pdbqt'
    writer = PdbqtWriter()
    fptr = open(pdbqt_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", pdbqt_filename
    

# To execute this command type:
コード例 #4
0
            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 charges_to_add is not None:
        #restore any previous charges
        for atom, chargeList in list(preserved.items()):
            atom._charges[chargeList[0]] = chargeList[1]
            atom.chargeSet = chargeList[0]

    #pdbqt_filename = mol.name + '.pdbqt'
    writer = PdbqtWriter()
    fptr = open(pdbqt_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", pdbqt_filename)

# To execute this command type:
# pdbqs_to_pdbqt.py -s pdbqs_filename_stem  -v
コード例 #5
0
            usage()
            sys.exit()


    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 = Numeric.add.reduce(mol.allAtoms.coords)/len(mol.allAtoms)
    crds = Numeric.array(mol.allAtoms.coords)
    center = Numeric.add.reduce(crds)/len(mol.allAtoms)
    crds = crds - center
    crds = crds.tolist()
    mol.allAtoms.updateCoords(crds)