示例#1
0
def redock(pose,partners):
    dock_jump = 1 # jump number 1 is the inter-body jump
    pyrosetta.rosetta.protocols.docking.setup_foldtree(pose,partners,Vector1([dock_jump]))

    # Create ScoreFunctions for centroid and fullatom docking
    scorefxn = pyrosetta.create_score_function("ref2015.wts")

    # Setup the high resolution (fullatom) docking protocol using DockMCMProtocol.
    docking = pyrosetta.rosetta.protocols.docking.DockMCMProtocol()
    # Many of its options and settings can be set using the setter methods.
    docking.set_scorefxn(scorefxn)

    # # Set the native pose so that the output scorefile contains the pose rmsd metric
    # native_pose = pose 

    # # Optional: setup a PyMOLObserver
    # # pyrosetta.rosetta.protocols.moves.AddPyMOLObserver(test_pose, True)

    # # Perform protein-ligand docking
    # # counter = 0 # for pretty output to PyMOLObserver

    # test_pose = pose.clone() # Reset test pose to original structure
        
    # counter += 1 # Change the pose name, for pretty output to PyMOLObserver
    # test_pose.pdb_info().name(job_output + '_' + str(counter))
        
    # Perform docking and output to PyMOL:
    # print('DOCKING'*100)
    docking.apply(pose) 
示例#2
0
    def redock(self, hires=True, perturb=False, TRANS_PERT=0.05, ROT_PERT=1):
        # setup the docking FoldTree
        # using this method, the jump number 1 is automatically set to be the
        #    inter-body jump
        dock_jump = 1
        protocols.docking.setup_foldtree(self.pose, self.partners,
                                         Vector1([dock_jump]))

        # create ScoreFunctions for centroid and fullatom docking
        self.scorefxn = create_score_function('ref2015')

        # setup the high resolution (fullatom) docking protocol (DockMCMProtocol)

        hiresdocker = protocols.docking.DockMCMProtocol()
        hiresdocker.set_scorefxn(self.scorefxn)
        hiresdocker.set_first_cycle(4)
        hiresdocker.set_second_cycle(20)
        self.hiresdocker = hiresdocker

        # Setup perturber
        dockperturb = RigidBodyPerturbMover(dock_jump, TRANS_PERT, ROT_PERT)
        self.perturber = dockperturb

        if hires:
            self.hiresdocker.apply(self.pose)
        elif perturb:
            self.perturber.apply(self.pose)
示例#3
0
def get_pose_with_ligand(filepath, LIGAND_PARAMS=[]):
    pose = Pose()
    ligand_params = Vector1(LIGAND_PARAMS)
    res_set = pose.conformation().modifiable_residue_type_set_for_conf()
    res_set.read_files_for_base_residue_types(ligand_params)
    pose.conformation().reset_residue_type_set_for_conf(res_set)
    return pose_from_file(filepath)
示例#4
0
def sample_dna_interface(pdb_filename,
                         partners,
                         jobs=1,
                         job_output='dna_output'):
    """
    Performs DNA-protein docking using Rosetta fullatom docking (DockingHighRes)
        on the DNA-protein complex in  <pdb_filename>  using the relative chain
        <partners>  .
        <jobs>  trajectories are performed with output structures named
        <job_output>_(job#).pdb.

    """
    # 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 orientation
    #    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 a copy of the pose for testing
    test_pose = Pose()
    test_pose.assign(pose)

    # 4. create ScoreFunctions for centroid and fullatom docking
    scorefxn = create_score_function('dna')
    scorefxn.set_weight(core.scoring.fa_elec, 1)  # an "electrostatic" term

    #### global docking, a problem solved by the Rosetta DockingProtocol,
    ####    requires interface detection and refinement
    #### as with other protocols, these tasks are split into centroid (interface
    ####    detection) and high-resolution (interface refinement) methods
    #### without a centroid representation, low-resolution DNA-protein
    ####    prediction is not possible and as such, only the high-resolution
    ####    DNA-protein interface refinement is available
    #### WARNING: if you add a perturbation or randomization step, the
    ####    high-resolution stages may fail (see Changing DNA Docking
    ####    Sampling below)
    #### a perturbation step CAN make this a global docking algorithm however
    ####    the rigid-body sampling preceding refinement will require EXTENSIVE
    ####    sampling to produce accurate results and this algorithm spends most
    ####    of its effort in refinement (which may be useless for the predicted
    ####    interface)

    # 5. setup the high resolution (fullatom) docking protocol (DockMCMProtocol)
    # ...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
    # as there is currently no centroid representation of DNA in the chemical
    #    database, the low-resolution docking stages are not useful for
    #    DNA docking
    # instead, create an instance of just the high-resolution docking stages
    docking = protocols.docking.DockMCMProtocol()
    docking.set_scorefxn(scorefxn)

    # 6. setup the PyJobDistributor
    jd = PyJobDistributor(job_output, jobs, scorefxn)

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

    # 8. 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. perform docking
        docking.apply(test_pose)

        # c. output the decoy structure:
        # to PyMOL
        test_pose.pdb_info().name(job_output + '_' + str(counter) + '_fa')
        # to a PDB file
        jd.output_decoy(test_pose)
示例#5
0
ex.ex1(True)
ex.ex2(True)
ex.extrachi_cutoff(1)

tf = core.pack.task.TaskFactory()
tf.push_back(core.pack.task.operation.RestrictToRepacking())
tf.push_back(
    core.pack.task.operation.OperateOnResidueSubset(ex,
                                                    protein_interface_sele))

task = tf.create_task_and_apply_taskoperations(pose)
rotsets = core.pack.rotamer_set.RotamerSetsFactory.create_rotamer_sets(pose)
ig = core.pack.interaction_graph.AnnealableGraphBase()

basic.options.set_string_vector_option(
    'out:levels',
    Vector1(['core.pack.rotamer_set.RotamerSet_.extra_rotamers:500']))

core.pack.pack_rotamers_setup(pose, sfxn, task, rotsets, ig)

print('*' * 80)
print('*' * 80)
print('*' * 80)

basic.options.set_string_vector_option(
    'out:levels',
    Vector1(['core.pack.rotamer_set.RotamerSet_.extra_rotamers:100']))
#basic.options.set_string_vector_option('out:mute', Vector1(['core.pack.rotamer_set.RotamerSet_.extra_rotamers']))

core.pack.pack_rotamers_setup(pose, sfxn, task, rotsets, ig)
示例#6
0
import pyrosetta
import pyrosetta.rosetta as rosetta

from pyrosetta import init, Pose, Vector1, create_score_function
from pyrosetta.rosetta import core, protocols

init(extra_options = "-constant_seed")  # WARNING: option '-constant_seed' is for testing only! MAKE SURE TO REMOVE IT IN PRODUCTION RUNS!!!!!
import os; os.chdir('.test.output')

print('testing ligand modeling')
ligand_p = Pose()

params_list = ['../test/data/ligand.params']
rts = ligand_p.conformation().modifiable_residue_type_set_for_conf( core.chemical.FULL_ATOM_t )
rts.read_files_for_base_residue_types( Vector1(params_list) )
ligand_p.conformation().reset_residue_type_set_for_conf( rts )

core.import_pose.pose_from_file(ligand_p, "../test/data/ligand_test.pdb")

scorefxn = create_score_function("ligand")
scorefxn(ligand_p)

print('testing DNA modeling')
dna_p = Pose()
core.import_pose.pose_from_file(dna_p, "../test/data/dna_test.pdb")

scorefxn = create_score_function("dna")
scorefxn(dna_p)

print('Done!')
示例#7
0
# :noTabs=true:
# (c) Copyright Rosetta Commons Member Institutions.
# (c) This file is part of the Rosetta software suite and is made available under license.
# (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
# (c) For more information, see http://www.rosettacommons.org. Questions about this can be
# (c) addressed to University of Washington CoMotion, email: [email protected].

## @author Sergey Lyskov

from __future__ import print_function

import pyrosetta
from pyrosetta import Vector1, version

print(Vector1([1, 2, 3, 4]))
print(Vector1([1, 2, 3, 4.5]))
print(Vector1(['a', 'b', 'c', 'd']))

print('Testing Python bindings for Rosetta...')
print('Init...')
pyrosetta.init()

print(pyrosetta._version_string())
print(version())
示例#8
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)
示例#9
0
def scanning(pdb_filename,
             partners,
             mutant_aa='A',
             interface_cutoff=8.0,
             output=False,
             trials=1,
             trial_output=''):
    """
    Performs "scanning" at an interface within  <pdb_filename>  between
        <partners>  by mutating relevant residues to  <mutant_aa>  and repacking
        residues within  <pack_radius>  Angstroms, further repacking all
        residues within  <interface_cutoff>  of the interface residue, scoring
        the complex and subtracting the score of a pose with the partners
        separated by 500 Angstroms.
        <trials>  scans are performed (to average results) with summaries written
        to  <trial_output>_(trial#).txt.
        Structures are exported to a PyMOL instance.

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

    # 2. setup the docking FoldTree and other related parameters
    dock_jump = 1
    movable_jumps = Vector1([dock_jump])
    protocols.docking.setup_foldtree(pose, partners, movable_jumps)

    # 3. create ScoreFuncions for the Interface and "ddG" calculations
    # the pose's Energies objects MUST be updated for the Interface object to
    #    work normally
    scorefxn = get_fa_scorefxn()  #  create_score_function('standard')
    scorefxn(pose)  # needed for proper Interface calculation

    # setup a "ddG" ScoreFunction, custom weights
    ddG_scorefxn = ScoreFunction()
    ddG_scorefxn.set_weight(core.scoring.fa_atr, 0.44)
    ddG_scorefxn.set_weight(core.scoring.fa_rep, 0.07)
    ddG_scorefxn.set_weight(core.scoring.fa_sol, 1.0)
    ddG_scorefxn.set_weight(core.scoring.hbond_bb_sc, 0.5)
    ddG_scorefxn.set_weight(core.scoring.hbond_sc, 1.0)

    # 4. create an Interface object for the pose
    interface = Interface(dock_jump)
    interface.distance(interface_cutoff)
    interface.calculate(pose)

    # 5. create a PyMOLMover for sending output to PyMOL (optional)
    pymover = PyMOLMover()
    pymover.keep_history(True)  # for multiple trajectories
    pymover.apply(pose)
    pymover.send_energy(pose)

    # 6. perform scanning trials
    # the large number of packing operations introduces a lot of variability,
    #    for best results, perform several trials and average the results,
    #    these score changes are useful to QUALITATIVELY defining "hotspot"
    #    residues
    # this script does not use a PyJobDistributor since no PDB files are output
    for trial in range(trials):
        # store the ddG values in a dictionary
        ddG_mutants = {}
        for i in range(1, pose.total_residue() + 1):
            # for residues at the interface
            if interface.is_interface(i) == True:
                # this way you can TURN OFF output by providing False arguments
                #    (such as '', the default)
                filename = ''
                if output:
                    filename = pose.pdb_info().name()[:-4] + '_' +\
                        pose.sequence()[i-1] +\
                        str(pose.pdb_info().number(i)) + '->' + mutant_aa
                # determine the interace score change upon mutation
                ddG_mutants[i] = interface_ddG(pose, i, mutant_aa,
                                               movable_jumps, ddG_scorefxn,
                                               interface_cutoff, filename)

        # output results
        print('=' * 80)
        print('Trial', str(trial + 1))
        print(
            'Mutants (PDB numbered)\t\"ddG\" (interaction dependent score change)'
        )
        residues = list(ddG_mutants.keys()
                        )  # list(...) conversion is for python3 compatbility
        residues.sort()  # easier to read
        display = [
            pose.sequence()[i - 1] + str(pose.pdb_info().number(i)) +
            mutant_aa + '\t' + str(ddG_mutants[i]) + '\n' for i in residues
        ]
        print(''.join(display)[:-1])
        print('=' * 80)

        # write to file
        f = open(trial_output + '_' + str(trial + 1) + '.txt', 'w')
        f.writelines(display)
        f.close()

    #### alternate output using scanning_analysis (see below), only display
    ####    mutations with "deviant" score changes
    print('Likely Hotspot Residues')
    for hotspot in scanning_analysis(trial_output):
        print(hotspot)
    print('=' * 80)
示例#10
0
init(extra_options = "-constant_seed")  # WARNING: option '-constant_seed' is for testing only! MAKE SURE TO REMOVE IT IN PRODUCTION RUNS!!!!!
import os; os.chdir('.test.output')


'''
for _i in range(10):
    try:
'''

# Docking Moves in Rosetta
pose = pose_from_file("../test/data/workshops/complex.start.pdb")

print( pose.fold_tree() )

protocols.docking.setup_foldtree(pose, "A_B", Vector1([1]))
print( pose.fold_tree() )

jump_num = 1
print( pose.jump(jump_num).get_rotation() )
print( pose.jump(jump_num).get_translation() )

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)