Example #1
0
def _minimize_step(sf, pose):
    mmap = MoveMap()
    mmap.set_bb(True)
    mmap.set_chi(False)
    mmap.set_jump(True)

    min_mover = MinMover(mmap, sf, "lbfgs_armijo_nonmonotone", 0.0001, True)
    min_mover.max_iter(1000)
    min_mover.apply(pose)
Example #2
0
def relax(pose):
    sf = create_score_function("ref2015")
    sf.set_weight(rosetta.core.scoring.atom_pair_constraint, 5)
    sf.set_weight(rosetta.core.scoring.dihedral_constraint, 1)
    sf.set_weight(rosetta.core.scoring.angle_constraint, 1)

    mmap = MoveMap()
    mmap.set_bb(True)
    mmap.set_chi(True)
    mmap.set_jump(True)

    relax = rosetta.protocols.relax.FastRelax()
    relax.set_scorefxn(sf)
    relax.max_iter(200)
    relax.dualspace(True)
    relax.set_movemap(mmap)

    switch = SwitchResidueTypeSetMover("fa_standard")
    switch.apply(pose)
    relax.apply(pose)
Example #3
0
def sample_docking(pdb_filename, partners,
        translation = 3.0, rotation = 8.0,
        jobs = 1, job_output = 'dock_output'):
    """
    Performs protein-protein docking using the Rosetta standard DockingProtocol
        on the proteins in  <pdb_filename>  using the relative chain
        <partners>  with an initial perturbation using  <translation>
        Angstroms and  <rotation>  degrees.  <jobs>  trajectories are performed
        with output structures named  <job_output>_(job#).pdb.
        structures are exported to a PyMOL instance.

    """
    # 1. creates a pose from the desired PDB file
    pose = Pose()
    pose_from_file(pose, pdb_filename)

    # 2. setup the docking FoldTree
    # using this method, the jump number 1 is automatically set to be the
    #    inter-body jump
    dock_jump = 1
    # the exposed method setup_foldtree takes an input pose and sets its
    #    FoldTree to have jump 1 represent the relation between the two docking
    #    partners, the jump points are the residues closest to the centers of
    #    geometry for each partner with a cutpoint at the end of the chain,
    # the second argument is a string specifying the relative chain partners
    #    such as "A_B" of "LH_A", ONLY TWO BODY DOCKING is supported and the
    #    partners MUST have different chain IDs and be in the same pose (the
    #    same PDB), additional chains can be grouped with one of the partners,
    #    the "_" character specifies which bodies are separated
    # the third argument...is currently unsupported but must be set (it is
    #    supposed to specify which jumps are movable, to support multibody
    #    docking...but Rosetta doesn't currently)
    # the FoldTrees setup by this method are for TWO BODY docking ONLY!
    protocols.docking.setup_foldtree(pose, partners, Vector1([dock_jump]))

    # 3. create centroid <--> fullatom conversion Movers
    to_centroid = SwitchResidueTypeSetMover('centroid')
    to_fullatom = SwitchResidueTypeSetMover('fa_standard')
    # and a Mover to recover sidechain conformations
    #    when a protocol samples backbone torsion space in centroid,
    #    the sidechain conformations are neglected, when it is transferred
    #    to fullatom, we typically set the sidechain conformations to their
    #    "original" values and perform sidechain packing,
    #    a ReturnSidechainMover saves a pose's sidechains (in this case
    #    staring_pose) and when applied, inserts these conformations
    #    into the input pose
    recover_sidechains = protocols.simple_moves.ReturnSidechainMover(pose)

    # 4. convert to centroid
    to_centroid.apply(pose)

    # 5. create a (centroid) test pose
    test_pose = Pose()
    test_pose.assign(pose)

    # 6. create ScoreFunctions for centroid and fullatom docking
    scorefxn_low = create_score_function('interchain_cen')
    scorefxn_high = create_score_function('docking')

    # PyRosetta3: scorefxn_high_min = create_score_function_ws_patch('docking', 'docking_min')
    scorefxn_high_min = create_score_function('docking', 'docking_min')

    # 7. create Movers for producing an initial perturbation of the structure
    # the DockingProtocol (see below) can do this but several Movers are
    #    used to demonstrate their syntax
    # these Movers randomize the orientation (rotation) of each docking partner
    randomize_upstream = RigidBodyRandomizeMover(pose, dock_jump,
        partner_upstream)
    randomize_downstream = RigidBodyRandomizeMover(pose, dock_jump,
        partner_downstream)
    # this Mover translates one docking partner away from the other in a random
    #    direction a distance specified by the second argument (in Angstroms)
    #    and rotates this partner randomly by the third argument (in degrees)
    dock_pert = RigidBodyPerturbMover(dock_jump, translation, rotation)
    # this Mover randomizes a pose's partners (rotation)
    spin = RigidBodySpinMover(dock_jump)
    # this Mover uses the axis defined by the inter-body jump (jump 1) to move
    #    the docking partners close together
    slide_into_contact = protocols.docking.DockingSlideIntoContact(dock_jump)

    # 8. setup the MinMover
    # the MoveMap can set jumps (by jump number) as degrees of freedom
    movemap = MoveMap()
    movemap.set_jump(dock_jump, True)
    # the MinMover can minimize score based on a jump degree of freedom, this
    #    will find the distance between the docking partners which minimizes
    #    the score
    minmover = protocols.minimization_packing.MinMover()
    minmover.movemap(movemap)
    minmover.score_function(scorefxn_high_min)

    # 9. create a SequenceMover for the perturbation step
    perturb = protocols.moves.SequenceMover()
    perturb.add_mover(randomize_upstream)
    perturb.add_mover(randomize_downstream)
    perturb.add_mover(dock_pert)
    perturb.add_mover(spin)
    perturb.add_mover(slide_into_contact)
    perturb.add_mover(to_fullatom)
    perturb.add_mover(recover_sidechains)
    perturb.add_mover(minmover)

    # 10. setup the DockingProtocol
    # ...as should be obvious by now, Rosetta applications have no central
    #    standardization, the DockingProtocol object can be created and
    #    applied to perform Rosetta docking, many of its options and settings
    #    can be set using the DockingProtocol setter methods
    # here, on instance is created with all default values and the movable jump
    #    is manually set to jump 1 (just to be certain), the centroid docking
    #    ScoreFunction is set and the fullatom docking ScoreFunction is set
    dock_prot = protocols.docking.DockingProtocol()    # contains many docking functions
    dock_prot.set_movable_jumps(Vector1([1]))    # set the jump to jump 1
    dock_prot.set_lowres_scorefxn(scorefxn_low)
    dock_prot.set_highres_scorefxn(scorefxn_high_min)
    #### you can alternatively access the low and high resolution sections of
    ####    the DockingProtocol, both are applied by the DockingProtocol but
    ####    a novel protocol may only require centroid (DockingLowRes) or
    ####    fullatom (DockingHighRes), uncomment the lines below and their
    ####    application below
    #docking_low = DockingLowRes()
    #docking_low.set_movable_jumps(Vector1([1]))
    #docking_low.set_scorefxn(scorefxn_low)
    #docking_high = DockingHighRes()
    #docking_high.set_movable_jumps(Vector1([1]))
    #docking_high.set_scorefxn(scorefxn_high)

    # 11. setup the PyJobDistributor
    jd = PyJobDistributor(job_output, jobs, scorefxn_high)
    temp_pose = Pose()    # a temporary pose to export to PyMOL
    temp_pose.assign(pose)
    to_fullatom.apply(temp_pose)    # the original pose was fullatom
    recover_sidechains.apply(temp_pose)    # with these sidechains
    jd.native_pose = temp_pose    # for RMSD comparison

    # 12. setup a PyMOL_Observer (optional)
    # the PyMOL_Observer object owns a PyMOLMover and monitors pose objects for
    #    structural changes, when changes are detected the new structure is
    #    sent to PyMOL
    # fortunately, this allows investigation of full protocols since
    #    intermediate changes are displayed, it also eliminates the need to
    #    manually apply the PyMOLMover during a custom protocol
    # unfortunately, this can make the output difficult to interpret (since you
    #    aren't explicitly telling it when to export) and can significantly slow
    #    down protocols since many structures are output (PyMOL can also slow
    #    down if too many structures are provided and a fast machine may
    #    generate structures too quickly for PyMOL to read, the
    #    "Buffer clean up" message
    # uncomment the line below to use the PyMOL_Observer
##    AddPyMOLObserver(test_pose, True)

    # 13. perform protein-protein docking
    counter = 0    # for pretty output to PyMOL
    while not jd.job_complete:
        # a. set necessary variables for this trajectory
        # -reset the test pose to original (centroid) structure
        test_pose.assign(pose)
        # -change the pose name, for pretty output to PyMOL
        counter += 1
        test_pose.pdb_info().name(job_output + '_' + str(counter))

        # b. perturb the structure for this trajectory
        perturb.apply(test_pose)

        # c. perform docking
        dock_prot.apply(test_pose)
        #### alternate application of the DockingProtocol pieces
        #docking_low.apply(test_pose)
        #docking_high.apply(test_pose)

        # d. output the decoy structure
        to_fullatom.apply(test_pose)    # ensure the output is fullatom
        # to PyMOL
        test_pose.pdb_info().name(job_output + '_' + str( counter ) + '_fa')
        # to a PDB file
        jd.output_decoy(test_pose)
print( "_____ Check point 1" )
pert_mover = rigid_moves.RigidBodyPerturbMover(jump_num, 8, 3)
#pert_mover.apply(pose)

randomize1 = rigid_moves.RigidBodyRandomizeMover(pose, jump_num, rigid_moves.partner_upstream)
randomize2 = rigid_moves.RigidBodyRandomizeMover(pose, jump_num, rigid_moves.partner_downstream)

print( "_____ Check point 2" )
#randomize1.apply(pose)
#randomize2.apply(pose)
slid = protocols.docking.DockingSlideIntoContact(jump_num)
slide = protocols.docking.FaDockingSlideIntoContact(jump_num)
slide.apply(pose)

movemap = MoveMap()
movemap.set_jump(jump_num, True)

scorefxn = create_score_function("ref2015")
scorefxn( pose )

print( "_____ Check point 3" )
print( 'Making MinMover...' )
min_mover = protocols.minimization_packing.MinMover()
min_mover.movemap(movemap)
min_mover.score_function(scorefxn)

#min_mover.apply(pose)

print( 'Done Applying MinMover!' )