def make_confspace(cfs_file, data, cfs_dir=DEFAULT_CFS_DIR): """make_confspace Generate conf spaces from input file Takes as input a cfs_file that contains chain definitions, flexible residues, and mutable residues. Returns a dictionary containing forcefield parameters and OSPREY confspace objects for: protein ligand complex """ # Get the pdb code for this design data["pdb"] = cfs_file[:4] print("pdb: %s" % data["pdb"]) # Load the design conformation space information data["cfs"] = os.path.join(cfs_dir, cfs_file) confspace = imp.load_source('confspace', data["cfs"]) print("CFS File: %s" % data["cfs"]) # Get the sequences if they exist try: data["sequences"] = confspace.sequences except AttributeError: data["sequences"] = [None] ffparams = osprey.ForcefieldParams() mol = osprey.readPdb(confspace.mol) template_library = osprey.TemplateLibrary(ffparams.forcefld) # Make sure we don't have 3 strands (some cfs files do) assert len(confspace.strand_defs) == 2 # Define the protein strand protein = osprey.Strand(mol, templateLib=template_library, residues=confspace.strand_defs["strand0"]) for resi, res_allowed in confspace.strand_flex["strand0"].iteritems(): protein.flexibility[resi]\ .setLibraryRotamers(osprey.WILD_TYPE, *res_allowed)\ .setContinuous()\ .addWildTypeRotamers() # Define the ligand strand ligand = osprey.Strand(mol, templateLib=template_library, residues=confspace.strand_defs["strand1"]) for resi, res_allowed in confspace.strand_flex["strand1"].iteritems(): ligand.flexibility[resi]\ .setLibraryRotamers(osprey.WILD_TYPE,*res_allowed)\ .setContinuous()\ .addWildTypeRotamers() # Build spaces return { 'protein': osprey.ConfSpace(protein), 'ligand': osprey.ConfSpace(ligand), 'complex': osprey.ConfSpace([protein, ligand]), 'ffparams': ffparams }
import osprey 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
protein.flexibility['A8'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the ligand strand 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,
osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() design.flexibility['G651'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the ligand strand ligand = osprey.Strand(mol, templateLib=templateLib, residues=['A155', 'A194']) ligand.flexibility['A172'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A192'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() 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,
protein.flexibility['G654'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the ligand strand ligand = osprey.Strand(mol, templateLib=templateLib, residues=['A155', 'A194']) ligand.flexibility['A156'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A172'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A192'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A193'].setLibraryRotamers( 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)
ffparams = osprey.ForcefieldParams() # read a PDB file for molecular info mol = osprey.readPdb('2RL0.min.reduce.pdb') # define the conformation space strand = osprey.Strand(mol, residues=['G648', 'G654']) for resNum in ['G649', 'G650', 'G651']: strand.flexibility[resNum]\ .setLibraryRotamers(osprey.WILD_TYPE)\ .addWildTypeRotamers()\ .setContinuous() confSpace = osprey.MultiStateConfSpace([ # yeah, we didn't define any mutations, # but SOFEA still needs one "mutable" state to define the sequence space osprey.StateMutable('protein', osprey.ConfSpace(strand)) ]) # we only care about the "wild-type" sequence in this case seq = confSpace.seqSpace.makeWildTypeSequence() # how should we compute energies of molecules? ecalc = osprey.EnergyCalculator(confSpace, ffparams, parallelism=parallelism) # make a function that makes a SOFEA config object for a state def config(state): # how should we define energies of conformations? confEcalc = osprey.ConfEnergyCalculator( state.confSpace, ecalc,
customizedTemplateLib = osprey.TemplateLibrary( extraTemplates=[customTemplates], extraTemplateCoords=[customTemplateCoords], extraRotamers=[customRotamers]) # or read templates from files # customizedTemplateLibFromFiles = osprey.TemplateLibrary( # extraTemplates=['/path/to/templates/file'] # etc... # ) # or completely replace default templates # completelyCustomTemplateLib = osprey.TemplateLibrary( # defaultTemplates=False, # extraTemplates=['/path/to/all/templates'], # etc... # ) # load the molecule and make the strand using our custom template library protein = osprey.Strand('1CC8.ss.pdb', templateLib=customizedTemplateLib) # make the conf space 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() confSpace = osprey.ConfSpace(protein) # continue design with confSpace
# define the ligand strand ligandStrand = osprey.Strand(mol, templateLib=templateLib, residues=['A155', 'A194']) ligandStrand.flexibility['A156'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligandStrand.flexibility['A172'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligandStrand.flexibility['A192'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligandStrand.flexibility['A193'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() complex = osprey.EwakstarDoer_State( 'PL', osprey.ConfSpace([proteinStrand, ligandStrand])) # number of CPUs cpus = 4 # configure EWAKStar ewakstarDoer = osprey.EwakstarDoer( state=complex, smaNodes=0, useSMA=False, printPDBs=True, # do we want to set our baseline at the wild-type sequence? as in: do we only want sequences better than wild-type? useWtBenchmark=False, logFile='ewakstar.sequences.tsv',
templateLib=templateLib, residues=[startResL, endResL]) for i in range(0, len(resNumsL)): ligand.flexibility[resNumsL[i]].setLibraryRotamers( *AATypeOptions[posL[i]]).addWildTypeRotamers().setContinuous() # define the ligand strand protein = osprey.Strand(mol, templateLib=templateLib, residues=[startResP, endResP]) for i in range(0, len(resNumsP)): 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,
# define the ligand strand ligandStrand = osprey.Strand(mol, templateLib=templateLib, residues=['A155', 'A194']) ligandStrand.flexibility['A156'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligandStrand.flexibility['A172'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligandStrand.flexibility['A192'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligandStrand.flexibility['A193'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the MSK* states protein = osprey.MSKStar_State('Protein', osprey.ConfSpace(proteinStrand)) ligand = osprey.MSKStar_State('Ligand', osprey.ConfSpace(ligandStrand)) complex = osprey.MSKStar_State('Complex', osprey.ConfSpace([proteinStrand, ligandStrand])) # configure COMETS mskstar = osprey.MSKStar( objective=osprey.MSKStar_LMFE({ complex: 1.0, protein: -1.0, ligand: -1.0 }), logFile='mskstar.tsv', # how precisely should we estimate partition function values? # (in range (0,1], lower is more precise)
# define a strand strand = osprey.Strand('1CC8.ss.pdb') strand.flexibility['A38'].setLibraryRotamers('ILE', 'ALA', 'GLY').setContinuous() strand.flexibility['A39'].setLibraryRotamers("Ser", "Ala", "Gly").setContinuous() strand.flexibility['A40'].setLibraryRotamers("Met", "Ser", "Ala", "Gly", "Leu").setContinuous() strand.flexibility['A41'].setLibraryRotamers("Glu", "Ala", "Gly").setContinuous() strand.flexibility['A42'].setLibraryRotamers("Ala", "Gly").setContinuous() # make the conf space bbflex = osprey.c.confspace.CATSStrandFlex(strand, 'A38', 'A42') confSpace = osprey.ConfSpace([[strand, bbflex]]) # choose a forcefield ffparams = osprey.ForcefieldParams() ffparams.solvScale = 0. # how should we compute energies of molecules? ecalc = osprey.EnergyCalculator(confSpace, ffparams) eref = osprey.ReferenceEnergies(confSpace, ecalc) # how should we define energies of conformations? confEcalc = osprey.ConfEnergyCalculator(confSpace, ecalc, referenceEnergies=eref)
def loadd_confspaces(config, xtal_rotamers=True, continuous=False, force_wt=True): """Loads OSPREY ConfSpace objects from a config dictionary. OPTIONS: xtal_rotamers: if true, add the rotamers from the input pdb continuous: if true, set continuous rotamers force_wt: if true, always add the wild-type amino acid """ ffparams = osprey.ForcefieldParams() mol = osprey.readPdb(join(PDB, config["molecule"])) template_library = osprey.TemplateLibrary(ffparams.forcefld) # Make sure we don't have 3 strands (some cfs files do) if len(config["strand_definitions"]) > 2: exit() # Define the protein strand protein = osprey.Strand(mol, templateLib=template_library, residues=config["strand_definitions"]["strand0"]) for resi, res_allowed in config["strand_mutations"]["strand0"].items(): # Add the osprey.WILD_TYPE object to the allowed residues if desired if force_wt: res_allowed.append(osprey.WILD_TYPE) # Set the flexibility protein.flexibility[resi]\ .setLibraryRotamers(*res_allowed) if xtal_rotamers: protein.flexibility[resi].addWildTypeRotamers() if continuous: protein.flexibility[resi].setContinuous() # Define the ligand strand ligand = osprey.Strand(mol, templateLib=template_library, residues=config["strand_definitions"]["strand1"]) for resi, res_allowed in config["strand_mutations"]["strand1"].items(): # Add the osprey.WILD_TYPE object to the allowed residues if desired if force_wt: res_allowed.append(osprey.WILD_TYPE) # Set the flexibility ligand.flexibility[resi]\ .setLibraryRotamers(*res_allowed) if xtal_rotamers: ligand.flexibility[resi].addWildTypeRotamers() if continuous: ligand.flexibility[resi].setContinuous() # Build spaces return { 'protein': osprey.ConfSpace(protein), 'ligand': osprey.ConfSpace(ligand), 'complex': osprey.ConfSpace([protein, ligand]), 'ffparams': ffparams }
strand1.flexibility['A3'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers() strand1.flexibility['A4'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers() # define another strand strand2 = osprey.Strand(mol, residues=['A21', 'A40']) strand2.flexibility['A21'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers() strand2.flexibility['A22'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers() strand2.flexibility['A23'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers() # make the conf space confSpace = osprey.ConfSpace([strand1, strand2]) # choose a forcefield ffparams = osprey.ForcefieldParams() # how to compute the energy of a conformation? ecalc = osprey.EnergyCalculator(confSpace, ffparams) confEcalc = osprey.ConfEnergyCalculator(confSpace, ecalc) # how should confs be ordered and searched? emat = osprey.EnergyMatrix(confEcalc) astar = osprey.AStarMPLP(emat, confSpace) # find the best sequence and rotamers gmec = osprey.GMECFinder(astar, confEcalc).find()
endResL = 'B161' AATypeOptions = [['HID', 'ASP', 'GLU', 'SER', 'THR', 'ASN', 'GLN', 'ALA', 'VAL', 'ILE', 'LEU', 'CYS', 'GLY'], ['ALA', 'LEU', 'ILE', 'VAL', 'PHE', 'TYR', 'MET', 'GLU', 'ASP','HID', 'ASN', 'GLN', 'GLY'], ['CYS', 'SER', 'THR', 'ASN', 'GLN', 'HIE', 'ALA', 'VAL', 'ILE', 'LEU', 'PHE', 'TYR', 'GLY'], ['ILE', 'ALA', 'LEU', 'VAL', 'PHE', 'TYR', 'MET','GLU', 'ASP', 'HID', 'ASN', 'GLN', 'GLY'], ['GLU', 'ASP', 'PHE', 'TYR', 'ALA', 'VAL', 'ILE', 'LEU', 'HIE', 'HID', 'ASN', 'GLN', 'GLY'], ['TYR', 'PHE', 'ALA', 'VAL', 'ILE','LEU', 'GLU', 'ASP', 'HID', 'HIE', 'ASN', 'GLN', 'GLY'], ['PHE', 'TYR', 'ALA', 'VAL', 'ILE', 'LEU', 'GLU', 'ASP', 'HID', 'HIE', 'ASN', 'GLN', 'GLY'], ['TRP', 'ALA', 'VAL','ILE', 'LEU', 'PHE', 'TYR', 'MET', 'SER', 'THR', 'ASN', 'GLN', 'GLY'], ['TYR', 'PHE', 'ALA', 'VAL', 'ILE', 'LEU', 'GLU', 'ASP', 'HID', 'HIE', 'ASN', 'GLN', 'GLY']] # make sure all strands share the same template library (including wild-type rotamers) templateLib = osprey.TemplateLibrary(ffparams.forcefld, moleculesForWildTypeRotamers=[mol]) # define the protein strand ligand = osprey.Strand(mol, templateLib=templateLib, residues=[startResL, endResL]) for i in range(0,len(resNumsL)): ligand.flexibility[resNumsL[i]].setLibraryRotamers(*AATypeOptions[posL[i]]).addWildTypeRotamers().setContinuous() # define the ligand strand protein = osprey.Strand(mol, templateLib=templateLib, residues=[startResP, endResP]) for i in range(0,len(resNumsP)): protein.flexibility[resNumsP[i]].setLibraryRotamers(*AATypeOptions[posP[i]]).addWildTypeRotamers().setContinuous() complex = osprey.EwakstarDoer_State('PL', osprey.ConfSpace([protein, ligand])) # number of CPUs cpus = 40; # configure EWAKStar ewakstarDoer = osprey.EwakstarDoer( state = complex, # do we want to set our baseline at the wild-type sequence? as in: do we only want sequences better than wild-type? useWtBenchmark = False, # number of sequences we want to limit ourselves to during the "sequence filter" portion of ewakstarDoer numEWAKStarSeqs = 10000,
osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() design.flexibility['G651'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the ligand strand ligand = osprey.Strand(mol, templateLib=templateLib, residues=['A155', 'A194']) ligand.flexibility['A172'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A192'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A193'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # make a single-state conf space: confSpace = osprey.MultiStateConfSpace( [osprey.StateMutable('complex', osprey.ConfSpace([design, ligand]))]) complexState = confSpace.getState('complex') # use the "wild-type" sequence seq = confSpace.seqSpace.makeWildTypeSequence() # (or any other sequence defined in your conf space) #seq = confSpace.seqSpace.makeUnassignedSequence()\ # .set('G649', 'ALA') # how should we compute energies of molecules? ecalc = osprey.EnergyCalculator(confSpace, ffparams, parallelism=parallelism) # make a function that makes a SOFEA config object for a state def config(state):
protein.flexibility['G654'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the ligand strand ligand = osprey.Strand(mol, templateLib=templateLib, residues=['A155', 'A194']) ligand.flexibility['A156'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A172'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A192'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() ligand.flexibility['A193'].setLibraryRotamers( osprey.WILD_TYPE).addWildTypeRotamers().setContinuous() # define the COMETS states bound = osprey.COMETS_State('Bound', osprey.ConfSpace([protein, ligand])) unbound = osprey.COMETS_State('Unbound', osprey.ConfSpace(protein)) # configure COMETS comets = osprey.COMETS(objective=osprey.COMETS_LME({ bound: 1.0, unbound: -1.0 }), logFile='comets.tsv') # how should we compute energies of molecules? # (give all the conf spaces to the ecalc) confSpaces = [state.confSpace for state in comets.states] parallelism = osprey.Parallelism(cpuCores=4) ecalc = osprey.EnergyCalculator(confSpaces, ffparams, parallelism=parallelism)