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)
def findGmec(epart): print("\n\nFinding GMEC with energy partition: %s\n" % epart) # configure conformation energies with the desired energy partition confEcalc = osprey.ConfEnergyCalculator(confSpace, ecalc, energyPartition=epart) # find the GMEC emat = osprey.EnergyMatrix(confEcalc) astar = osprey.AStarTraditional(emat, confSpace) gmec = osprey.GMECFinder(astar, confEcalc).find()
def config(state): # how should we define energies of conformations? confEcalc = osprey.ConfEnergyCalculator( state.confSpace, ecalc, referenceEnergies = osprey.ReferenceEnergies(state.confSpace, ecalc), # use the "AllOnPairs" setting to get tighter energy bounds # tighter energy bounds make SOFEA run much faster! energyPartition = osprey.EnergyPartition.AllOnPairs ) # train forcefield approximations to make energy calculations go much faster amat = osprey.ApproximatorMatrix( confEcalc, # save the approximator matrix to disk so we don't have to calculate it again later cacheFile = 'sofea.%s.amat' % state.name, ) # update the conformation energy calculator with the forcefield approximations confEcalc = osprey.ConfEnergyCalculator( state.confSpace, ecalc, # copy settings from the previous confEcalc referenceEnergies = confEcalc.eref, energyPartition = confEcalc.epart, # give the new confEcalc the approximator matrix amat = amat, # how much error can we tolerate per conformation? approximationErrorBudget = 0.1 # kcal/mol ) # make the SOFEA config return osprey.SOFEA_StateConfig( # calculate the energy matrix emat = osprey.EnergyMatrix( confEcalc, # save the emat to disk so we don't have to calculate it again later cacheFile = 'sofea.%s.emat' % state.name, # correct overly optimistic energy bounds with triples to get even tighter energy bounds! tripleCorrectionThreshold = 0.0 ), confEcalc = confEcalc )
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 # how should we define energies of conformations? eref = osprey.ReferenceEnergies(paste.protein.confSpace, ecalc) paste.protein.confEcalc = osprey.ConfEnergyCalculator(paste.protein.confSpace, ecalc, referenceEnergies=eref) # compute the energy matrix emat = osprey.EnergyMatrix(paste.protein.confEcalc, cacheFile='emat.%s.dat' % paste.protein.id) # how should confs be ordered and searched? (don't forget to capture emat by using a defaulted argument) def makeAStar(rcs, emat=emat): return osprey.AStarTraditional(emat, rcs, showProgress=False) paste.protein.confSearchFactory = osprey.Paste.ConfSearchFactory(makeAStar) # run PAStE paste.run()
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 astar = osprey.AStarMPLP(emat, pmat) gmec = osprey.GMECFinder(astar, confEcalc).find()
# choose a forcefield ffparams = osprey.ForcefieldParams() # let's go fast parallelism = osprey.Parallelism(cpuCores=4) # how should we compute energies of molecules? ecalc = osprey.EnergyCalculator(confSpace, ffparams, parallelism=parallelism) # how should we define energies of conformations? confEcalc = osprey.ConfEnergyCalculator(confSpace, ecalc) # calculate the energy matrix so we can do DEE emat = osprey.EnergyMatrix( confEcalc, cacheFile= 'LUTE.emat.dat' # save it to disk so we don't have to calculate it again later ) # Good LUTE fits rely heavily on DEE pruning, so use the best available DEE options here. # With interval pruning, we prune only conformations whose energies are more than X higher # than the lower bound of the conformation with the minimum lower bound. # If we sort the whole conformation space by lower bounds, interval pruning is like keeping # only conformations in the bottom X kcal/mol slice of the sorted list. pruningInterval = 10.0 # kcal/mol pmat = osprey.DEE( confSpace, emat, singlesGoldsteinDiffThreshold=pruningInterval, pairsGoldsteinDiffThreshold=pruningInterval, triplesGoldsteinDiffThreshold=
numBestSequences=2, epsilon= 0.99, # you proabably want something more precise in your real designs writeSequencesToConsole=True, writeSequencesToFile='bbkstar.results.tsv') # configure BBK* inputs for each conf space for info in bbkstar.confSpaceInfos(): # how should we define energies of conformations? eref = osprey.ReferenceEnergies(info.confSpace, minimizingEcalc) info.confEcalcMinimized = osprey.ConfEnergyCalculator( info.confSpace, minimizingEcalc, referenceEnergies=eref) # compute the energy matrix ematMinimized = osprey.EnergyMatrix(info.confEcalcMinimized, cacheFile='emat.%s.dat' % info.id) # how should confs be ordered and searched? # (since we're in a loop, need capture variables above by using defaulted arguments) def makeAStarMinimized(rcs, emat=ematMinimized): return osprey.AStarTraditional(emat, rcs, showProgress=False) info.confSearchFactoryMinimized = osprey.BBKStar.ConfSearchFactory( makeAStarMinimized) # BBK* needs rigid energies too confEcalcRigid = osprey.ConfEnergyCalculatorCopy(info.confEcalcMinimized, rigidEcalc) ematRigid = osprey.EnergyMatrix(confEcalcRigid, cacheFile='emat.%s.rigid.dat' % info.id)
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. # With interval pruning, we prune only conformations whose energies are more than X higher # than the lower bound of the conformation with the minimum lower bound. # If we sort the whole conformation space by lower bounds, interval pruning is like keeping # only conformations in the bottom X kcal/mol slice of the sorted list. pruningInterval = 20.0 # kcal/mol pmat = osprey.DEE( state.confSpace, emat, # pruning triples is much slower than just singles and pairs, but important for good fits singlesGoldsteinDiffThreshold=pruningInterval, pairsGoldsteinDiffThreshold=pruningInterval, triplesGoldsteinDiffThreshold=pruningInterval,
complexConfSpace, numBestSequences=2, epsilon=0.99, # you proabably want something more precise in your real designs writeSequencesToConsole=True, writeSequencesToFile='bbkstar.results.tsv' ) # configure BBK* inputs for each conf space for info in bbkstar.confSpaceInfos(): # how should we define energies of conformations? eref = osprey.ReferenceEnergies(info.confSpace, minimizingEcalc) info.confEcalcMinimized = osprey.ConfEnergyCalculator(info.confSpace, minimizingEcalc, referenceEnergies=eref) # compute the energy matrix emat = osprey.EnergyMatrix(info.confEcalcMinimized, cacheFile='emat.%s.dat' % info.id) # BBK* needs rigid energies too rigidConfEcalc = osprey.ConfEnergyCalculatorCopy(info.confEcalcMinimized, rigidEcalc) rigidEmat = osprey.EnergyMatrix(rigidConfEcalc, cacheFile='emat.%s.rigid.dat' % info.id) # how should partition functions be computed? info.pfuncFactory = osprey.PartitionFunctionFactory(info.confSpace, info.confEcalcMinimized, info.id) # run BBK* scoredSequences = bbkstar.run() # use results for scoredSequence in scoredSequences: print("result:") print("\tsequence: %s" % scoredSequence.sequence)
# variables for EWAKStar epsilon = 0.68 numTopSeqs = 5 maxPFConfs = 500 seqFilterOnly = False wtBenchmark = False useMaxMutable = True #want to change maxMutable for various designs maxMutable = 1 numFilteredSeqs = 10000 orderOfMag = 5.0 unboundEw = 8.0 boundEw = 8.0 ewakstarEw = 1.0 Ival = 0.0 PLmatrixName = "ewak.*" PLematMatrixName = "ewak.PL.emat" emat = osprey.EnergyMatrix(confECalc, cacheFile=PLematMatrixName) # run EWAK* ewakstarDoer = osprey.EWAKStar( numCPUs, wtBenchmark, seqFilterOnly, useMaxMutable, maxMutable, numTopSeqs, maxPFConfs, epsilon, confRigidECalc, confECalc, emat, ecalc, confSpace, confSpaceL, confSpaceP, pos, posL, posP, numFilteredSeqs, orderOfMag, unboundEw, boundEw, ewakstarEw, startResL, endResL, startResP, endResP, mol, resNumsPL, resNumsL, resNumsP, Ival, PLmatrixName) scoredSequences = ewakstarDoer.run()
isMinimizing=False) # how should we define energies of conformations? eref = osprey.ReferenceEnergies(complex.confSpace, ecalc) erefRigid = osprey.ReferenceEnergies(complex.confSpace, rigidEcalc) # how should we define energies of conformations? eref = osprey.ReferenceEnergies(complex.confSpace, ecalc) complex.confEcalc = osprey.ConfEnergyCalculator(complex.confSpace, ecalc, referenceEnergies=eref) complex.confRigidEcalc = osprey.ConfEnergyCalculator( complex.confSpace, rigidEcalc, referenceEnergies=erefRigid) # compute the energy matrix complex.emat = osprey.EnergyMatrix(complex.confEcalc, cacheFile='ewakstar.%s.emat' % complex.name) complex.fragmentEnergies = complex.emat complex.ematRigid = osprey.EnergyMatrix(complex.confRigidEcalc, cacheFile='ewakstar.%s.ematRigid' % complex.name) # how should confs be ordered and searched? (don't forget to capture emat by using a defaulted argument) useSMA = False #do you want to use memory bounded A*? if (useSMA): def makeAStar(rcs, emat=complex.emat): return osprey.AStarTraditional(complex.emat, rcs, showProgress=False, maxNumNodes=2000000)
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() # make the conf space confSpace = osprey.ConfSpace(protein) # how should molecule energies be calculated? ecalc = osprey.EnergyCalculator(confSpace, ffparams, parallelism=parallelism) # how could conformation energies be calculated? confEcalc = osprey.ConfEnergyCalculator(confSpace, ecalc) # calculate the energy matrix emat = osprey.EnergyMatrix(confEcalc, cacheFile='/tmp/emat.dat') # define the conformation search astar = osprey.AStarMPLP(emat, confSpace, numIterations=1) # or traditionalAstar = osprey.AStarTraditional(emat, confSpace) energyWindow = 0.1 # kcal/mol confs = osprey.GMECFinder(astar, confEcalc, printIntermediateConfs=True, confLog='confs.txt').find(energyWindow)
ligandConfSpace, complexConfSpace, epsilon=0.99, # 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? eref = osprey.ReferenceEnergies(info.confSpace, ecalc) info.confEcalc = osprey.ConfEnergyCalculator(info.confSpace, ecalc, referenceEnergies=eref) # compute the energy matrix emat = osprey.EnergyMatrix(info.confEcalc, cacheFile='emat.%s.dat' % info.id) # how should confs be ordered and searched? (don't forget to capture emat by using a defaulted argument) def makeAStar(rcs, emat=emat): return osprey.AStarTraditional(emat, rcs, showProgress=False) info.confSearchFactory = osprey.KStar.ConfSearchFactory(makeAStar) # run K* scoredSequences = kstar.run() # use results for scoredSequence in scoredSequences: print("result:") print("\tsequence: %s" % scoredSequence.sequence) print("\tscore: %s" % scoredSequence.score)
maxSimultaneousMutations=1) # how should we compute energies of molecules? # (give all the conf spaces to the ecalc) confSpaces = [state.confSpace for state in mskstar.states] parallelism = osprey.Parallelism(cpuCores=4) ecalc = osprey.EnergyCalculator(confSpaces, ffparams, parallelism=parallelism) # configure MSK* states for state in mskstar.states: # how should we define energies of conformations? eref = osprey.ReferenceEnergies(state.confSpace, ecalc) state.confEcalc = osprey.ConfEnergyCalculator(state.confSpace, ecalc, referenceEnergies=eref) # compute the energy matrix emat = osprey.EnergyMatrix(state.confEcalc, cacheFile='emat.%s.dat' % state.name) state.fragmentEnergies = emat # how should confs be ordered and searched? (don't forget to capture emat by using a defaulted argument) def makeAStar(rcs, emat=emat): return osprey.AStarTraditional(emat, rcs, showProgress=False) state.confTreeFactory = osprey.MSKStar_ConfSearchFactory(makeAStar) # finally, run MSK* mskstar.findBestSequences(5)