Ejemplo n.º 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
Ejemplo n.º 2
0
# 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*
bbkstar = osprey.BBKStar(
    proteinConfSpace,
    ligandConfSpace,
    complexConfSpace,
Ejemplo n.º 3
0
def configure_bbk(instance, minimizingEcalc, type_string, id_obj, algo_index):
    """Configure the energy calculators and info for BBK* instance"""

    for info in instance.confSpaceInfos():
        # Compute reference energies
        eref = osprey.ReferenceEnergies(info.confSpace, minimizingEcalc)
        #Create a minimizing energy calculator
        info.confEcalcMinimized = osprey.ConfEnergyCalculator(
            info.confSpace, minimizingEcalc, referenceEnergies=eref)

        # BBK* needs rigid energies too
        rigidEcalc = osprey.SharedEnergyCalculator(minimizingEcalc,
                                                   isMinimizing=False)
        rigidConfEcalc = osprey.ConfEnergyCalculatorCopy(
            info.confEcalcMinimized, rigidEcalc)
        info.confEcalcRigid = rigidConfEcalc

        # Specify the input for the partition functions. Providing the confUpperBoundcalc turns on SHARK*
        if ALGO_LIST[algo_index] == 'SHARK':
            impt_ecalc = rigidConfEcalc
            choose_markstar = False
        elif ALGO_LIST[algo_index] == 'MARK':
            impt_ecalc = rigidConfEcalc
            choose_markstar = True
        else:
            impt_ecalc = None
            choose_markstar = False

        info.pfuncFactory = osprey.PartitionFunctionFactory(
            info.confSpace,
            info.confEcalcMinimized,
            info.id,
            confUpperBoundcalc=impt_ecalc,
            useMARK=choose_markstar)

        # Set cache pattern
        info.pfuncFactory.setCachePattern('%s/emat.%s.%s' %
                                          (XTMP_DIR, info.id, id_obj))
        print('Cache pattern: %s/emat.%s.%s' % (XTMP_DIR, info.id, id_obj))

        # compute the energy matrices
        info.ematMinimized = info.pfuncFactory.getOrMakeEmat(
            info.confEcalcMinimized, 'minimized')

        info.ematRigid = info.pfuncFactory.getOrMakeEmat(
            info.confEcalcRigid, 'rigid')

        # Updating energy matrix?
        #info.ematCorrected =\
        #osprey.c.ematrix.UpdatingEnergyMatrix(
        #info.confSpace,
        #info.ematMinimized,
        #info.confEcalcMinimized
        #)

        # how should confs be ordered and searched? (don't forget to capture emat by using a defaulted argument)
        def makeAStar_min(rcs, emat=info.ematMinimized):
            return osprey.AStarTraditional(emat, rcs, showProgress=True)

        info.confSearchFactoryMinimized =\
                osprey.KStar.ConfSearchFactory(makeAStar_min)

        def makeRigidAStar(rcs, emat=info.ematRigid):
            return osprey.AStarTraditional(emat, rcs, showProgress=True)

        info.confSearchFactoryRigid =\
                osprey.KStar.ConfSearchFactory(makeRigidAStar)
Ejemplo n.º 4
0
# 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)
ecalc = osprey.EnergyCalculator(complexConfSpace,
                                ffparams,
                                parallelism=parallelism)

# MARK* needs a rigid energy calculator too
ecalcRigid = osprey.SharedEnergyCalculator(ecalc, isMinimizing=False)

# configure K*
kstar = osprey.KStar(
    proteinConfSpace,
    ligandConfSpace,
    complexConfSpace,
    epsilon=
    0.95,  # you proabably want something more precise in your real designs
    writeSequencesToConsole=True,
    writeSequencesToFile='kstar.results.tsv')

# configure K* inputs for each conf space
for info in kstar.confSpaceInfos():

    # how should we define energies of conformations?