Beispiel #1
0
def apply_constraints(pose, cst_file='protease_design/ly104.cst'):
    """ Applies the constraints form the input CST file to a pose """
    cstm = AddOrRemoveMatchCsts()
    cstm.set_cst_action(ADD_NEW)
    cstm.cstfile(cst_file)
    cstm.apply(pose)
    return pose
Beispiel #2
0
def apply_enzdes_constraints(pose, cst_file):
    """ 
    Applies the constraints form the input CST file to a pose. Returns 
    constraied pose.
    """
    from pyrosetta.rosetta.protocols.enzdes import ADD_NEW, AddOrRemoveMatchCsts

    cstm = AddOrRemoveMatchCsts()
    cstm.set_cst_action(ADD_NEW)
    cstm.cstfile(cst_file)
    cstm.apply(pose)

    return pose
def main(args):
    # Destination folder for PDB files
    if args.out_dir:
        dir_name = args.out_dir
        if not isdir(dir_name):
            makedirs(dir_name)
    else:
        dir_name = ""

    # Creating coordinate constraints for the entire molecule
    cg = CoordinateConstraintGenerator()
    ac = AddConstraints()
    ac.add_generator(cg)

    # Create enzdes constraints
    if args.constraints:
        enz_cst = AddOrRemoveMatchCsts()
        enz_cst.set_cst_action(ADD_NEW)
    ''' Declare the score function. '''
    if args.symmetry:  # Declare symmetric score functions
        score_function = SymmetricScoreFunction()
        if args.repulsive_type == 'hard':
            if args.membrane:
                score_function.add_weights_from_file('franklin2019')
            else:
                score_function.add_weights_from_file('ref2015')
        elif args.repulsive_type == 'soft':
            if args.membrane:  # Set up a soft-rep version of franklin2019 manually
                score_function.add_weights_from_file('ref2015_soft')
                score_function.set_weight(ScoreType.fa_water_to_bilayer, 1.0)
            else:
                score_function.add_weights_from_file('ref2015_soft')
    else:  # Declare ordinary score functions
        if args.repulsive_type == 'hard':
            if args.membrane:
                score_function = create_score_function('franklin2019')
            else:
                score_function = create_score_function('ref2015')
        elif args.repulsive_type == 'soft':
            if args.membrane:  # Set up a soft-rep version of franklin2019 manually
                score_function = create_score_function('ref2015_soft')
                score_function.set_weight(ScoreType.fa_water_to_bilayer, 1.0)
            else:
                score_function = create_score_function('ref2015_soft')

    if args.coord_wt:
        score_function.set_weight(ScoreType.coordinate_constraint,
                                  args.coord_wt)

    if args.enzdes_wt:
        score_function.set_weight(ScoreType.atom_pair_constraint,
                                  args.enzdes_wt)
        score_function.set_weight(ScoreType.angle_constraint, args.enzdes_wt)
        score_function.set_weight(ScoreType.dihedral_constraint,
                                  args.enzdes_wt)

    # Loading PDB file
    pose = pose_from_pdb(args.pdb_file)

    if args.symmetry:  # Applying symmetry if specified
        sfsm = SetupForSymmetryMover(args.symmetry)
        sfsm.apply(pose)
        if args.membrane:  # Set up membrane for membrane protein
            add_memb = SymmetricAddMembraneMover(args.span_file)
            add_memb.apply(pose)
    else:
        if args.membrane:  # Set up membrane for membrane protein
            add_memb = AddMembraneMover(args.span_file)
            add_memb.apply(pose)

    # Creating FastRelax protocol with the given score function
    fr = FastRelax()
    fr.set_scorefxn(score_function)

    # Packer tasks
    tf = standard_task_factory()
    tf.push_back(IncludeCurrent())
    tf.push_back(ExtraRotamers(0, 1, 1))
    tf.push_back(ExtraRotamers(0, 2, 1))
    protein_selector = ResiduePropertySelector(ResidueProperty.PROTEIN)
    repack = RestrictToRepackingRLT()
    tf.push_back(OperateOnResidueSubset(repack, protein_selector))
    prevent = PreventRepackingRLT()
    tf.push_back(OperateOnResidueSubset(prevent, protein_selector, True))
    fr.set_task_factory(tf)

    move_map = MoveMap()
    if args.repulsive_type == 'hard':
        move_map.set_bb(True)
    elif args.repulsive_type == 'soft':
        ''' When using the soft-rep score function, backbone should be fixed. '''
        move_map.set_bb(False)
    protein_res_true_vector = protein_selector.apply(pose)
    move_map.set_chi(protein_res_true_vector)
    fr.set_movemap(move_map)

    # Determining file name
    if args.name:
        file_name = args.name
    else:
        file_name = basename(args.pdb_file).replace('.pdb', '_relaxed')

    out_name = join(dir_name, file_name)

    # Applying constraints

    ac.apply(pose)
    if args.constraints:
        enz_cst.apply(pose)

    # RMSD metric
    rmsdm = RMSDMetric()
    rmsdm.set_comparison_pose(pose)

    print(tf.create_task_and_apply_taskoperations(pose))

    # Running relax set
    jd = PyJobDistributor(out_name, args.n_decoys, score_function)
    while not jd.job_complete:
        pp = Pose()
        pp.assign(pose)
        fr.apply(pp)
        rmsdm.apply(pp)
        jd.output_decoy(pp)