示例#1
0
def make_pfunc_factory(conf_space, ffparams, numcores, eps, algo_index,
                       emat_cache_pattern, data):
    """make_pfunc_factory

    Return a PartitionFunctionFactory object for the input confspace, which we can use to make
    partition functions for various sequences.
    """
    parallelism = osprey.Parallelism(cpuCores=numcores)
    data['numCpus'] = numcores

    # how should we compute energies of molecules?
    minimizingEcalc = osprey.EnergyCalculator(conf_space,
                                              ffparams,
                                              parallelism=parallelism,
                                              isMinimizing=True)
    # Compute reference energies
    eref = osprey.ReferenceEnergies(conf_space, minimizingEcalc)

    #Create a minimizing energy calculator
    confEcalcMinimized = osprey.ConfEnergyCalculator(conf_space,
                                                     minimizingEcalc,
                                                     referenceEnergies=eref)

    # we need rigid energies too for many algorithms
    rigidEcalc = osprey.SharedEnergyCalculator(minimizingEcalc,
                                               isMinimizing=False)
    rigidConfEcalc = osprey.ConfEnergyCalculatorCopy(confEcalcMinimized,
                                                     rigidEcalc)
    confEcalcRigid = rigidConfEcalc

    # Specify the type of partitionFunction
    if ALGO_LIST[algo_index] == 'SHARK':  # using SHARK*
        impt_ecalc = rigidConfEcalc
        choose_markstar = False
    elif ALGO_LIST[algo_index] == 'MARK':  # using MARK*
        impt_ecalc = rigidConfEcalc
        choose_markstar = True
    else:  # using Gradient descent pfunc
        impt_ecalc = None
        choose_markstar = False

    pfuncFactory = osprey.PartitionFunctionFactory(
        conf_space,
        confEcalcMinimized,
        emat_cache_pattern,
        confUpperBoundcalc=impt_ecalc,
        useMARK=choose_markstar)
    # Set cache pattern
    pfuncFactory.setCachePattern(
        '%s/emat.%s.%s' % (XTMP_DIR, emat_cache_pattern, data["design name"]))
    print('Cache pattern: %s/emat.%s.%s' %
          (XTMP_DIR, emat_cache_pattern, data["design name"]))

    return pfuncFactory
示例#2
0
def makeo_emat(confspace, ffparams, parallelism, fo, continuous=False):
    """Save energy matrix based on OSPREY objects"""
    ecalc = osprey.EnergyCalculator(confspace,
                                    ffparams,
                                    parallelism,
                                    isMinimizing=continuous)
    eref = osprey.ReferenceEnergies(confspace, ecalc)
    conf_ecalc = osprey.ConfEnergyCalculator(confspace,
                                             ecalc,
                                             referenceEnergies=eref)
    emat = osprey.EnergyMatrix(conf_ecalc, cacheFile=fo)
示例#3
0
def setup_design(numcores, conf_spaces, eps, num_seqs, algo_index, data):
    """setup_design

    Set up the classes required to run the design

    conf_spaces: A dictionary containing protein, ligand, and complex conf
    spaces along with force-field parameters
    num_seqs:   The number of top sequences we want (usually 5)

    Returns a BBKStar instance, ready to run
    """

    parallelism = osprey.Parallelism(cpuCores=numcores)
    data['numCpus'] = numcores

    # how should we compute energies of molecules?
    minimizingEcalc = osprey.EnergyCalculator(conf_spaces['complex'],
                                              conf_spaces['ffparams'],
                                              parallelism=parallelism,
                                              isMinimizing=True)
    # record the seq tree file name
    data['seq_tree_name'] = data["design name"] + "seqTree.tree"

    # configure basic inputs for SHARKStar
    design = osprey.BBKStar(
        conf_spaces['protein'],
        conf_spaces['ligand'],
        conf_spaces['complex'],
        numBestSequences=num_seqs,
        epsilon=
        eps,  # you proabably want something more precise in your real designs
        showPfuncProgress=True,
        maxSimultaneousMutations=9,
        numConfsPerBatch=BBK_BATCH_SIZE,
        maxNumConfsPerBatch=8,
        #printSequenceTree=data["seq_tree_name"]
    )

    # configure SHARK*/BBK* inputs for each conf space
    configure_bbk(design, minimizingEcalc, "shark", data["design name"],
                  algo_index)

    return design
示例#4
0
    osprey.WILD_TYPE).addWildTypeRotamers().setContinuous()
ligand.flexibility['A42'].setLibraryRotamers(
    osprey.WILD_TYPE, 'THR', 'LYS').addWildTypeRotamers().setContinuous()
ligand.flexibility['A45'].setLibraryRotamers(
    osprey.WILD_TYPE).addWildTypeRotamers().setContinuous()
ligand.flexibility['A46'].setLibraryRotamers(
    osprey.WILD_TYPE).addWildTypeRotamers().setContinuous()

# make the conf space for the protein+ligand complex
complexConfSpace = osprey.ConfSpace([protein, ligand])

# how should we compute energies of molecules?
# (give the complex conf space to the ecalc since it knows about all the templates and degrees of freedom)
parallelism = osprey.Parallelism(cpuCores=4)
ecalc = osprey.EnergyCalculator(complexConfSpace,
                                ffparams,
                                parallelism=parallelism)

# configure PAStE
paste = osprey.Paste(
    complexConfSpace,
    numPDBs=15,
    epsilon=
    0.68,  # you proabably want something more precise in your real designs
    useWindowCriterion=True,
    writeSequencesToConsole=True,
    writeSequencesToFile='paste.results.tsv',
    mutFile='mut.txt')

# configure PAStE inputs for the conf space
示例#5
0
osprey.start()

# define a strand
strand = osprey.Strand('1CC8.ss.pdb')
strand.flexibility['A2'].setLibraryRotamers('ALA', 'GLY')
strand.flexibility['A3'].setLibraryRotamers(osprey.WILD_TYPE, 'VAL')
strand.flexibility['A4'].setLibraryRotamers(osprey.WILD_TYPE)

# make the conf space
confSpace = osprey.ConfSpace(strand)

# choose a forcefield
ffparams = osprey.ForcefieldParams()

# how should we compute energies of molecules?
ecalc = osprey.EnergyCalculator(confSpace, ffparams)

# how should we define energies of conformations?
confEcalc = osprey.ConfEnergyCalculator(confSpace, ecalc)

# compute the energy matrix
emat = osprey.EnergyMatrix(confEcalc)

# run DEE with just steric pruning
pmat = osprey.DEE(confSpace, emat, showProgress=True)

# or run DEE with Goldstein pruning
#i0 = 10.0 # kcal/mol
#pmat = osprey.DEE(confSpace, emat, showProgress=True, singlesGoldsteinDiffThreshold=i0, pairsGoldsteinDiffThreshold=i0)

# find the best sequence and rotamers
示例#6
0
文件: bbkstar.py 项目: yazhai/OSPREY3
    osprey.WILD_TYPE).addWildTypeRotamers().setContinuous()

# make the conf space for the protein
proteinConfSpace = osprey.ConfSpace(protein)

# make the conf space for the ligand
ligandConfSpace = osprey.ConfSpace(ligand)

# make the conf space for the protein+ligand complex
complexConfSpace = osprey.ConfSpace([protein, ligand])

# how should we compute energies of molecules?
# (give the complex conf space to the ecalc since it knows about all the templates and degrees of freedom)
parallelism = osprey.Parallelism(cpuCores=4)
minimizingEcalc = osprey.EnergyCalculator(complexConfSpace,
                                          ffparams,
                                          parallelism=parallelism,
                                          isMinimizing=True)

# BBK* needs a rigid energy calculator too, for multi-sequence bounds on K*
rigidEcalc = osprey.SharedEnergyCalculator(minimizingEcalc, isMinimizing=False)


# how should we define energies of conformations?
def confEcalcFactory(confSpace, ecalc):
    eref = osprey.ReferenceEnergies(confSpace, ecalc)
    return osprey.ConfEnergyCalculator(confSpace,
                                       ecalc,
                                       referenceEnergies=eref)


# configure BBK*
示例#7
0
ligand.flexibility['A193'].setLibraryRotamers(
    osprey.WILD_TYPE).addWildTypeRotamers().setContinuous()

# make a multi-state conf space
confSpace = osprey.MultiStateConfSpace([
    osprey.StateMutable('design', osprey.ConfSpace(design)),
    osprey.StateUnmutable('ligand', osprey.ConfSpace(ligand)),
    osprey.StateMutable('complex', osprey.ConfSpace([design, ligand]))
])

# train a LUTE model for each state
for state in confSpace.states:

    # how should we compute energies of molecules?
    ecalc = osprey.EnergyCalculator(state.confSpace,
                                    ffparams,
                                    parallelism=parallelism)

    # how should we define energies of conformations?
    eref = osprey.ReferenceEnergies(state.confSpace, ecalc)
    confEcalc = osprey.ConfEnergyCalculator(state.confSpace,
                                            ecalc,
                                            referenceEnergies=eref)

    # calculate the energy matrix so we can do DEE
    emat = osprey.EnergyMatrix(
        confEcalc,
        # save it to disk so we don't have to calculate it again later
        cacheFile='sofea.%s.emat' % state.name)

    # Good LUTE fits rely heavily on DEE pruning, so use the best available DEE options here.
示例#8
0
文件: runTest.py 项目: yazhai/OSPREY3
        *AATypeOptions[posP[i]]).addWildTypeRotamers().setContinuous()

# make the conf space for the protein
confSpaceP = osprey.ConfSpace(protein)

# make the conf space for the ligand
confSpaceL = osprey.ConfSpace(ligand)

# make the conf space for the protein+ligand complex
confSpace = osprey.ConfSpace([protein, ligand])

# how should we compute energies of molecules?
# (give the complex conf space to the ecalc since it knows about all the templates and degrees of freedom)
numCPUs = 40
parallelism = osprey.Parallelism(cpuCores=numCPUs)
ecalc = osprey.EnergyCalculator(confSpace, ffparams, parallelism=parallelism)
rigidEcalc = osprey.EnergyCalculator(confSpace,
                                     ffparams,
                                     parallelism=parallelism,
                                     isMinimizing=False)

# how should we define energies of conformations?
eref = osprey.ReferenceEnergies(confSpace, ecalc)
erefRigid = osprey.ReferenceEnergies(confSpace, rigidEcalc)
confECalc = osprey.ConfEnergyCalculator(confSpace,
                                        ecalc,
                                        referenceEnergies=eref)
confRigidECalc = osprey.ConfEnergyCalculator(confSpace,
                                             rigidEcalc,
                                             referenceEnergies=eref)