示例#1
0
def get_relaxer_mover(pose,
                      score_function=DEFAULT.score_function,
                      no_constraints=DEFAULT.no_constraints,
                      c_weight=DEFAULT.c_weight):
    """
    TO DO
    """

    if score_function == "auto":
        try:
            score_function = get_fa_scorefxn()
        except:
            import pyrosetta
            init()
            score_function = get_fa_scorefxn()
    else:
        from pyrosetta.rosetta.core.scoring import ScoreFunction
        assert type(score_function) == ScoreFunction, \
            "Score function for relaxer mover must be of type ScoreFunction."

    if no_constraints == False:
        coordinates_constraint = CoordinateConstraintGenerator()
        constraints = AddConstraints()
        constraints.add_generator(coordinates_constraint)
        constraints.apply(pose)
        activate_constraints(score_function, c_weight)
    task_factory = standard_task_factory()
    task_factory.push_back(ExtraRotamers(0, 2, 1))
    task_factory.push_back(RestrictToRepacking())
    task_factory.push_back(IncludeCurrent())
    fast_relax = FastRelax()
    fast_relax.set_scorefxn(score_function)
    fast_relax.set_task_factory(task_factory)

    return fast_relax
def coord_constrain_peptide(pose, selection=ChainSelector('B')):
    """ Applies backbone coordinate constraints to a selection of a pose """
    cg = CoordinateConstraintGenerator()
    if selection:
        cg.set_residue_selector(selection)
    ac = AddConstraints()
    ac.add_generator(cg)
    ac.apply(pose)
    return pose
def coord_constrain_pose(pose):
    """
   Applies coordinate constraints if needed to selected residues
   """
    print_out("Applying Constraints")
    ccg = CoordinateConstraintGenerator()
    ccg.set_bounded_width(0.2)
    ccg.set_bounded(True)
    ccg.set_ca_only(True)
    ccg.set_sd(0.5)
    ac = AddConstraints()
    ac.add_generator(ccg)
    ac.apply(pose)

    return pose
示例#4
0
def apply_constraints(pose):
    """ 
	Applies enzdes constraints from the input CST file to a pose
	Also applies coordinate constraints to the original substrate peptide
	which is assumed correct from the PDB
	"""
    # Enzdes constraints
    cstm = AddOrRemoveMatchCsts()
    cstm.set_cst_action(ADD_NEW)
    cstm.apply(pose)

    # Coordinate constraints
    cg = CoordinateConstraintGenerator()
    cs = ResidueIndexSelector('213-216')
    cg.set_residue_selector(cs)

    ac = AddConstraints()
    ac.add_generator(cg)
    ac.apply(pose)

    return
示例#5
0
def apply_constraints(pose):
    """ 
	Applies enzdes constraints form the input CST file to a pose
	Also applies coordinate constraints to the substrate peptide, assumed to 
	be chain B
	"""
    # Enzdes constraints
    cstm = AddOrRemoveMatchCsts()
    cstm.set_cst_action(ADD_NEW)
    cstm.apply(pose)

    # Coordinate constraints
    cg = CoordinateConstraintGenerator()
    cs = ChainSelector('B')
    cg.set_residue_selector(cs)

    ac = AddConstraints()
    ac.add_generator(cg)
    ac.apply(pose)

    return
def apply_constraints(pose):
    """ 
	Applies enzdes constraints form the input CST file to a pose
	Also applies coordinate constraints to the substrate peptide, assumed to 
	be chain B
	"""
    # Enzdes constraints
    cstm = AddOrRemoveMatchCsts()
    cstm.set_cst_action(ADD_NEW)
    cstm.apply(pose)

    # Coordinate constraints
    cg = CoordinateConstraintGenerator()
    ors = OrResidueSelector()
    ors.add_residue_selector(ChainSelector('A'))  # Constrain main backbone
    ors.add_residue_selector(
        ResidueIndexSelector('113-115'))  # Preserving original peptide
    cg.set_residue_selector(ors)

    ac = AddConstraints()
    ac.add_generator(cg)
    ac.apply(pose)

    return
示例#7
0
def apply_coord_constraints(pose,
                            sidechains=False,
                            bounded=True,
                            selection=None):
    """ 
    Applies backbone coordinate constraints to a selection of a pose Returns 
    constraied pose.
    """
    cg = CoordinateConstraintGenerator()
    cg.set_sidechain(sidechains)

    if bounded:
        cg.set_bounded(True)
        cg.set_bounded_width(0.1)
        cg.set_sd(0.5)

    if selection:
        cg.set_residue_selector(selection)

    ac = AddConstraints()
    ac.add_generator(cg)
    ac.apply(pose)

    return pose
         pdb_info, args.pdb, args.symmetry)
     match_indexes = match_substrate_pose_indexes.union(
         match_res_pose_indexes)
     active_site_positions.update(match_index
                                  for match_index in match_indexes)
 if args.substrates:
     active_site_positions.update(args.substrates)
 # coordinate constraint
 if args.reference_pose:
     coord_cst_gen = create_coord_cst(
         ref_pose=ref_pose
     )  #, ligand_res_indexes=match_substrate_pose_indexes)
 else:
     coord_cst_gen = create_coord_cst(
     )  #ligand_res_indexes=match_substrate_pose_indexes)
 add_csts = AddConstraints()
 add_csts.add_generator(coord_cst_gen)
 add_csts.apply(pose)
 # constraint
 if args.constraints:
     add_fa_constraints_from_cmdline(pose, sfxn)
 # enzyme design constraint
 if args.enzyme_design_constraints:
     enzdes_cst = create_enzdes_cst()
     enzdes_cst.apply(pose)
 # declare movers
 movers = list()
 if not args.rmsd:
     rmsdm = RMSDMetric(pose)
 else:
     rmsdm = RMSDMetric(
示例#9
0
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)

	# Creating symmetry setup
	if args.symmetry:
		sfsm = SetupForSymmetryMover(args.symmetry)

	# Setting up the scorefunction with the desired constraint weights
	if args.symmetry:
		sf = SymmetricScoreFunction()
		sf.add_weights_from_file(args.score_function)
	else:
		sf = create_score_function(args.score_function)

	if args.coord_wt:
		sf.set_weight(st.coordinate_constraint, args.coord_wt)

	if args.enzdes_wt:
		sf.set_weight(st.atom_pair_constraint, args.enzdes_wt)
		sf.set_weight(st.angle_constraint, args.enzdes_wt)
		sf.set_weight(st.dihedral_constraint, args.enzdes_wt)

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

	# Packer tasks
	tf = standard_task_factory()
	tf.push_back(RestrictToRepacking())
	tf.push_back(IncludeCurrent())
	tf.push_back(ExtraRotamers(0, 1, 1))
	tf.push_back(ExtraRotamers(0, 2, 1))
	fr.set_task_factory(tf)

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

	out_name = join(dir_name, file_name)

	# Loading PDB file, applying constraints
	pose = pose_from_pdb(args.pdb_file)
	ac.apply(pose)
	if args.constraints:
		enz_cst.apply(pose)
	if args.symmetry:
		sfsm.apply(pose)

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

	# Running relax set
	jd = PyJobDistributor(out_name, args.n_decoys, sf)
	while not jd.job_complete:
		pp = Pose()
		pp.assign(pose)
		fr.apply(pp)
		rmsdm.apply(pp)
		jd.output_decoy(pp)
示例#10
0
    args = parser.parse_args()
    validate_arguments(args)
    init()

    # Define the starting Pose:
    pose = pose_from_pdb(args.input_file)

    # Define the Score Function:
    score_function = get_fa_scorefxn()

    if args.no_constraints == False:
        # Create the Generator
        coordinates_constraint = CoordinateConstraintGenerator()
        # Add the Generate to a new AddConstraints object
        constraints = AddConstraints()
        constraints.add_generator(coordinates_constraint)
        # Apply the defined AddConstraints object to a Pose
        constraints.apply(pose)
        # Enable all constraint weights on the score function
        activate_constraints(score_function, args.c_weight)

    # An optinal but recommended Task is to include extra rotamers (away from
    # the regular optimums) for both chi1 (ex1) and chi2 (ex2)
    task_factory = standard_task_factory()
    # It seems that Ex1 is enabled by default.
    # Ex. task_factory.push_back(ExtraRotamers(0, 1, 1)) # ex1
    task_factory.push_back(ExtraRotamers(0, 2, 1))  # ex2
    # FastRelax, by default, blocks 'design' on the regular rotamers. However,
    # when adding the ExtraRotamers, new 'designable' rotamers are included
    # and considered during the sampling. Therefore, the TaskFactory must
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)