def set_relative_movers(self, max_translation, max_rotation):
     """
         Generate the relative models form the transfors. The transforms
         is a list with triplets [id1, id2, transform_file]
         @param max_translation Maximum translation distance allowed for
             the moves
         @param nax_rotation Maximum rotation angle allowed for the moves
     """
     log.info("Setting relative movers")
     self.movers = []
     relative_movers = []
     relative_names = []
     for d in self.dock_transforms:
         rb_id = representation.get_rb_name(d[1])
         if rb_id not in relative_names:
             log.debug("Checking for %s", rb_id)
             rb_lig = representation.get_rigid_body(self.rbs, rb_id)
             mv = em2d.RelativePositionMover(rb_lig, max_translation,
                                                          max_rotation)
             relative_movers.append(mv)
             relative_names.append(rb_id)
             log.debug("added a RelativePositionMover for %s",rb_id)
         i = relative_names.index(rb_id)
         relative_movers[i].set_random_move_probability(
                                               self.non_relative_move_prob)
         rb_rec = representation.get_rigid_body(self.rbs,
                                      representation.get_rb_name(d[0]))
         log.debug("Reference added for %s: %s. ref. frame %s ",
                     rb_id, rb_rec.get_name(), rb_rec)
         Tis = io.read_transforms(d[2])
         relative_movers[i].add_internal_transformations(rb_rec, Tis)
     # add regular movers for the rigid bodies that are neither moved
     # anchored nor moved relative to others
     regular_movers = []
     for is_anchored, rb in zip(self.anchored, self.rbs):
         if(not is_anchored):
             name =rb.get_name()
             if(not name in relative_names):
                 log.debug("adding a RigidBodyMover for %s",name)
                 mv = core.RigidBodyMover(rb, max_translation, max_rotation)
                 regular_movers.append(mv)
     self.movers = regular_movers
     self.movers += relative_movers
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)