if not ligand_filename:
        print('gpf4_to_gpf3: ligand_filename must be specified.')
        usage()
        sys.exit()
    if not receptor_filename:
        receptor_filename = gpf4_stem + '.pdbqs'
        print("gpf4_to_gpf3: using default receptor_filename:", receptor_filename)
    if not gpf4_filename:
        print('gpf4_to_gpf3: no gpf4_filename specified using GridParameter defaults')

    #what about nucleic acids???
    GPO3 = GridParameters()
    GPO3.read4(gpf4_filename)
    GPO3.read(gpf4_filename)
    if verbose: print('read ', gpf4_filename)
    #have to set the ligand_types
    GPO3.set_ligand(ligand_filename)
    #build an autogrid3 'types' string from autogrid4 ligand_types
    GPO3.set_ligand_types3(GPO3['ligand_types']['value'])
    if verbose: print('set ligand to  ', ligand_filename)
    GPO3.set_receptor(receptor_filename)
    if verbose: print('set receptor to  ', receptor_filename)
    if outputfilename is None:
        outputfilename = gpf4_stem + '_3.gpf'
    GPO3.write(outputfilename, grid_parameter_list)
    if verbose: 
        print("wrote ", outputfilename, ' using:')
        for p in grid_parameter_list:
            print(p)
Esempio n. 2
0
            sys.exit()

    if not ligand_filename:
        print 'gpf3_to_gpf4: ligand_filename must be specified.'
        usage()
        sys.exit()
    if not receptor_filename:
        receptor_filename = gpf3_stem + '.pdbqt'
        print "gpf3_to_gpf4: using default receptor_filename:", receptor_filename
    if not gpf3_filename:
        print 'gpf3_to_gpf4: no gpf3_filename specified using GridParameter defaults'

    #what about nucleic acids???
    GPO4 = GridParameters()
    if gpf3_filename:
        GPO4.read(gpf3_filename)
        if verbose: print 'read ', gpf3_filename
    else:
        if verbose: print 'using gpo defaults'
    GPO4.set_ligand4(ligand_filename)
    if verbose: print 'set ligand to  ', ligand_filename
    GPO4.set_receptor4(receptor_filename)
    if verbose: print 'set receptor to  ', receptor_filename
    if outputfilename is None:
        outputfilename = gpf3_stem + '_4.gpf'
    GPO4.write4(outputfilename, grid_parameter_list4)
    if verbose:
        print "wrote ", outputfilename, ' using:'
        for p in grid_parameter_list4:
            print p
    # 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'))

    # At this point, we have pathnames and filenames for all the
    # input and output files, start reading them
    ######################################################################

    # the ligand from the dpf
    dpf_ligand = Read(ligand_pathname)[0]
Esempio n. 4
0
class LibraryGpfWriter:

    def __init__(self, gpffile, extension='pdbq', err_file="write_lib_gpf_errors",
                           prefix='',alltypes=None, extratypes_dict={}, verbose=0):
        self.verbose = verbose
        if verbose: print("self.verbose = ", verbose)
        self.extratypes_dict = extratypes_dict
        self.setup(gpffile)
        self.alltypes = alltypes
        if self.alltypes is None:
            self.alltypes = self.gettypes(extension)
        self.prefix = prefix
        #real element, Rii, epsii
        #eg {X:['Cl', 4.09, .02345]}
        #WHAT errors should be captured
        #self.error_file = open(err_file, 'w')


    def setup(self,gpffile):
        self.gpffile = gpffile
        self.gpo = GridParameters()
        self.gpo.read(gpffile)
        if len(self.extratypes_dict):
            print("update each type in extratypes here")
        #????RENAME extratype in receptor and write new output file here?


    def set_receptor(self, receptor_filename):
        self.gpo.set_receptor(receptor_filename)
        ty


    def gettypes(self, extension, name=''):
        typeDict = {}
        key = name + '*.' + extension
        ligandfilenames = glob.glob(key)
        if self.verbose:
            print("processing ", len(ligandfilenames), " files matching ", key)
        for ligand_file in ligandfilenames:
            m = Read(ligand_file)[0]
            for a in m.allAtoms:
                typeDict[a.autodock_element] = 1
            del(m)
        alltypes = list(typeDict.keys())
        return alltypes


    def write(self, gpo):
        #set types in groups of 6 + write
        outputlist = []
        number_of_files = len(self.alltypes)/6 + 1
        ctr = 0
        last = 6
        for i in range(number_of_files):
            if i == number_of_files-1:
                current_types = self.alltypes[ctr*6:]
            elif last>len(self.alltypes):
                current_types = self.alltypes[ctr*6:]
            else:
                current_types = self.alltypes[ctr*6:last]
            gpo['types']['value'] =  string.join(current_types,'')
            if not gpo.receptor_stem:
                gpo.receptor_stem = os.path.splitext(gpo['receptor']['value'])[0]
            outputfilename = self.prefix + gpo.receptor_stem + '_'+ str(ctr) + '_library.gpf'
            gpo.write(outputfilename, grid_parameter_list)
            ctr = ctr + 1
            last = last + 6
            outputlist.append(outputfilename)
        return outputlist
    # 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'))

    # At this point, we have pathnames and filenames for all the
    # input and output files, start reading them
    ######################################################################
   
    # the ligand from the dpf
    dpf_ligand = Read(ligand_pathname)[0]
Esempio n. 6
0

    if not ligand_filename:
        print 'gpf3_to_gpf4: ligand_filename must be specified.'
        usage()
        sys.exit()
    if not receptor_filename:
        receptor_filename = gpf3_stem + '.pdbqt'
        print "gpf3_to_gpf4: using default receptor_filename:", receptor_filename
    if not gpf3_filename:
        print 'gpf3_to_gpf4: no gpf3_filename specified using GridParameter defaults'

    #what about nucleic acids???
    GPO4 = GridParameters()
    if gpf3_filename:
        GPO4.read(gpf3_filename)
        if verbose: print 'read ', gpf3_filename
    else:
        if verbose: print 'using gpo defaults'
    GPO4.set_ligand4(ligand_filename)
    if verbose: print 'set ligand to  ', ligand_filename
    GPO4.set_receptor4(receptor_filename)
    if verbose: print 'set receptor to  ', receptor_filename
    if outputfilename is None:
        outputfilename = gpf3_stem + '_4.gpf'
    GPO4.write4(outputfilename, grid_parameter_list4)
    if verbose: 
        print "wrote ", outputfilename, ' using:'
        for p in grid_parameter_list4:
            print p
    
Esempio n. 7
0

    if not ligand_filename:
        print 'gpf4_to_gpf3: ligand_filename must be specified.'
        usage()
        sys.exit()
    if not receptor_filename:
        receptor_filename = gpf4_stem + '.pdbqs'
        print "gpf4_to_gpf3: using default receptor_filename:", receptor_filename
    if not gpf4_filename:
        print 'gpf4_to_gpf3: no gpf4_filename specified using GridParameter defaults'

    #what about nucleic acids???
    GPO3 = GridParameters()
    GPO3.read4(gpf4_filename)
    GPO3.read(gpf4_filename)
    if verbose: print 'read ', gpf4_filename
    #have to set the ligand_types
    GPO3.set_ligand(ligand_filename)
    #build an autogrid3 'types' string from autogrid4 ligand_types
    GPO3.set_ligand_types3(GPO3['ligand_types']['value'])
    if verbose: print 'set ligand to  ', ligand_filename
    GPO3.set_receptor(receptor_filename)
    if verbose: print 'set receptor to  ', receptor_filename
    if outputfilename is None:
        outputfilename = gpf4_stem + '_3.gpf'
    GPO3.write(outputfilename, grid_parameter_list)
    if verbose: 
        print "wrote ", outputfilename, ' using:'
        for p in grid_parameter_list:
            print p
class LibraryGpfWriter:

    def __init__(self, gpffile, extension='pdbq', err_file="write_lib_gpf_errors", 
                           prefix='',alltypes=None, extratypes_dict={}, verbose=0):
        self.verbose = verbose
        if verbose: print "self.verbose = ", verbose
        self.extratypes_dict = extratypes_dict
        self.setup(gpffile)
        self.alltypes = alltypes
        if self.alltypes is None:
            self.alltypes = self.gettypes(extension)
        self.prefix = prefix
        #real element, Rii, epsii
        #eg {X:['Cl', 4.09, .02345]}
        #WHAT errors should be captured
        #self.error_file = open(err_file, 'w')
    

    def setup(self,gpffile):
        self.gpffile = gpffile
        self.gpo = GridParameters() 
        self.gpo.read(gpffile)
        if len(self.extratypes_dict):
            print "update each type in extratypes here"
        #????RENAME extratype in receptor and write new output file here?


    def set_receptor(self, receptor_filename):
        self.gpo.set_receptor(receptor_filename)
        ty


    def gettypes(self, extension, name=''):
        typeDict = {}
        key = name + '*.' + extension
        ligandfilenames = glob.glob(key)
        if self.verbose:
            print "processing ", len(ligandfilenames), " files matching ", key
        for ligand_file in ligandfilenames:
            m = Read(ligand_file)[0]
            for a in m.allAtoms:
                typeDict[a.autodock_element] = 1
            del(m)
        alltypes = typeDict.keys()
        return alltypes


    def write(self, gpo):
        #set types in groups of 6 + write
        outputlist = []
        number_of_files = len(self.alltypes)/6 + 1
        ctr = 0
        last = 6
        for i in range(number_of_files):
            if i == number_of_files-1:
                current_types = self.alltypes[ctr*6:]
            elif last>len(self.alltypes):
                current_types = self.alltypes[ctr*6:]
            else:
                current_types = self.alltypes[ctr*6:last]
            gpo['types']['value'] =  string.join(current_types,'')
            if not gpo.receptor_stem:
                gpo.receptor_stem = os.path.splitext(gpo['receptor']['value'])[0]
            outputfilename = self.prefix + gpo.receptor_stem + '_'+ str(ctr) + '_library.gpf'
            gpo.write(outputfilename, grid_parameter_list)
            ctr = ctr + 1
            last = last + 6
            outputlist.append(outputfilename)
        return outputlist