def getSurface( model, key ): if verbose: log.write("Calculating SurfaceRacer data for %s..."%key) d = PDBDope( model ) d.addSurfaceRacer( probe=1.4 ) if verbose: log.writeln('Done.') result['%s_AS'%key] = model.profile('AS') result['%s_MS'%key] = model.profile('MS') result['%s_relAS'%key] = model.profile('relAS') result['%s_relMS'%key] = model.profile('relMS')
## Load Trajectories - read and sort bound ligand and recepror trajectories traj_rec_ref = Trajectory([ref_rec_file]) traj_lig_ref = Trajectory([ref_lig_file]) traj_rec, traj_rec_ref = castTraj(traj_rec, traj_rec_ref) traj_lig, traj_lig_ref = castTraj(traj_lig, traj_lig_ref) refCom = ProteinComplex(traj_rec_ref.ref, traj_lig_ref.ref) traj_rec = traj_rec_ref.concat(traj_rec) traj_lig = traj_lig_ref.concat(traj_lig) ## Add surface atom profile flushPrint('Adding accessible surface profiles...\n') rec_asa = PDBDope(traj_rec.getRef()) rec_asa.addASA() lig_asa = PDBDope(traj_lig.getRef()) lig_asa.addASA() ## Atom sets to use for analysis ## Sets are(only heavy atoms): masks_all, mask_all_names = allMasks(traj_rec, traj_lig, refCom) ## Masks restricted to surface atoms masks_surf, mask_surf_names = surfMasks(traj_rec, traj_lig, refCom) ## pairwise rmsd calculation rmsd_all_dic = calcAllRmsds(traj_rec, traj_lig, masks_all) rmsd_surf_dic = calcAllRmsds(traj_rec, traj_lig, masks_surf)
def main(options): ################## ## files and names receptorName = absfile(options['r']) receptorCode = stripFilename(receptorName)[0:4] ligandName = absfile(options['l']) ligandCode = stripFilename(ligandName)[0:4] complexName = absfile(options['c']) rm = options['rm'] lm = options['lm'] if rm or lm: rn = rm or '1' ln = lm or '1' baseName = receptorCode + '_' + rn + '-' + ligandCode + '_' + ln else: baseName = receptorCode + '-' + ligandCode ## hex macro name macName = baseName + '_hex.mac' ## hex rotation matrix output name outName_all = baseName + '_hex.out' outName_clust = baseName + '_hex_cluster.out' ## load model dictionaries, if they exist in the same directory ## as the corresponding pdb-file and start with the same pdb-code ## and ends with '_model.dic' try: rec_dic = stripFilename(options['r'])[:4] + '_model.dic' rec_path = options['r'][:options['r'].rfind('/')] lig_dic = stripFilename(options['l'])[:4] + '_model.dic' lig_path = options['l'][:options['l'].rfind('/')] rec = load( absfile(rec_path + '/' + rec_dic) ) lig = load( absfile(lig_path + '/' + lig_dic) ) print 'Loading dictionaries' if type(rec) is dict: rec = rec[1] if type(lig) is dict: lig = lig[1] ## could not load dictionaty, will load pdb-file insted except: print 'Loading pdb files' rec = PDBModel(receptorName) lig = PDBModel(ligandName) ############################# ## get structural information ## add surface profiles if not there if not rec.atoms.has_key('relASA'): flushPrint('\nCalculating receptor surface profile') rec_asa = PDBDope( rec ) rec_asa.addASA() if not lig.atoms.has_key('relASA'): flushPrint('\nCalculating ligand surface profile') lig_asa = PDBDope( lig ) lig_asa.addASA() ## surface masks, > 95% exposed rec_surf_mask = greater( rec.profile('relASA'), 95 ) lig_surf_mask = greater( lig.profile('relASA'), 95 ) ## maximun and medisn distance from centre of mass to any surface atom recMax, recMin = centerSurfDist( rec, rec_surf_mask ) ligMax, ligMin = centerSurfDist( lig, lig_surf_mask ) ## approxinate max and min center to centre distance maxDist = recMax + ligMax minDist = recMin + ligMin print '\n\nReceptor and ligand max radius are %i and %i A, respectively.'\ %( recMax, ligMax ) print 'Receptor and ligand min radius are %i and %i A, respectively.'\ %( recMin, ligMin ) ## molecular separation and search range to be used in the docking molSep = ( maxDist + minDist ) / 2 molRange = 2 * ( maxDist - molSep ) print 'A molecular separation of %i A and a search range of +-%i will be used.'\ %( molSep, molRange ) ## determine docking mode to use macroDocking = 0 if recMax > 30 and ligMax > 30: print '\nWARNING! Both the receptor and ligand radius is greater than 30 A.\n' if recMax > 30: print '\nReceptor has a radius that exceeds 30 A -> Macro docking will be used' macroDocking = 1 ##################### ## write macro file macOpen= open(macName, 'w') macOpen.write('# ------------------- ' + macName + ' -----------------------\n') macOpen.write(' \n') macOpen.write('open_receptor '+receptorName+'\n') macOpen.write('open_ligand '+ligandName+'\n') if complexName[-4:] == '.pdb': macOpen.write('open_complex '+complexName+'\n') macOpen.write('\n') head = """ # -------------- general settings ---------------- disc_cache 1 # disc cache on (0 off) docking_sort_mode 1 # Sort solutions by cluster (0 by energy) docking_cluster_mode 1 # Display all clusters (0 display best) docking_cluster_threshold 2.00 # docking_cluster_bumps number # ------------ molecule orientation -------------- molecule_separation %(separation)i commit_view """%({'separation': round(molSep)} ) macro =""" # -------------- macro docking ------------------- macro_min_coverage 25 macro_sphere_radius 15 macro_docking_separation 25 activate_macro_model""" tail = """ # -------------- docking setup ------------------- docking_search_mode 0 # full rotational search receptor_range_angle 180 # 0, 15, 30, 45, 60, 75, 90, 180 docking_receptor_samples 720 # 362, 492, 642, 720, 980, 1280 ligand_range_angle 180 docking_ligand_samples 720 twist_range_angle 360 # 0, 15, 30, 60, 90, 180, 360 docking_alpha_samples 128 # 64, 128, 256 r12_step 0.500000 # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2 r12_range %(range)i docking_radial_filter 0 # Radial Envelope Filter - None # docking_radial_filter 0 # Radial Envelope Filter - Re-entrant # docking_radial_filter 0 # Radial Envelope Filter - Starlike grid_size 0.600 # 0.4, 0.5, 0.6, 0.75, 1.0 # docking_electrostatics 0 # use only surface complimentarity docking_electrostatics 1 # use electrostatic term for scoring clusters docking_main_scan 16 # docking_main_search 26 max_docking_solutions %(nr_sol)i # number of solutions to save # -------------- post-processing ---------------- docking_refine 0 # None # docking_refine 1 # Backbone Bumps and volumes # docking_refine 2 # MM energies # docking_refine 3 # MM minimization # ---------------- run docking ------------------ activate_docking save_docking %(output_clust)s # save_range 1 512 ./ dock .pdb # ------------ also save all solutions ---------- docking_sort_mode 0 # Sort solutions by energy (1 by cluster) save_docking %(output_all)s""" \ %({'range':round(molRange), 'output_all':outName_all, 'nr_sol':int(options['sol']), 'output_clust':outName_clust} ) macOpen.writelines( head ) ## select certain models if rm or lm: macOpen.write('\n') macOpen.write('\n# -------------- select models -------------------\n') if rm: select_rec_model = 'dock_receptor_model %s'%rm macOpen.write( select_rec_model + '\n') if lm: select_lig_model = 'dock_ligand_model %s'%lm macOpen.write( select_lig_model + '\n') ## macro docking will not work with multiple models, if both are added to ## the hex macro file - macrodocking will be skipped during the docking run if macroDocking: macOpen.writelines( macro ) macOpen.writelines( tail ) macOpen.close()
def createHexInp(recPdb, recModel, ligPdb, ligModel, comPdb=None, outFile=None, macDock=None, silent=0, sol=512): """ Prepare a Hex macro file for the docking of the receptor(s) against ligand(s). @param recPdb: hex-formatted PDB @type recPdb: str @param recModel: hex-formatted PDB @type recModel: str @param ligPdb: PDBModel, get distances from this one @type ligPdb: PDBModel @param ligModel: PDBModel, getdistances from this one @type ligModel: PDBModel @param comPdb: reference PDB @type comPdb: str @param outFile: base of file name for mac and out @type outFile: str @param macDock: None -> hex decides (from the size of the molecule), 1 -> force macroDock, 0-> force off (default: None) @type macDock: None|1|0 @param silent: don't print distances and macro warnings (default: 0) @type silent: 0|1 @param sol: number of solutions that HEx should save (default: 512) @type sol: int @return: HEX macro file name, HEX out generated bu the macro, macro docking status @rtype: str, str, boolean """ ## files and names recCode = t.stripFilename(recPdb)[0:4] ligCode = t.stripFilename(ligPdb)[0:4] outFile = outFile or recCode + '-' + ligCode ## hex macro name macName = t.absfile(outFile + '_hex.mac') ## hex rotation matrix output name outName_all = t.absfile(outFile + '_hex.out') outName_clust = t.absfile(outFile + '_hex_cluster.out') ## add surface profiles if not there if not recModel.atoms.has_key('relAS'): #t.flushPrint('\nCalculating receptor surface profile') rec_asa = PDBDope(recModel) rec_asa.addSurfaceRacer() if not ligModel.atoms.has_key('relAS'): #t.flushPrint('\nCalculating ligand surface profile') lig_asa = PDBDope(ligModel) lig_asa.addSurfaceRacer() ## surface masks, > 95% exposed rec_surf_mask = N.greater(recModel.profile('relAS'), 95) lig_surf_mask = N.greater(ligModel.profile('relAS'), 95) ## maximun and medisn distance from centre of mass to any surface atom recMax, recMin = centerSurfDist(recModel, rec_surf_mask) ligMax, ligMin = centerSurfDist(ligModel, lig_surf_mask) ## approxinate max and min center to centre distance maxDist = recMax + ligMax minDist = recMin + ligMin ## molecular separation and search range to be used in the docking molSep = (maxDist + minDist) / 2 molRange = 2 * (maxDist - molSep) if not silent: print 'Docking setup: %s\nRecMax: %.1f RecMin: %.1f\nLigMax: %.1f LigMin: %.1f\nMaxDist: %.1f MinDist: %.1f\nmolecular_separation: %.1f r12_range: %.1f\n' % ( outFile, recMax, recMin, ligMax, ligMin, maxDist, minDist, molSep, molRange) if recMax > 30 and ligMax > 30 and not silent: print '\nWARNING! Both the receptor and ligand radius is ', print 'greater than 30A.\n' ## determine docking mode to use macroDocking = 0 if macDock == None: if recMax > 35 and not silent: print '\nReceptor has a radius that exceeds 35A ', print '-> Macro docking will be used' macroDocking = 1 else: macroDocking = macDock ##################### ## write macro file macOpen = open(macName, 'w') macOpen.write('# -- ' + macName + ' --\n') macOpen.write(' \n') macOpen.write('open_receptor ' + t.absfile(recPdb) + '\n') macOpen.write('open_ligand ' + t.absfile(ligPdb) + '\n') if comPdb and comPdb[-4:] == '.pdb': macOpen.write('open_complex ' + comPdb + '\n') macOpen.write('\n') head = """ # -------------- general settings ---------------- disc_cache 1 # disc cache on (0 off) docking_sort_mode 1 # Sort solutions by cluster (0 by energy) docking_cluster_mode 1 # Display all clusters (0 display best) docking_cluster_threshold 2.00 # docking_cluster_bumps number # ------------ molecule orientation -------------- molecule_separation %(separation)i commit_view """ % ({ 'separation': round(molSep) }) macro = """ # -------------- macro docking ------------------- macro_min_coverage 25 macro_sphere_radius 15 macro_docking_separation 25 activate_macro_model""" tail = """ # -------------- docking setup ------------------- docking_search_mode 0 # full rotational search receptor_range_angle 180 # 0, 15, 30, 45, 60, 75, 90, 180 docking_receptor_samples 720 # 362, 492, 642, 720, 980, 1280 ligand_range_angle 180 docking_ligand_samples 720 twist_range_angle 360 # 0, 15, 30, 60, 90, 180, 360 docking_alpha_samples 128 # 64, 128, 256 r12_step 0.500000 # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2 r12_range %(range)i docking_radial_filter 0 # Radial Envelope Filter - None grid_size 0.600 # 0.4, 0.5, 0.6, 0.75, 1.0 # docking_electrostatics 0 # use only surface complimentarity docking_electrostatics 1 # use electrostatic term for scoring clusters docking_main_scan 16 # docking_main_search 26 max_docking_solutions %(nr_sol)i # number of solutions to save # -------------- post-processing ---------------- docking_refine 0 # None # docking_refine 1 # Backbone Bumps # docking_refine 2 # MM energies # docking_refine 3 # MM minimization # ---------------- run docking ------------------ activate_docking # save_docking %(output_clust)s # save_range 1 512 ./ dock .pdb # ------------ also save all solutions ---------- docking_sort_mode 0 # Sort solutions by energy (1 by cluster) save_docking %(output_all)s""" \ %({'range':round(molRange), 'output_all':outName_all, 'nr_sol':int(sol), 'output_clust':outName_clust} ) macOpen.writelines(head) ## macro docking will not work with multiple models, if both are added to ## the hex macro file - macrodocking will be skipped during the docking run if macroDocking: macOpen.writelines(macro) macOpen.writelines(tail) macOpen.close() return macName, outName_all, macroDocking
traj.fit(prof='rms2avg') f_global = traj.getFluct_global() f_local = traj.getFluct_local() ref = traj.getRef() ## disconnect ref from its source ref.disconnect() ref.atoms.set('fluct_global', f_global, comment='fluctuation around average position in A') ref.atoms.set('fluct_local', f_local, comment='fluctuation after fitting to each residue backbone') try: doper = PDBDope(ref) flushPrint('adding accessible surface profiles...') doper.addSurfaceRacer() except Exception, why: errWriteln("Couldn't add surface area profiles, ProfileError: ", why) dump(traj, options['o'])
traj.fit( prof='rms2avg', ref=traj.ref ) traj.fit( prof='rms2avg' ) f_global = traj.getFluct_global() f_local = traj.getFluct_local() ref = traj.getRef() ## disconnect ref from its source ref.disconnect() ref.atoms.set( 'fluct_global', f_global, comment='fluctuation around average position in A' ) ref.atoms.set( 'fluct_local', f_local, comment='fluctuation after fitting to each residue backbone') try: doper = PDBDope( ref ) flushPrint('adding accessible surface profiles...') doper.addSurfaceRacer() except Exception, why: errWriteln("Couldn't add surface area profiles, ProfileError: ", why) dump( traj, options['o'] )
def main(options): ################## ## files and names receptorName = absfile(options['r']) receptorCode = stripFilename(receptorName)[0:4] ligandName = absfile(options['l']) ligandCode = stripFilename(ligandName)[0:4] complexName = absfile(options['c']) rm = options['rm'] lm = options['lm'] if rm or lm: rn = rm or '1' ln = lm or '1' baseName = receptorCode + '_' + rn + '-' + ligandCode + '_' + ln else: baseName = receptorCode + '-' + ligandCode ## hex macro name macName = baseName + '_hex.mac' ## hex rotation matrix output name outName_all = baseName + '_hex.out' outName_clust = baseName + '_hex_cluster.out' ## load model dictionaries, if they exist in the same directory ## as the corresponding pdb-file and start with the same pdb-code ## and ends with '_model.dic' try: rec_dic = stripFilename(options['r'])[:4] + '_model.dic' rec_path = options['r'][:options['r'].rfind('/')] lig_dic = stripFilename(options['l'])[:4] + '_model.dic' lig_path = options['l'][:options['l'].rfind('/')] rec = load(absfile(rec_path + '/' + rec_dic)) lig = load(absfile(lig_path + '/' + lig_dic)) print 'Loading dictionaries' if type(rec) is dict: rec = rec[1] if type(lig) is dict: lig = lig[1] ## could not load dictionaty, will load pdb-file insted except: print 'Loading pdb files' rec = PDBModel(receptorName) lig = PDBModel(ligandName) ############################# ## get structural information ## add surface profiles if not there if not rec.atoms.has_key('relASA'): flushPrint('\nCalculating receptor surface profile') rec_asa = PDBDope(rec) rec_asa.addASA() if not lig.atoms.has_key('relASA'): flushPrint('\nCalculating ligand surface profile') lig_asa = PDBDope(lig) lig_asa.addASA() ## surface masks, > 95% exposed rec_surf_mask = greater(rec.profile('relASA'), 95) lig_surf_mask = greater(lig.profile('relASA'), 95) ## maximun and medisn distance from centre of mass to any surface atom recMax, recMin = centerSurfDist(rec, rec_surf_mask) ligMax, ligMin = centerSurfDist(lig, lig_surf_mask) ## approxinate max and min center to centre distance maxDist = recMax + ligMax minDist = recMin + ligMin print '\n\nReceptor and ligand max radius are %i and %i A, respectively.'\ %( recMax, ligMax ) print 'Receptor and ligand min radius are %i and %i A, respectively.'\ %( recMin, ligMin ) ## molecular separation and search range to be used in the docking molSep = (maxDist + minDist) / 2 molRange = 2 * (maxDist - molSep) print 'A molecular separation of %i A and a search range of +-%i will be used.'\ %( molSep, molRange ) ## determine docking mode to use macroDocking = 0 if recMax > 30 and ligMax > 30: print '\nWARNING! Both the receptor and ligand radius is greater than 30 A.\n' if recMax > 30: print '\nReceptor has a radius that exceeds 30 A -> Macro docking will be used' macroDocking = 1 ##################### ## write macro file macOpen = open(macName, 'w') macOpen.write('# ------------------- ' + macName + ' -----------------------\n') macOpen.write(' \n') macOpen.write('open_receptor ' + receptorName + '\n') macOpen.write('open_ligand ' + ligandName + '\n') if complexName[-4:] == '.pdb': macOpen.write('open_complex ' + complexName + '\n') macOpen.write('\n') head = """ # -------------- general settings ---------------- disc_cache 1 # disc cache on (0 off) docking_sort_mode 1 # Sort solutions by cluster (0 by energy) docking_cluster_mode 1 # Display all clusters (0 display best) docking_cluster_threshold 2.00 # docking_cluster_bumps number # ------------ molecule orientation -------------- molecule_separation %(separation)i commit_view """ % ({ 'separation': round(molSep) }) macro = """ # -------------- macro docking ------------------- macro_min_coverage 25 macro_sphere_radius 15 macro_docking_separation 25 activate_macro_model""" tail = """ # -------------- docking setup ------------------- docking_search_mode 0 # full rotational search receptor_range_angle 180 # 0, 15, 30, 45, 60, 75, 90, 180 docking_receptor_samples 720 # 362, 492, 642, 720, 980, 1280 ligand_range_angle 180 docking_ligand_samples 720 twist_range_angle 360 # 0, 15, 30, 60, 90, 180, 360 docking_alpha_samples 128 # 64, 128, 256 r12_step 0.500000 # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2 r12_range %(range)i docking_radial_filter 0 # Radial Envelope Filter - None # docking_radial_filter 0 # Radial Envelope Filter - Re-entrant # docking_radial_filter 0 # Radial Envelope Filter - Starlike grid_size 0.600 # 0.4, 0.5, 0.6, 0.75, 1.0 # docking_electrostatics 0 # use only surface complimentarity docking_electrostatics 1 # use electrostatic term for scoring clusters docking_main_scan 16 # docking_main_search 26 max_docking_solutions %(nr_sol)i # number of solutions to save # -------------- post-processing ---------------- docking_refine 0 # None # docking_refine 1 # Backbone Bumps and volumes # docking_refine 2 # MM energies # docking_refine 3 # MM minimization # ---------------- run docking ------------------ activate_docking save_docking %(output_clust)s # save_range 1 512 ./ dock .pdb # ------------ also save all solutions ---------- docking_sort_mode 0 # Sort solutions by energy (1 by cluster) save_docking %(output_all)s""" \ %({'range':round(molRange), 'output_all':outName_all, 'nr_sol':int(options['sol']), 'output_clust':outName_clust} ) macOpen.writelines(head) ## select certain models if rm or lm: macOpen.write('\n') macOpen.write('\n# -------------- select models -------------------\n') if rm: select_rec_model = 'dock_receptor_model %s' % rm macOpen.write(select_rec_model + '\n') if lm: select_lig_model = 'dock_ligand_model %s' % lm macOpen.write(select_lig_model + '\n') ## macro docking will not work with multiple models, if both are added to ## the hex macro file - macrodocking will be skipped during the docking run if macroDocking: macOpen.writelines(macro) macOpen.writelines(tail) macOpen.close()
return pm if __name__ == '__main__': from Biskit import PDBDope from Biskit.tools import * from Biskit.Dock import Complex print "Loading" m_com = load(testRoot() + '/com/ref.complex').model() rec = m_com.takeChains([0]) lig = m_com.takeChains([1]) ## add molecular surface to components doper = PDBDope(rec) doper.addSurfaceRacer(probe=1.4) surf_rec = rec.profile2mask('MS', 0.0001, 101) doper = PDBDope(lig) doper.addSurfaceRacer(probe=1.4) surf_lig = lig.profile2mask('MS', 0.0001, 101) ## kick out non-surface rec = rec.compress(surf_rec) lig = lig.compress(surf_lig) com = Complex(rec, lig) ## get interface patch cont = com.atomContacts(cutoff=6.0)
return pm if __name__ == '__main__': from Biskit import PDBDope from Biskit.tools import * from Biskit.Dock import Complex print "Loading" ## m_com = load( testRoot() + '/com_wet/dry_com.model' ) m_com = load( testRoot() + '/com/ref.complex').model() m_com._resIndex = None ## HACK, something wrong with legacy _resIndex doper = PDBDope( m_com ) doper.addSurfaceRacer() mask = m_com.profile2mask( 'relAS', 5, 101 ) m = m_com.compress( mask ) ## get patches and put them into Pymoler for display print "Patching" pm = test( m ) ## show real interface patch com = Complex( m_com.takeChains([0]), m_com.takeChains([1])) cont = com.atomContacts() rec_i = N.flatnonzero( N.sum( cont, 1 ) ) lig_i = N.flatnonzero( N.sum( cont, 0 ) )
if __name__ == '__main__': from Biskit import PDBDope from Biskit.tools import * from Biskit.Dock import Complex print "Loading" m_com = load( testRoot() + '/com/ref.complex' ).model() rec = m_com.takeChains([0]) lig = m_com.takeChains([1]) ## add molecular surface to components doper = PDBDope( rec ) doper.addSurfaceRacer( probe=1.4 ) surf_rec = rec.profile2mask( 'MS', 0.0001, 101 ) doper = PDBDope( lig ) doper.addSurfaceRacer( probe=1.4 ) surf_lig = lig.profile2mask( 'MS', 0.0001, 101 ) ## kick out non-surface rec = rec.compress( surf_rec ) lig = lig.compress( surf_lig ) com = Complex( rec, lig ) ## get interface patch cont = com.atomContacts( cutoff=6.0 )
def test_Complex(self): """Dock.Complex test""" lig = PCRModel( t.testRoot() + "/com/1BGS.psf", t.testRoot() + "/com/lig.model") rec = PCRModel( t.testRoot() + "/com/1BGS.psf", t.testRoot() + "/com/rec.model") rec = rec.compress( rec.maskHeavy() ) lig = lig.compress( lig.maskHeavy() ) c = Complex(rec, lig) c.info['soln'] = 1 cont = c.atomContacts( 6.0 ) contProfile_lig = N.sum( cont ) contProfile_rec = N.sum( cont, 1 ) try: dope = PDBDope( c.rec_model ) dope.addSurfaceRacer( probe=1.4 ) rec_surf = c.rec_model.profile2mask( 'MS', 0.0000001, 1000 ) dope = PDBDope( c.lig_model ) dope.addSurfaceRacer( probe=1.4 ) lig_surf = c.lig_model.profile2mask( 'MS', 0.0000001, 1000 ) except: pass if self.local: from Biskit import Pymoler self.pm = Pymoler() self.pm.addPdb( c.rec(), 'rec' ) self.pm.addPdb( c.lig(), 'lig' ) self.pm.colorAtoms( 'rec', contProfile_rec ) self.pm.colorAtoms( 'lig', contProfile_lig ) rec_sphere = c.rec().clone() rec_sphere.xyz = mathUtils.projectOnSphere( rec_sphere.xyz ) lig_sphere = c.lig().clone() lig_sphere.xyz = mathUtils.projectOnSphere( lig_sphere.xyz ) self.pm.addPdb( rec_sphere, 'rec_sphere' ) self.pm.addPdb( lig_sphere, 'lig_sphere' ) self.pm.colorAtoms( 'rec_sphere', contProfile_rec ) self.pm.colorAtoms( 'lig_sphere', contProfile_lig ) self.pm.add( 'hide all') self.pm.add( 'color grey, (b=0)' ) self.pm.add( 'show stick, (rec or lig)' ) self.pm.add( 'show surf, rec_sphere') self.pm.add( 'zoom all' ) self.pm.show() globals().update( locals() ) self.assertEqual( N.sum(contProfile_lig) + N.sum(contProfile_rec), 2462 )
def conservationScore( self, cons_type='cons_ent', ranNr=150, log=StdLog(), verbose=1 ): """ Score of conserved residue pairs in the interaction surface. Optionally, normalized by radom surface contacts. @param cons_type: precalculated conservation profile name, see L{Biskit.PDBDope}. @type cons_type: str @param ranNr: number of random matricies to use (default: 150) @type ranNr: int @param log: log file [STDOUT] @type log: Biskit.LogFile @param verbose: give progress report [1] @type verbose: bool | int @return: conservation score @rtype: float """ try: recCons = self.rec().profile( cons_type, updateMissing=1 ) except: if verbose: log.add('\n'+'*'*30+'\nNO HHM PROFILE FOR RECEPTOR\n'+\ '*'*30+'\n') recCons = N.ones( self.rec().lenResidues() ) try: ligCons = self.lig().profile( cons_type, updateMissing=1 ) except: if verbose: log.add(\ '\n'+'*'*30+'\nNO HHM PROFILE FOR LIGAND\n'+'*'*30+'\n') ligCons = N.ones( self.lig().lenResidues() ) if self.rec().profile( 'surfMask' ): recSurf = self.rec().profile( 'surfMask' ) else: d = PDBDope(self.rec()) d.addSurfaceMask() if self.lig().profile( 'surfMask' ): ligSurf = self.lig().profile( 'surfMask' ) else: d = PDBDope(self.lig()) d.addSurfaceMask() surfMask = N.ravel(N.outerproduct( recSurf, ligSurf )) missing = N.outerproduct( N.equal( recCons, 0), N.equal(ligCons,0)) cont = self.resContacts() * N.logical_not(missing) consMat = N.outerproduct( recCons, ligCons ) score = cont* consMat # get a random score if ranNr != 0: if self.verbose: self.log.write('.') ranMat = mathUtils.random2DArray( cont, ranNr, mask=surfMask ) random_score = N.sum(N.sum( ranMat * consMat ))/( ranNr*1.0 ) return N.sum(N.sum(score))/random_score else: return N.sum(N.sum(score))/ N.sum(N.sum(cont))
def foldXEnergy( self, force=1 ): """ Calculate E_rec and/or E_lig only if not given:: E_com - (E_rec + E_lig). @param force: force calc of E_rec and E_lig @type force: 1|0 @return: dict with the different fold-X energy terms @rtype: dict """ rec, lig = self.rec_model, self.lig_model ## add/update lig/rec fold-X energies if necessary if not 'foldX' in rec.info or rec.xyzChanged or force: d = PDBDope( rec ) d.addFoldX() if not 'foldX' in lig.info or lig.xyzChanged or force: d = PDBDope( lig ) d.addFoldX() try: self.lig_transformed.info = lig.info except: pass m = self.model() d = PDBDope( m ) d.addFoldX() e_rec = rec.info['foldX'] e_lig = lig.info['foldX'] e_com = m.info['foldX'] r = {} for key in e_com: e = e_com[key] - ( e_lig[key] + e_rec[key] ) r[key] = e return r
def createHexInp( recPdb, recModel, ligPdb, ligModel, comPdb=None, outFile=None, macDock=None, silent=0, sol=512 ): """ Prepare a Hex macro file for the docking of the receptor(s) against ligand(s). @param recPdb: hex-formatted PDB @type recPdb: str @param recModel: hex-formatted PDB @type recModel: str @param ligPdb: PDBModel, get distances from this one @type ligPdb: PDBModel @param ligModel: PDBModel, getdistances from this one @type ligModel: PDBModel @param comPdb: reference PDB @type comPdb: str @param outFile: base of file name for mac and out @type outFile: str @param macDock: None -> hex decides (from the size of the molecule), 1 -> force macroDock, 0-> force off (default: None) @type macDock: None|1|0 @param silent: don't print distances and macro warnings (default: 0) @type silent: 0|1 @param sol: number of solutions that HEx should save (default: 512) @type sol: int @return: HEX macro file name, HEX out generated bu the macro, macro docking status @rtype: str, str, boolean """ ## files and names recCode = t.stripFilename( recPdb )[0:4] ligCode = t.stripFilename( ligPdb )[0:4] outFile = outFile or recCode + '-' + ligCode ## hex macro name macName = t.absfile( outFile + '_hex.mac' ) ## hex rotation matrix output name outName_all = t.absfile( outFile + '_hex.out' ) outName_clust = t.absfile( outFile + '_hex_cluster.out') ## add surface profiles if not there if not recModel.atoms.has_key('relAS'): #t.flushPrint('\nCalculating receptor surface profile') rec_asa = PDBDope( recModel ) rec_asa.addSurfaceRacer() if not ligModel.atoms.has_key('relAS'): #t.flushPrint('\nCalculating ligand surface profile') lig_asa = PDBDope( ligModel ) lig_asa.addSurfaceRacer() ## surface masks, > 95% exposed rec_surf_mask = N.greater( recModel.profile('relAS'), 95 ) lig_surf_mask = N.greater( ligModel.profile('relAS'), 95 ) ## maximun and medisn distance from centre of mass to any surface atom recMax, recMin = centerSurfDist( recModel, rec_surf_mask ) ligMax, ligMin = centerSurfDist( ligModel, lig_surf_mask ) ## approxinate max and min center to centre distance maxDist = recMax + ligMax minDist = recMin + ligMin ## molecular separation and search range to be used in the docking molSep = ( maxDist + minDist ) / 2 molRange = 2 * ( maxDist - molSep ) if not silent: print 'Docking setup: %s\nRecMax: %.1f RecMin: %.1f\nLigMax: %.1f LigMin: %.1f\nMaxDist: %.1f MinDist: %.1f\nmolecular_separation: %.1f r12_range: %.1f\n'%(outFile, recMax, recMin, ligMax, ligMin, maxDist, minDist, molSep, molRange) if recMax > 30 and ligMax > 30 and not silent: print '\nWARNING! Both the receptor and ligand radius is ', print 'greater than 30A.\n' ## determine docking mode to use macroDocking = 0 if macDock==None: if recMax > 35 and not silent: print '\nReceptor has a radius that exceeds 35A ', print '-> Macro docking will be used' macroDocking = 1 else: macroDocking = macDock ##################### ## write macro file macOpen= open( macName, 'w') macOpen.write('# -- ' + macName + ' --\n') macOpen.write(' \n') macOpen.write('open_receptor '+ t.absfile(recPdb) +'\n') macOpen.write('open_ligand '+ t.absfile(ligPdb) +'\n') if comPdb and comPdb[-4:] == '.pdb': macOpen.write('open_complex '+comPdb+'\n') macOpen.write('\n') head = """ # -------------- general settings ---------------- disc_cache 1 # disc cache on (0 off) docking_sort_mode 1 # Sort solutions by cluster (0 by energy) docking_cluster_mode 1 # Display all clusters (0 display best) docking_cluster_threshold 2.00 # docking_cluster_bumps number # ------------ molecule orientation -------------- molecule_separation %(separation)i commit_view """%({'separation': round(molSep)} ) macro =""" # -------------- macro docking ------------------- macro_min_coverage 25 macro_sphere_radius 15 macro_docking_separation 25 activate_macro_model""" tail = """ # -------------- docking setup ------------------- docking_search_mode 0 # full rotational search receptor_range_angle 180 # 0, 15, 30, 45, 60, 75, 90, 180 docking_receptor_samples 720 # 362, 492, 642, 720, 980, 1280 ligand_range_angle 180 docking_ligand_samples 720 twist_range_angle 360 # 0, 15, 30, 60, 90, 180, 360 docking_alpha_samples 128 # 64, 128, 256 r12_step 0.500000 # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2 r12_range %(range)i docking_radial_filter 0 # Radial Envelope Filter - None grid_size 0.600 # 0.4, 0.5, 0.6, 0.75, 1.0 # docking_electrostatics 0 # use only surface complimentarity docking_electrostatics 1 # use electrostatic term for scoring clusters docking_main_scan 16 # docking_main_search 26 max_docking_solutions %(nr_sol)i # number of solutions to save # -------------- post-processing ---------------- docking_refine 0 # None # docking_refine 1 # Backbone Bumps # docking_refine 2 # MM energies # docking_refine 3 # MM minimization # ---------------- run docking ------------------ activate_docking # save_docking %(output_clust)s # save_range 1 512 ./ dock .pdb # ------------ also save all solutions ---------- docking_sort_mode 0 # Sort solutions by energy (1 by cluster) save_docking %(output_all)s""" \ %({'range':round(molRange), 'output_all':outName_all, 'nr_sol':int(sol), 'output_clust':outName_clust} ) macOpen.writelines( head ) ## macro docking will not work with multiple models, if both are added to ## the hex macro file - macrodocking will be skipped during the docking run if macroDocking: macOpen.writelines( macro ) macOpen.writelines( tail ) macOpen.close() return macName, outName_all, macroDocking
## Load Trajectories - read and sort bound ligand and recepror trajectories traj_rec_ref = Trajectory( [ ref_rec_file ] ) traj_lig_ref = Trajectory( [ ref_lig_file ] ) traj_rec, traj_rec_ref = castTraj( traj_rec, traj_rec_ref ) traj_lig, traj_lig_ref = castTraj( traj_lig, traj_lig_ref ) refCom = ProteinComplex( traj_rec_ref.ref, traj_lig_ref.ref ) traj_rec = traj_rec_ref.concat( traj_rec ) traj_lig = traj_lig_ref.concat( traj_lig ) ## Add surface atom profile flushPrint('Adding accessible surface profiles...\n') rec_asa = PDBDope( traj_rec.getRef() ) rec_asa.addASA() lig_asa = PDBDope( traj_lig.getRef() ) lig_asa.addASA() ## Atom sets to use for analysis ## Sets are(only heavy atoms): masks_all , mask_all_names = allMasks( traj_rec, traj_lig, refCom ) ## Masks restricted to surface atoms masks_surf , mask_surf_names = surfMasks( traj_rec, traj_lig, refCom ) ## pairwise rmsd calculation rmsd_all_dic = calcAllRmsds( traj_rec, traj_lig, masks_all ) rmsd_surf_dic = calcAllRmsds( traj_rec, traj_lig, masks_surf )