Example #1
0
def pep_run(decoy_name, n_decoys, pose, sf='docking', pymol_ip_addr=None):
    """
    Tested score function is 'docking' not sure if this is the best. Is there a way to run this in a 
    distributed fashion? Each decoy takes ~3 minutes on my machine.
    """
    if pymol_ip_addr:
        pmm = PyMOLMover(pymol_ip_addr,
                         65000)  #enter the IP that pymol displays on startup
        pmm.keep_history(True)

    # Score function and starting PDB
    sf = create_score_function(sf)  # no idea what this sf is...
    #pose = pose_from_pdb(pdb)

    # Creating FlexPepDock protocol using init options
    fpdock = FlexPepDockingProtocol()

    jd = PyJobDistributor(decoy_name, n_decoys, sf)
    while not jd.job_complete:
        pp = Pose()
        pp.assign(pose)
        fpdock.apply(pp)
        if pymol_ip_addr:
            pmm.apply(pp)
        jd.output_decoy(
            pp)  # this will output a PDB file, which is not really necessary.
###################################################################
## Loop through and store lowest energy docking pose
lowest_energy_pose = Pose()
lowest_energy = float('inf')

for i in range(3):
    # rotate and translate superantigen (8 degrees rot, 3 ang trans)
    pert_mover = rigid_moves.RigidBodyPerturbMover(jump_num, 8, 3)
    pert_mover.apply(fa_working)

    # minimize the energy
    min_mover.apply(fa_working)

    # score pose
    print('working pose energy: ')
    curr_score = scorefxn(fa_working)
    print(curr_score)

    # store values
    if curr_score < lowest_energy:
        lowest_energy = curr_score

###################################################################

# see in PyMOL
pymol = PyMOLMover()
pymol.keep_history(True)
pymol.apply(fa_starting)
pymol.apply(fa_working)
Example #3
0
OUT = sys.argv[3]
weight_file = sys.argv[4]

from pyrosetta import *
from rosetta import *
from rosetta.protocols.rigid import *
from rosetta.core.scoring import *
from pyrosetta import PyMOLMover
from rosetta.protocols.rigid import *
import pyrosetta.rosetta.protocols.rigid as rigid_moves
from pyrosetta.rosetta.protocols.minimization_packing import MinMover

init()

pmm = PyMOLMover()
pmm.keep_history(True)

#os.system('mkdir working_dir')
working_dir = os.getcwd()
#os.system('cd working_dir')


def add_cst(pose, resi, resj, lb, up):
    res_i = pose.pdb_info().pdb2pose('A', res=resi)

    res_j = pose.pdb_info().pdb2pose('B', res=resj)

    if res_i != 0 and res_j != 0:

        atm_i = 'CA' if pose.residue(res_i).name()[0:3] == 'GLY' else 'CB'
        atm_j = 'CA' if pose.residue(res_j).name()[0:3] == 'GLY' else 'CB'
Example #4
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)