예제 #1
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)
예제 #2
0
def pose_from_params(filename, params_list):
    pose = Pose()

    rts = pose.conformation().modifiable_residue_type_set_for_conf(
        core.chemical.FULL_ATOM_t)
    rts.read_files_for_base_residue_types(Vector1(params_list))
    pose.conformation().reset_residue_type_set_for_conf(rts)

    pose_from_file(pose, pose.residue_type_set_for_pose(), filename)
    return pose
예제 #3
0
 def add_residuetype(
     self, pose: pyrosetta.Pose
 ) -> pyrosetta.rosetta.core.chemical.ResidueTypeSet:
     rts = pose.conformation().modifiable_residue_type_set_for_conf(
         pyrosetta.rosetta.core.chemical.FULL_ATOM_t)
     buffer = pyrosetta.rosetta.std.stringbuf(self.dumps())
     stream = pyrosetta.rosetta.std.istream(buffer)
     new = pyrosetta.rosetta.core.chemical.read_topology_file(
         stream, self.NAME, rts)  # no idea what the second argument does
     rts.add_base_residue_type(new)
     return rts
예제 #4
0
def pose_from_pubchem(cid, name, temporary=True):
    pose = Pose()
    if temporary:
        # the temporary solution, create an ephemeral ResidueSet
        params_from_pubchem(cid, name)

        # Add the new ResidueType to the pose
        rts = pose.conformation().modifiable_residue_type_set_for_conf(
            core.chemical.FULL_ATOM_t)
        rts.add_base_residue_type(name)
        pose.conformation().reset_residue_type_set_for_conf(rts)

        # fill the pose
        pose_from_file(pose, pose.residue_type_set_for_pose(),
                       name + "_0001.pdb")
    else:
        # permanent solution, add to .params list
        add_cid_to_database(cid, name)

        # fill the pose
        pose_from_file(pose, name + "_0001.pdb")
    return pose
def sample_ligand_interface(pdb_filename,
                            partners,
                            ligand_params=[''],
                            jobs=1,
                            job_output='ligand_output'):
    """
    Performs ligand-protein docking using Rosetta fullatom docking
        (DockingHighRes) on the ligand-protein complex in  <pdb_filename>
        using the relative chain  <partners>  .
        If the ligand parameters (a .params file, see below) are not defaultly
        loaded into PyRosetta,  <ligand_params>  must supply the list of files
        including the ligand parameters.
        <jobs>  trajectories are performed with output structures named
        <job_output>_(job#).pdb.
    """
    # 1. creates a pose from the desired PDB file
    pose = Pose()

    if len(ligand_params
           ) != 0 and ligand_params[0] != '':  # the params list has contents
        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)

    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('ligand')

    #### 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 ligand-protein
    ####    prediction is not possible and as such, only the high-resolution
    ####    ligand-protein interface refinement is available
    #### WARNING: if you add a perturbation or randomization step, the
    ####    high-resolution stages may fail (see Changing Ligand Docking
    ####    Sampling below)
    #### a perturbation step CAN make this a global docking algorithm however
    ####    the rigid-body sampling preceding refinement requires 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
    # there is currently no centroid representation of an arbitrary ligand in
    #    the chemical database, although you can check to see if it is already
    #    present or make your own (see "Obtaining Params Files" below), and
    #    without a centroid representation, the low-resolution docking stages
    #    are not useful for ligand docking
    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 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)
예제 #6
0
at5C = res5.atom("C")

print(at5N)
# TODO: above should print atom type key not magic number
# 2/23/9: hm, not sure this is possible b/c atom does not know which AtomTypeSet to use!

print('xyz of at5N:', at5N.xyz().x, at5N.xyz().y, at5N.xyz().z)
print('norm of xyz at5N:', at5N.xyz().norm)

print(res5.atoms())  # <-- Still missing

atomN = AtomID(1, 5)
atomCA = AtomID(2, 5)
atomC = AtomID(3, 5)
print('bond length of N-CA in residue 5 is ')
print(pose.conformation().bond_length(atomN, atomCA))
print('bond angle of N-CA-C in residue 5 is ')
print(pose.conformation().bond_angle(atomN, atomCA, atomC))
print('setting bond length of N-CA in residue 5 to 1.5A ')
pose.conformation().set_bond_length(atomN, atomCA, 1.5)
print('setting bond angle of N-CA-C in residue 5 to 90 ')
pose.conformation().set_bond_angle(atomN, atomCA, atomC, 90)
# TODO: make the above work with atom objects instead of atomIDs

print('pose was generated from this pdb file: ', pose.pdb_info().name())
print('pose numbering for chain A, residue 5, is ',
      pose.pdb_info().pdb2pose('A', 5))
print('pdb chain letter and residue number for residue 5, is ',
      pose.pdb_info().pose2pdb(5))
# TODO: pdb_info.* does not tab-complete
예제 #7
0
from __future__ import print_function

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)