def Interface_axis( pose, dist, resmuts, score ): ## return the interface rotation/translation axis and the center ## Compute interface at "dist" of distance and store: ## The contact_list=[i := contact of ith residue ] ## The interface_list= [[interface_1],[interface_2]] copy_pose = Pose() copy_pose.assign(pose) score(copy_pose) interface = Interface(1) interface.distance(dist) interface.calculate(copy_pose) contact = interface.contact_list() interface_residue = interface.pair_list() centroid_interface = [] for interface in interface_residue: ## Compute the axis by taking the whole interfaces. centroid_interface.append( centroid([ copy_pose.residue(res).xyz('CA') for res in interface ])) ## store the centroids of the residue in the interfaces. interface_axis = map(sub, centroid_interface[0], centroid_interface[1]) center = centroid_interface[0] return (interface_axis, center)
def get_interface_residues(self, chains, name=None): # We are going to only change jump 1, so we know which jump to look at # in the Interface class movable_jumps = vector1_int(1) # Now we can alter the fold tree such that the jump is between the # chains we care about # chains = left_chains + '_' + right_chains sfxn = create_score_function('ref2015') sfxn(self.pose) print('SETTING UP FOLD TREE FOR INTERFACE {}'.format(chains)) setup_foldtree(self.pose, chains, movable_jumps) # Set up interface class interface = Interface(1) interface.distance(self.dist) interface.calculate(self.pose) if not name: name = self.pdbid # Logic for filtering out residues not on chains of interest interface_list = [] # interface_resis = [] for side in interface.pair_list(): for resi in side: # Find out what chain the residue belongs to pdbinfo = self.pose.pdb_info().pose2pdb(resi) # resnum = pdbinfo.split(' ')[0] chain = pdbinfo.split(' ')[1] # Find out what chain the resiude is interacting with closest = interface.closest_interface_residue(self.pose, resi, self.dist) interacting_chain = self.pose.pdb_info().pose2pdb(closest).split(' ')[1] interacting_resi = self.pose.pdb_info().pose2pdb(closest).split(' ')[0] # If both this chain and its partner are in the chains we care # about, do something with them (in this case I'm spitting out a # string that will let me select all the interface residues in # PyMOL as a sanity check, you'll obviously want to save these # to a dictionary or something) if chain in list(chains) and interacting_chain in list(chains): # interface_resis.append(resi) row = {'pdb': name, 'interface': chains, 'chain':chain, 'rosetta_resnum': resi, 'closest_chain': interacting_chain, 'closest_rosetta_resnum': closest, } # 'closest_pdb_resnum': interacting_resi} # 'pdb_resnum': resnum, interface_list.append(row) return interface_list
def Interface_axis( pose, dist, resmuts, score ): ## return the interface rotation/translation axis and the center ## Compute interface at "dist" of distance and store: ## The contact_list=[i := contact of ith residue ] ## The interface_list= [[interface_1],[interface_2]] copy_pose = Pose() copy_pose.assign(pose) setup_foldtree(copy_pose, "A_B", Vector1([1])) score(copy_pose) interface = Interface(1) interface.distance(dist) interface.calculate(copy_pose) contact = interface.contact_list() interface_residue = interface.pair_list() centroid_interface = [] for interface in interface_residue: ## Compute the axis by taking the whole interfaces. (Only for the native) centroid_interface.append( centroid([ copy_pose.residue(res).xyz('CA') for res in interface ])) ## store the centroids of the residue in the interfaces. interface_axis = map(sub, centroid_interface[0], centroid_interface[1]) center = centroid_interface[0] ## If there is mutation. The axis change by moving to the centroid of mutable residue. if (len(resmuts) != 0 and len(interface_residue[1]) != 0 and len(interface_residue[2]) != 0): centroid_muts = [] ## array for the mutables centroids centroid_flexs = [ ] ## array for the flexibles centroids i.e centroid of flexible 1, flexible 2 etc... for res in resmuts: ## Calculate the centroid of flexibles of (of res in resnames) centroid_flexs.append( centroid([ copy_pose.residue(i).xyz("CA") for i in sorted(list(set(contact[int(res)]))) ])) centroid_muts.append(copy_pose.residue(int(res)).xyz("CA")) centroid_flex = centroid( centroid_flexs) ## calculate the centroid of flexibles centroids centroid_mut = centroid( centroid_muts) ## calculate the centroid of mutables interface_axis = [ centroid_flex[0] - centroid_mut[0], centroid_flex[1] - centroid_mut[1], centroid_flex[2] - centroid_mut[2] ] ## Calculate the axis center = centroid_mut return (interface_axis, center)
def Interface_axis(pose, dist, resmuts, score): ## return the interface rotation/translation axis and the center ## Compute interface at "dist" of distance and store: ## The contact_list=[i := contact of ith residue ] ## The interface_list= [[interface_1],[interface_2]] copy_pose=Pose() copy_pose.assign(pose) score(copy_pose) interface = Interface(1) interface.distance(dist) interface.calculate(copy_pose) contact = interface.contact_list() interface_residue = interface.pair_list() centroid_interface=[] for interface in interface_residue: ## Compute the axis by taking the whole interfaces. centroid_interface.append(centroid([copy_pose.residue(res).xyz('CA') for res in interface])) ## store the centroids of the residue in the interfaces. interface_axis= map(sub,centroid_interface[0],centroid_interface[1]) center=centroid_interface[0] return (interface_axis, center)
def scanning(pdb_filename, partners, mutant_aa='A', interface_cutoff=8.0, output=False, trials=1, trial_output='', iresA="", iresB=""): """ Performs "scanning" at an interface within <pdb_filename> between <partners> by mutating relevant residues to <mutant_aa> and repacking residues within <pack_radius> Angstroms, further repacking all residues within <interface_cutoff> of the interface residue, scoring the complex and subtracting the score of a pose with the partners separated by 500 Angstroms. <trials> scans are performed (to average results) with summaries written to <trial_output>_(trial#).txt. Structures are exported to a PyMOL instance. """ # 1. create a pose from the desired PDB file pose = Pose() pose_from_file(pose, pdb_filename) iresA = [ pose.pdb_info().pdb2pose(partners[0], int(x)) for x in iresA.split(",") ] iresB = [ pose.pdb_info().pdb2pose(partners[-1], int(x)) for x in iresB.split(",") ] # 2. setup the docking FoldTree and other related parameters dock_jump = 1 movable_jumps = Vector1([dock_jump]) protocols.docking.setup_foldtree(pose, partners, movable_jumps) # 3. create ScoreFuncions for the Interface and "ddG" calculations # the pose's Energies objects MUST be updated for the Interface object to # work normally scorefxn = get_fa_scorefxn() # create_score_function('standard') scorefxn(pose) # needed for proper Interface calculation # setup a "ddG" ScoreFunction, custom weights ddG_scorefxn = ScoreFunction() ddG_scorefxn.set_weight(core.scoring.fa_atr, 0.44) ddG_scorefxn.set_weight(core.scoring.fa_rep, 0.07) ddG_scorefxn.set_weight(core.scoring.fa_sol, 1.0) ddG_scorefxn.set_weight(core.scoring.hbond_bb_sc, 0.5) ddG_scorefxn.set_weight(core.scoring.hbond_sc, 1.0) # 4. create an Interface object for the pose interface = Interface(dock_jump) interface.distance(interface_cutoff) interface.calculate(pose) # 5. create a PyMOLMover for sending output to PyMOL (optional) #pymover = PyMOLMover() #pymover.keep_history(True) # for multiple trajectories #pymover.apply(pose) #pymover.send_energy(pose) # 6. perform scanning trials # the large number of packing operations introduces a lot of variability, # for best results, perform several trials and average the results, # these score changes are useful to QUALITATIVELY defining "hotspot" # residues # this script does not use a PyJobDistributor since no PDB files are output for trial in range(trials): # store the ddG values in a dictionary ddG_mutants = {} for i in range(1, pose.total_residue() + 1): # for residues at the interface if i in iresA or i in iresB: # this way you can TURN OFF output by providing False arguments # (such as '', the default) filename = '' if output: filename = pose.pdb_info().name()[:-4] + '_' +\ pose.sequence()[i-1] +\ str(pose.pdb_info().number(i)) + '->' + mutant_aa outdir = "Structures/{0}/".format("_".join( os.path.basename(filename).split("_")[:2])) if (not os.path.exists(outdir)): try: os.mkdir(outdir) except OSError: pass outdir = "Structures/{0}/Mut_to_{1}/".format( "_".join(os.path.basename(filename).split("_")[:2]), mutant_aa) if (not os.path.exists(outdir)): try: os.mkdir(outdir) except OSError: pass pdb_pos, chain = pose.pdb_info().pose2pdb(i).split() filename = os.path.abspath( "{0}{1}_{2}{3}{4}_{5}.pdb".format( outdir, "_".join( os.path.basename(filename).split("_")[:2]), pose.sequence()[i - 1], pdb_pos, mutant_aa, chain, trial)) #print "|{0}|".format(pose.sequence()[i]) #print "|{0}|".format(pose.pdb_info().pose2pdb(i)) #print "|{0}|".format(mutant_aa) #print "|{0}|".format(trial) #print filename # determine the interace score change upon mutation ddG_mutants[i] = interface_ddG(pose, i, mutant_aa, movable_jumps, ddG_scorefxn, interface_cutoff, filename, iresA, iresB) # output results print('=' * 80) print('Trial', str(trial + 1)) print( 'Mutants (PDB numbered)\t\"ddG\" (interaction dependent score change)' ) residues = list(ddG_mutants.keys() ) # list(...) conversion is for python3 compatbility residues.sort() # easier to read display = [ pose.sequence()[i - 1] + str(pose.pdb_info().number(i)) + mutant_aa + '\t' + str(ddG_mutants[i]) + '\n' for i in residues ] print(''.join(display)[:-1]) print('=' * 80) # write to file f = open(trial_output + '_' + str(trial + 1) + '.txt', 'w') f.writelines(display) f.close() while (not os.path.exists(trial_output + '_' + str(trial + 1) + '.txt')): f = open(trial_output + '_' + str(trial + 1) + '.txt', 'w') f.writelines(display) f.close()
def scanning(pdb_filename, partners, mutant_aa='A', interface_cutoff=8.0, output=False, trials=1, trial_output=''): """ Performs "scanning" at an interface within <pdb_filename> between <partners> by mutating relevant residues to <mutant_aa> and repacking residues within <pack_radius> Angstroms, further repacking all residues within <interface_cutoff> of the interface residue, scoring the complex and subtracting the score of a pose with the partners separated by 500 Angstroms. <trials> scans are performed (to average results) with summaries written to <trial_output>_(trial#).txt. Structures are exported to a PyMOL instance. """ # 1. create a pose from the desired PDB file pose = Pose() pose_from_pdb(pose, pdb_filename) # 2. setup the docking FoldTree and other related parameters dock_jump = 1 movable_jumps = Vector1([dock_jump]) setup_foldtree(pose, partners, movable_jumps) # 3. create ScoreFuncions for the Interface and "ddG" calculations # the pose's Energies objects MUST be updated for the Interface object to # work normally scorefxn = get_fa_scorefxn() # create_score_function('standard') scorefxn(pose) # needed for proper Interface calculation # setup a "ddG" ScoreFunction, custom weights ddG_scorefxn = ScoreFunction() ddG_scorefxn.set_weight(fa_atr, 0.44) ddG_scorefxn.set_weight(fa_rep, 0.07) ddG_scorefxn.set_weight(fa_sol, 1.0) ddG_scorefxn.set_weight(hbond_bb_sc, 0.5) ddG_scorefxn.set_weight(hbond_sc, 1.0) # 4. create an Interface object for the pose interface = Interface(dock_jump) interface.distance(interface_cutoff) interface.calculate(pose) # 5. create a PyMOL_Mover for sending output to PyMOL (optional) pymover = PyMOL_Mover() pymover.keep_history(True) # for multiple trajectories pymover.apply(pose) pymover.send_energy(pose) # 6. perform scanning trials # the large number of packing operations introduces a lot of variability, # for best results, perform several trials and average the results, # these score changes are useful to QUALITATIVELY defining "hotspot" # residues # this script does not use a PyJobDistributor since no PDB files are output for trial in range(trials): # store the ddG values in a dictionary ddG_mutants = {} for i in range(1, pose.total_residue() + 1): # for residues at the interface if interface.is_interface(i) == True: # this way you can TURN OFF output by providing False arguments # (such as '', the default) filename = '' if output: filename = pose.pdb_info().name()[:-4] + '_' +\ pose.sequence()[i-1] +\ str(pose.pdb_info().number(i)) + '->' + mutant_aa # determine the interace score change upon mutation ddG_mutants[i] = interface_ddG(pose, i, mutant_aa, movable_jumps, ddG_scorefxn, interface_cutoff, filename) # output results print '=' * 80 print 'Trial', str(trial + 1) print 'Mutants (PDB numbered)\t\"ddG\" (interaction dependent score change)' residues = ddG_mutants.keys() residues.sort() # easier to read display = [ pose.sequence()[i - 1] + str(pose.pdb_info().number(i)) + mutant_aa + '\t' + str(ddG_mutants[i]) + '\n' for i in residues ] print ''.join(display)[:-1] print '=' * 80 # write to file f = open(trial_output + '_' + str(trial + 1) + '.txt', 'w') f.writelines(display) f.close() #### alternate output using scanning_analysis (see below), only display #### mutations with "deviant" score changes print 'Likely Hotspot Residues' for hotspot in scanning_analysis(trial_output): print hotspot print '=' * 80
from toolbox import * import StringIO parser = optparse.OptionParser() parser.add_option('--pdb', dest='pdb_file', default='', help='Protein comple in PDB format') parser.add_option('--dist', dest='dist', default=10.0, help='Size of interface') (options, args) = parser.parse_args() pdb_file = options.pdb_file dist = float(options.dist) init() pose = pose_from_pdb(pdb_file) setup_foldtree(pose, "A_B", Vector1([1])) score = create_score_function("talaris2014") score(pose) interface = Interface(1) interface.distance(dist) interface.calculate(pose) contact = interface.contact_list() interface_residue = interface.pair_list() print pose.fold_tree() print interface_residue
from rosetta.core.scoring import * from rosetta.core.graph import * from rosetta.protocols.scoring import Interface from toolbox import * import StringIO parser=optparse.OptionParser() parser.add_option('--pdb', dest = 'pdb_file', default = '', help = 'Protein comple in PDB format' ) parser.add_option( '--dist', dest='dist' , default = 10.0, help = 'Size of interface') (options,args) = parser.parse_args() pdb_file=options.pdb_file dist=float(options.dist) init() pose=pose_from_pdb(pdb_file) setup_foldtree(pose, "A_B", Vector1([1])) score=create_score_function("talaris2014") score(pose) interface = Interface(1) interface.distance(dist) interface.calculate(pose) contact = interface.contact_list() interface_residue = interface.pair_list() print pose.fold_tree() print interface_residue