sel = atom.ATOMPDBSelector() m = IMP.Model() h_receptor = atom.read_pdb(args.fn_receptor, m, sel) rb_receptor = atom.create_rigid_body(h_receptor) h_ligand = atom.read_pdb(args.fn_ligand, m, sel) rb_ligand = atom.create_rigid_body(h_ligand) if args.dock: check_for_hexdock() if not args.fn_transforms or not args.fn_internal_transforms: raise IOError("Docking requires the --int and --hex arguments") hex_docking = HexDocking() hex_docking.dock(args.fn_receptor, args.fn_ligand, args.fn_transforms) # read the HEX file of solutions and get the internal transformations # giving the relative orientation of the ligand respect to the receptor Ts = read_hex_transforms(args.fn_transforms) rb_receptor = atom.create_rigid_body(h_receptor) Tis = [get_internal_transform(T, rb_receptor, rb_ligand) for T in Ts] io.write_transforms(Tis, args.fn_internal_transforms) elif args.write: # To write the positions correctly, the script requires that the # ligand file is the same that was used for the docking Tinternal = io.read_transforms(args.fn_internal_transforms) max_number = min(args.write, len(Tinternal)) Trec = rb_receptor.get_reference_frame().get_transformation_to() for i in range(max_number): Tdock = alg.compose(Trec, Tinternal[i]) ref = alg.ReferenceFrame3D(Tdock) rb_ligand.set_reference_frame(ref) atom.write_pdb(h_ligand,"docked-%03d.pdb" % i)
def create_dockings_from_xlinks(exp): """ Perform dockings that satisfy the cross-linking restraints. 1) Based on the number of restraints, creates an order for the docking between pairs of subunits, favouring the subunits with more crosslinks to be the "receptors" 2) Moves the subunits that are going to be docked to a position that satisfies the x-linking restraints. There is no guarantee that this position is correct. Its purpose is to help the docking algorithm with a clue of the proximity/orientation between subunits 3) Performs docking between the subunits 4) Filters the results of the docking that are not consistent with the cross-linking restraints 5) Computes the relative transformations between the rigid bodies of the subunits that have been docked @param exp Class with the parameters for the experiment """ log.info("Creating initial assembly from xlinks and docking") import docking_related as dock import buildxlinks as bx m = DominoModel.DominoModel() m.set_assembly_components(exp.fn_pdbs, exp.names) set_xlink_restraints(exp, m) order = bx.DockOrder() order.set_xlinks(m.xlinks) docking_pairs = order.get_docking_order() if hasattr(exp, "have_hexdock"): if not exp.have_hexdock: return for rec, lig in docking_pairs: pair_xlinks = m.xlinks.get_xlinks_for_pair((rec,lig)) log.debug("Xlinks for the pair %s %s %s",rec, lig, pair_xlinks) h_receptor = representation.get_component(m.assembly, rec) h_ligand = representation.get_component(m.assembly, lig) rb_receptor = representation.get_rigid_body(m.components_rbs, representation.get_rb_name(rec)) rb_ligand = representation.get_rigid_body(m.components_rbs, representation.get_rb_name(lig)) initial_ref = rb_ligand.get_reference_frame() # move to the initial docking position mv = bx.InitialDockingFromXlinks() mv.set_xlinks(pair_xlinks) mv.set_hierarchies(h_receptor, h_ligand) mv.set_rigid_bodies(rb_receptor, rb_ligand) mv.move_ligand() fn_initial_docking = "%s-%s_initial_docking.pdb" % (rec,lig) mv.write_ligand(fn_initial_docking) # dock hex_docking = dock.HexDocking() receptor_index = exp.names.index(rec) fn_transforms = "hex_solutions_%s-%s.txt" % (rec, lig) fn_docked = "%s-%s_hexdock.pdb" % (rec, lig) hex_docking.dock(exp.fn_pdbs[receptor_index], fn_initial_docking, fn_transforms, fn_docked, False) sel = atom.ATOMPDBSelector() new_m = IMP.Model() # After reading the file with the initial solution, the reference frame # for the rigid body of the ligand is not necessarily the same one # that it had when saved. # Thus reading the file again ensures consisten results when # using the HEXDOCK transforms new_h_ligand = atom.read_pdb(fn_initial_docking, new_m, sel) new_rb_ligand = atom.create_rigid_body(new_h_ligand) Tlig = new_rb_ligand.get_reference_frame().get_transformation_to() fn_filtered = "hex_solutions_%s-%s_filtered.txt" % (rec, lig) # h_ligand contains the coordinates of the ligand after moving it # to the initial position for the docking dock.filter_docking_results(h_receptor, new_h_ligand, pair_xlinks, fn_transforms, fn_filtered) # transforms to apply to the ligand as it is in the file # fn_initial_docking Thex = dock.read_hex_transforms(fn_filtered) Trec = rb_receptor.get_reference_frame().get_transformation_to() Tinternal = [] for i,T in enumerate(Thex): Tdock = alg.compose(T, Tlig) ref = alg.ReferenceFrame3D(Tdock) new_rb_ligand.set_reference_frame(ref) # internal transformation. The relationship is Tdock = Trec * Ti Ti = alg.compose(Trec.get_inverse(), Tdock) Tinternal.append(Ti) fn_relative = "relative_positions_%s-%s.txt" % (rec, lig) io.write_transforms(Tinternal, fn_relative) rb_ligand.set_reference_frame(initial_ref)
logging.root.setLevel(logging.DEBUG) sel = atom.ATOMPDBSelector() m = IMP.Model() h_receptor = atom.read_pdb(fn_receptor, m, sel) rb_receptor = atom.create_rigid_body(h_receptor) h_ligand = atom.read_pdb(fn_ligand, m, sel) rb_ligand = atom.create_rigid_body(h_ligand) if opts.dock: check_for_hexdock() if not opts.fn_transforms or not opts.fn_internal_transforms: raise IOError("Docking requires the --int and --hex arguments") hex_docking = HexDocking() hex_docking.dock(fn_receptor, fn_ligand, opts.fn_transforms) # read the HEX file of solutions and get the internal transformations # giving the relative orientation of the ligand respect to the receptor Ts = read_hex_transforms(opts.fn_transforms) Tis = [get_internal_transform(T, rb_receptor, rb_ligand) for T in Ts] io.write_transforms(Tis, opts.fn_internal_transforms) elif opts.write: # To write the positions correctly, the script requires that the # ligand file is the same that was used for the docking Tinternal = io.read_transforms(opts.fn_internal_transforms) max_number = min(opts.write, len(Tinternal)) Trec = rb_receptor.get_reference_frame().get_transformation_to() for i in range(max_number): Tdock = alg.compose(Trec, Tinternal[i]) ref = alg.ReferenceFrame3D(Tdock) rb_ligand.set_reference_frame(ref) atom.write_pdb(h_ligand,"docked-%03d.pdb" % i)