## 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 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()
## 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 )