コード例 #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 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
コード例 #3
0
ligand = osprey.Strand(mol, templateLib=templateLib, residues=['A38', 'A58'])
ligand.flexibility['A41'].setLibraryRotamers(
    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')
コード例 #4
0
ファイル: runTest.py プロジェクト: yazhai/OSPREY3
    protein.flexibility[resNumsP[i]].setLibraryRotamers(
        *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)
コード例 #5
0
ファイル: findGMEC.advanced.py プロジェクト: yazhai/OSPREY3
import osprey

osprey.start()

# what kind of hardware do we have?
parallelism = osprey.Parallelism(cpuCores=2)
# or use GPUs
gpuPrallelism = osprey.Parallelism(cpuCores=2, gpus=1, streamsPerGpu=1)

# choose a forcefield
ffparams = osprey.ForcefieldParams(osprey.Forcefield.AMBER)
ffparams.solvationForcefield = osprey.SolvationForcefield.EEF1  # this is the default
# or turn off solvation energy
#ffparams.solvationForcefield = None

# choose a template library
# (see templateLibrary.py for more detailed examples of custom template libraries)
templateLib = osprey.TemplateLibrary()

# load a molecule
mol = osprey.readPdb('1CC8.ss.pdb')

# define the protein strand
protein = osprey.Strand(mol, residues=['A2', 'A30'])

protein.flexibility['A2'].setLibraryRotamers('ALA', 'GLY')
protein.flexibility['A3'].setLibraryRotamers(osprey.WILD_TYPE, 'VAL',
                                             'ARG').setContinuous(10)
protein.flexibility['A4'].setLibraryRotamers(
    osprey.WILD_TYPE).addWildTypeRotamers()
コード例 #6
0
def maked_emat(config, fo):
    """Save complex energy matrix based on dictionary"""
    confspaces = loadd_confspaces(config)
    parallelism = osprey.Parallelism(cpuCores=multiprocessing.cpu_count())
    makeo_emat(confspaces["complex"], confspaces["ffparams"], parallelism, fo)
コード例 #7
0
def make_emat(fi, fo):
    """Save complex energy matrix based on TOML file"""
    confspaces = load_confspaces(fi)
    parallelism = osprey.Parallelism(cpuCores=multiprocessing.cpu_count())
    makeo_emat(confspaces["complex"], confspaces["ffparams"], parallelism, fo)