Ejemplo n.º 1
0
def setup_fastrelax(sf):
	"""
	Creates FastRelax mover with appropriate score function, movemap, and 
	packer rules. List of neighbor residues was generated using a 10A 
	neighborhood residue selector around the peptide chain.
	"""
	relax = FastRelax()
	relax.set_scorefxn(sf)

	# MoveMap
	mm = MoveMap()
	mm.set_bb_true_range(212,216)
	neighbors = [28, 29, 41, 42, 43, 44, 45, 46, 59, 60, 61, 62, 91, 125, 126, 
		127, 128, 129, 145, 147, 148, 149, 150, 151, 157, 164, 165, 166, 167, 
		168, 169, 170, 171, 183, 184, 185, 186, 187, 188, 189, 192, 193, 194, 212, 
		213, 214, 215, 216, 217, 218, 219, 220] # Did 10A selection separately
	for n in neighbors:
		mm.set_chi(n, True)
	relax.set_movemap(mm)

	# 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))
	relax.set_task_factory(tf)

	return relax
Ejemplo n.º 2
0
def setup_fastrelax(sf):
    """
	Creates FastRelax mover with appropriate score function, movemap, and 
	packer rules. List of neighbor residues was generated using a 8A 
	PyMOL selection expansion around the peptide chain.
	"""
    relax = FastRelax()
    relax.set_scorefxn(sf)

    # MoveMap
    mm = MoveMap()
    mm.set_bb_true_range(106, 112)
    neighbors = [
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 19, 22, 37,
        38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 53, 59, 62, 69, 70, 71, 72,
        73, 74, 75, 76, 77, 78, 79, 83, 85, 98, 100, 101, 103, 104, 105, 106,
        107, 108, 109, 110, 111, 112
    ]  # Did 8A selection separately
    for n in neighbors:
        mm.set_chi(n, True)
    relax.set_movemap(mm)

    # 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))
    relax.set_task_factory(tf)

    return relax
Ejemplo n.º 3
0
def setup_fastrelax(sf, pose):
    """
	Creates FastRelax mover with appropriate score function, movemap, and 
	packer rules. All sidechains are mobile, only substrate backbone is mobile.
	"""
    relax = FastRelax()
    relax.set_scorefxn(sf)

    # MoveMap
    mm = MoveMap()
    mm.set_chi(True)
    for i in range(1, pose.total_residue() + 1):
        if pose.residue(i).chain() == 2:
            mm.set_bb(i, True)
    relax.set_movemap(mm)

    # 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))
    relax.set_task_factory(tf)

    return relax
Ejemplo n.º 4
0
def main(args):
    # Destination folder for PDB files
    od = out_directory(args.out_dir)

    # 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(od, file_name)

    # Loading pose and applying constraints, symmetry,
    pose = load_pose(args.pdb_file,
                     enzdes_cst=args.constraints,
                     coord_cst=True,
                     symmetry=args.symmetry,
                     membrane=None)

    # Setting up the scorefunction with the desired constraint weights
    sf = get_sf(rep_type='hard',
                symmetry=args.symmetry,
                membrane=0,
                constrain=args.constraint_weight)

    # 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)

    # 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(pose)
        fr.apply(pp)
        rmsdm.apply(pp)
        jd.output_decoy(pp)

    print("Starting relax {}".format(pdb_name))
    pose = fastrelax(pose, sf, mm, taskfactory=tf)
Ejemplo n.º 5
0
def make_point_mutant_task_factory(site_1,
                                   change_1,
                                   site_2=None,
                                   change_2=None,
                                   fast=True):
    """
    Given a site integer and a 1-letter residue name (or two sites and two 
    residue names), generates a TaskFactory to repack all residues 
    in a pose with the altered sites repacking to the new sequence.
    """
    # Initialize selection of all altered residues
    modified_residues = OrResidueSelector()  # Keep list of mobile residues

    # Make TaskFactory to input changes
    task_factory = TaskFactory()
    task_factory.push_back(IncludeCurrent())
    if not fast:
        task_factory.push_back(ExtraRotamers(0, 1, 1))
        task_factory.push_back(ExtraRotamers(0, 2, 1))

    # Force packing to new residue for the mutated site
    res_selection_1 = ResidueIndexSelector(str(site_1))
    aa_force_1 = RestrictAbsentCanonicalAASRLT()
    aa_force_1.aas_to_keep(change_1)
    task_factory.push_back(OperateOnResidueSubset(aa_force_1, res_selection_1))
    modified_residues.add_residue_selector(res_selection_1)

    # Add second site if necessary
    if site_2 and change_2:
        res_selection_2 = ResidueIndexSelector(str(site_2))
        aa_force_2 = RestrictAbsentCanonicalAASRLT()
        aa_force_2.aas_to_keep(change_2)
        task_factory.push_back(
            OperateOnResidueSubset(aa_force_2, res_selection_2))
        modified_residues.add_residue_selector(res_selection_2)

    # Repack all other residues to accommodate substitutions
    unchanged_residues = NotResidueSelector(modified_residues)
    repack = RestrictToRepackingRLT()
    task_factory.push_back(OperateOnResidueSubset(repack, unchanged_residues))

    return task_factory
def make_task_factory(residue_selectors):
    """ 
    Makes a TaskFactory with operations that leave the mutable residues 
    designable, restricts the nearby residues to repacking, and prevents 
    repacking of other residues.
    """
    mutable_set = residue_selectors['mutable']
    repack_set = residue_selectors['packable']
    immobile_set = residue_selectors['immobile']

    prevent = PreventRepackingRLT()  # No repack, no design
    repack = RestrictToRepackingRLT()  # No design

    tf = TaskFactory()
    tf.push_back(IncludeCurrent())
    tf.push_back(ExtraRotamers(0, 1, 1))
    tf.push_back(ExtraRotamers(0, 2, 1))
    tf.push_back(OperateOnResidueSubset(prevent, immobile_set))
    tf.push_back(OperateOnResidueSubset(repack, repack_set))
    # Everything else left designable by default

    return tf
Ejemplo n.º 7
0
def task_factory_builder(repacking_residues='all', designing_residues=None, \
        extra_rotamers=[1,2]):
    #Setting this up for now, need to implement these conditions:
    #Repackable set, Designable Set, prevent ligand repacking
    #Building a Task Factory for repacking/design around the neighbors residues
    #Task factory builder should accept: repackable residues, designable
    #residues, specifically preventing repacking residues, and prevent the rest.
    #tf = task_factory_builder(repack=repacking_neighbors)

    #distance - distance for Neighborhood residue selector - need to remov
    print_out("Building task factory")
    #Start up Task factory, starting ex1 and ex2, and include current
    tf = TaskFactory()
    tf.push_back(IncludeCurrent())

    if extra_rotamers:
        for x in extra_rotamers:
            tf.push_back(ExtraRotamers(0, x, 1))
    print(repacking_residues)

    #Set up repack and prevent repack
    repack = RestrictToRepackingRLT()
    prevent = PreventRepackingRLT()
    prevent_everything_else = NotResidueSelector()

    residues_for_repack = None
    residues_for_design = None
    changing_residues = OrResidueSelector()

    if repacking_residues != 'all':
        print_out("Repacking these residues: " + str(repacking_residues))
        residues_for_repack = ResidueIndexSelector(
            ','.join(repacking_residues))
        changing_residues.add_residue_selector(residues_for_repack)
        tf.push_back(OperateOnResidueSubset(repack, residues_for_repack))

    if designing_residues:
        residues_for_design = ResidueIndexSelector(designing_residues)
        changing_residues.add_residue_selector(residues_for_design)

    prevent_everything_else.set_residue_selector(changing_residues)

    if repack == 'all':
        tf.push_back(OperateOnResidueSubset(repack, prevent_everything_else))
    else:
        tf.push_back(OperateOnResidueSubset(prevent, prevent_everything_else))
    return tf
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    'R386V-M388R-K394V-T415K-E416Y': 'pdz_relaxed_2.pdb_designed_13.pdb',
    'Y382W-R386V-M388R-K394V-T415K-E416Y': 'pdz_relaxed_2.pdb_designed_13.pdb',
    'S389D-S444R-N446Q': 'pdz_relaxed_3.pdb_designed_47.pdb',
    'N446E': 'pdz_relaxed_2.pdb_designed_9.pdb'
}
for des, muts in res_changes.items():
    pp = pose_from_pdb('pdz_designs/examples/' + start_pdb[des])
    peptide = ChainSelector('B')
    shell = NeighborhoodResidueSelector()
    shell.set_focus_selector(peptide)
    shell.set_include_focus_in_subset(True)
    shell.set_distance(12)
    mobile_residues = OrResidueSelector()
    tf = TaskFactory()
    tf.push_back(IncludeCurrent())
    tf.push_back(ExtraRotamers(0, 1, 1))
    tf.push_back(ExtraRotamers(0, 2, 1))
    for r, aa in muts.items():
        res_selection = ResidueIndexSelector(str(r))
        restriction = RestrictAbsentCanonicalAASRLT()
        restriction.aas_to_keep(aa.upper())
        tf.push_back(OperateOnResidueSubset(restriction, res_selection))
        mobile_residues.add_residue_selector(res_selection)
    packable = AndResidueSelector(shell, NotResidueSelector(mobile_residues))
    tf.push_back(OperateOnResidueSubset(RestrictToRepackingRLT(), packable))
    not_changing = NotResidueSelector(shell)
    tf.push_back(OperateOnResidueSubset(PreventRepackingRLT(), not_changing))
    pt = tf.create_task_and_apply_taskoperations(pose)
    prm = PackRotamersMover(sf, pt)
    prm.apply(pp)
    pp.dump_pdb('pdz_designs/design_models/pdz_' + des + '.pdb')
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)