Beispiel #1
0
 def pose(self):
   """ Loads the PDBMapStructure as a Rosetta::Pose object """
   import_rosetta()
   io = PDBIO()
   io.set_structure(self.structure)
   with tempfile.NamedTemporaryFile('wrb',suffix='.pdb',delete=False) as tf:
     io.save(tf.name)
   pose = rosetta.Pose()
   rosetta.pose_from_pdb(pose,tf.name)
   os.remove(tf.name)
   return pose
Beispiel #2
0
def extrapolate_repeat_pose(Repeat1Pose, Repeat2Pose, Duplications):
    '''  MUST give two overlapping, equal length, one-repeat-unit long poses !!!  '''
    assert Repeat1Pose.n_residue() == Repeat2Pose.n_residue(
    ), ' Repeat poses must be same length '
    RepeatLength = Repeat1Pose.n_residue()
    Residues = [P for P in range(1, RepeatLength + 1)]

    # First fusion is easy since the input poses contain duplicate residues
    FusionPose, RMSD, CorrespondingResidues = fuse(Repeat1Pose, Repeat2Pose)
    #
    # Copy and store first subunit as base unit for subsequent transformations/fusions
    FusionBasePose = rosetta.Pose()
    FusionBasePose.assign(FusionPose)
    # rosetta.dump_pdb(FusionBasePose, 'FusionBasePose.pdb')

    # Umatched region should be N terminal region of repeat pose 1 without matching pose 2 residues
    # Used repeated during loop below to superimpose on to end of growing fusion pose
    UnmatchedPose1Residues = [
        Number for Number in range(1, CorrespondingResidues[0][0])
    ]

    # N-terminal end of repeat unit pose 1 that extends past repeat unit pose 2
    NterminalUnmatchedArray = get_residue_array(Repeat1Pose,
                                                UnmatchedPose1Residues)

    # one iteration is run for each duplication event,
    # each time add a fusion pose to end of growing
    for Duplication in range(Duplications):
        # Grabs residue from back of RepeatPose2 for each unmatched residue at begining of Pose1
        EndMatch = []
        # also start making array of coord
        for UnmatchResidue in UnmatchedPose1Residues:
            EndMatch.append(Residues[-1 * UnmatchResidue])

        EndMatch.reverse()
        EndMatchArray = get_residue_array(Repeat2Pose, EndMatch)

        # print 'EndMatch', EndMatch
        RMSD, rMtx, tVec = solenoid_tools.rmsd_2_np_arrays_rosetta(
            EndMatchArray, NterminalUnmatchedArray)
        # print 'Corse RMSD:  ', RMSD
        # print 'rMtx:  ', rMtx
        # print 'tVec:  ', tVec

        DuplicatePose = rosetta.Pose()
        DuplicatePose.assign(FusionBasePose)
        rosetta.Pose.apply_transform_Rx_plus_v(DuplicatePose, rMtx, tVec)
        # rosetta.dump_pdb(DuplicatePose, 'Dup%d_DuplicatePose.pdb'%Duplication)

        FusionPose, RMSD, CorrespondingResidues = fuse(FusionPose,
                                                       DuplicatePose)
        # print 'Refined RMSD', RMSD
        # rosetta.dump_pdb(FusionPose, 'Dup%d_FusionPose.pdb'%Duplication)

        NterminalUnmatchedArray = get_residue_array(FusionPose,
                                                    UnmatchedPose1Residues)

        Residues = [P for P in range(1, FusionPose.n_residue() + 1)]
        Repeat2Pose = rosetta.Pose()
        Repeat2Pose.assign(FusionPose)
        # rosetta.dump_pdb(Repeat2Pose, 'Dup%d_NewRepeat2Pose.pdb'%Duplication)

    return FusionPose
Beispiel #3
0
                r: rosetta.protocols.moves.XC_red,
                1 + N - r: rosetta.protocols.moves.XC_white
            }
            #print r, N, C
            pymol.send_colors(pose,
                              C,
                              default_color=rosetta.protocols.moves.XC_blue)

            #pymol.send_energy( pose_s )

            time.sleep(.1)


rosetta.init()

pose = rosetta.Pose()
pose.name = 'CustomNamedPose'
pose_s = rosetta.Pose()
rosetta.pose_from_pdb(pose, "test/data/test_in.pdb")
rosetta.pose_from_pdb(pose_s, "test/data/test_in_short.pdb")

scorefxn = rosetta.create_score_function('standard')
scorefxn(pose)

pymol = rosetta.PyMOL_Mover()

pymol.apply(pose_s)
coloring_demo(pose_s)

seq = rosetta.protocols.moves.SequenceMover()
seq.add_mover(pymol)
Beispiel #4
0
def mutate_residue(pose, mutant_position, mutant_aa, pack_radius=0.0,
                                                             pack_scorefxn=''):
    """Replace the residue at <mutant_position> in <pose> with <mutant_aa> and
    repack any residues within <pack_radius> angstroms of the mutating
    residue's center (nbr_atom) using <pack_scorefxn>

    Note: <mutant_aa> is the single letter name for the desired ResidueType

    Example:
        mutate_residue(pose, 30, "A")
    See also:
        Pose
        PackRotamersMover
    """
    if not pose.is_fullatom():
        IOError('mutate_residue() only works with full-atom poses.')

    test_pose = rosetta.Pose()
    test_pose.assign(pose)

    # create a standard scorefxn by default
    if not pack_scorefxn:
        pack_scorefxn = rosetta.get_fa_scorefxn()

    task = rosetta.standard_packer_task(test_pose)
    task.or_include_current(True)

    # A vector1 of booleans (a specific object) is needed for specifying the
    # mutation.  This demonstrates another more direct method of setting
    # PackerTask options for design.
    aa_bool = rosetta.utility.vector1_bool()

    # PyRosetta uses several ways of tracking amino acids (ResidueTypes).
    # The numbers 1-20 correspond individually to the 20 proteogenic amino
    # acids.  aa_from_oneletter_code() returns the integer representation of an
    # amino acid from its one letter code

    # Convert mutant_aa to its integer representation.
    mutant_aa = rosetta.aa_from_oneletter_code(mutant_aa)

    # The mutation is performed by using a PackerTask with only the mutant
    # amino acid available during design.  To do this, we construct a vector1
    # of booleans indicating which amino acid (by its numerical designation;
    # see above) to allow.
    for i in range(1, 20 + 1):
        # In Python, logical expression are evaluated with priority, thus the
        # line below appends to aa_bool the truth (True or False) of the
        # statement i == mutant_aa.
        aa_bool.append(i == mutant_aa)

    # Modify the mutating residue's assignment in the PackerTask using the
    # vector1 of booleans across the proteogenic amino acids.
    task.nonconst_residue_task(mutant_position).restrict_absent_canonical_aas(
                                                                       aa_bool)

    # Prevent residues from packing by setting the per-residue "options" of
    # the PackerTask.
    center = pose.residue(mutant_position).nbr_atom_xyz()
    for i in range(1, pose.total_residue() + 1):
        # Only pack the mutating residue and any within the pack_radius
        if not i == mutant_position or center.distance_squared(
                         test_pose.residue(i).nbr_atom_xyz()) > pack_radius**2:
            task.nonconst_residue_task(i).prevent_repacking()

    # Apply the mutation and pack nearby residues.
    packer = rosetta.PackRotamersMover(pack_scorefxn, task)
    packer.apply(test_pose)

    return test_pose
Beispiel #5
0
def main():

    parent_path = "/Users/yanxia/Documents/Workspace/PyRosetta_Practice/"
    resource_path = parent_path + "resources"
    os.chdir(resource_path)

    rosetta.init()
    # initiate pose and two score functions
    pose = rosetta.Pose()
    rosetta.make_pose_from_sequence(
        pose, "GSSGSSGTGVKPYGCSQCAKTFSLKSQLIVHQRSHTGVKPSGPSSG", "centroid")

    fa_scorefxn = rosetta.create_score_function("standard")
    ct_scorefxn = rosetta.create_score_function("score3")
    kt_value = 1

    # initiate fragment set
    fragmentSet9 = rosetta.ConstantLengthFragSet(9)
    fragmentSet3 = rosetta.ConstantLengthFragSet(3)
    fragmentSet9.read_fragment_file("zf_9mer.txt")
    fragmentSet3.read_fragment_file("zf_3mer.txt")

    # set up movemap and Fragment Mover
    movemap = rosetta.MoveMap()
    movemap.set_bb(True)
    move_9mer = rosetta.ClassicFragmentMover(fragmentSet9, movemap)
    move_3mer = rosetta.ClassicFragmentMover(fragmentSet3, movemap)

    # Monte Carlo
    mc_low = rosetta.MonteCarlo(pose, ct_scorefxn, kt_value)

    #set up small and shear movers
    n_moves = 5
    small_mover = rosetta.SmallMover(movemap, kt_value, n_moves)
    shear_mover = rosetta.ShearMover(movemap, kt_value, n_moves)

    #set up minimize mover
    min_mover = rosetta.MinMover()
    min_mover.movemap(movemap)
    min_mover.score_function(fa_scorefxn)
    min_mover.min_type("linmin")
    min_mover.tolerance(0.5)

    #set up sequence mover and repeat mover
    seq_mover = rosetta.SequenceMover()
    seq_mover.add_mover(small_mover)
    seq_mover.add_mover(min_mover)
    seq_mover.add_mover(shear_mover)
    seq_mover.add_mover(min_mover)

    # folding
    # first low resolution

    #ct_switch = rosetta.SwitchResidueTypeSetMover("centroid")
    #ct_switch.apply(pose)
    low_res_folding(pose, move_9mer, move_3mer, mc_low)

    # high resolution
    fa_switch = rosetta.SwitchResidueTypeSetMover("fa_standard")
    fa_switch.apply(pose)
    mc_high = rosetta.MonteCarlo(pose, fa_scorefxn, kt_value)

    for i in range(5):
        print "before: ", fa_scorefxn(pose)
        max_angle = 25 - 5 * i
        small_mover.angle_max("H", max_angle)
        small_mover.angle_max("E", max_angle)
        small_mover.angle_max("S", max_angle)
        shear_mover.angle_max("H", max_angle)
        shear_mover.angle_max("E", max_angle)
        shear_mover.angle_max("S", max_angle)

        for _ in range(simulation_iter):
            seq_mover.apply(pose)
            mc_high.boltzmann(pose)

        print "after: ", fa_scorefxn(pose)

    result_path = parent_path + "results/"
    os.chdir(result_path)
    pose.dump_pdb("ara.pdb")
    print "Done!"