def make_task_factory(residue_selectors, confine_design=None): """ Makes a TaskFactory with operations that leave the mutable residues designable, restricts the nearby residues to repacking, and prevents repacking of other residues. Also includes the ability to take in a target residue mutatations text file in the form: res_number allowed_AAs for example: 138 KR All designable residues not listed in the file are restricted to repacking and the listed residues are limited in their design options to those AAs listed. """ design_set = residue_selectors['mutable'] repack_set = residue_selectors['packable'] other_set = residue_selectors['other'] prevent = PreventRepackingRLT() # No repack, no design repack = RestrictToRepackingRLT() # No design tf = TaskFactory() tf.push_back(OperateOnResidueSubset(prevent, other_set)) tf.push_back(OperateOnResidueSubset(repack, repack_set)) # Everything else left designable by default # Restricting design further if confine_design: trms = readfile(confine_design) # Converting lines to a dict limited_set = \ {int(line.split()[0]):line.split()[1] for line in trms} # Converting residues in the dict to a selector res_concatenated = str(limited_set.keys()).strip('[]').replace(' ','') small_des_set = ResidueIndexSelector(res_concatenated) now_only_repack = NotResidueSelector(small_des_set) # Making residue selection excluding residues in the file and # restricting them to repacking no_longer_designable = AndResidueSelector() no_longer_designable.add_residue_selector(design_set) no_longer_designable.add_residue_selector(now_only_repack) tf.push_back(OperateOnResidueSubset(repack, no_longer_designable)) # Limiting design on residues in the file for res, AAs in limited_set.items(): designable_res = ResidueIndexSelector(str(res)) restrict_AAs = RestrictAbsentCanonicalAASRLT() restrict_AAs.aas_to_keep(AAs) tf.push_back(OperateOnResidueSubset(restrict_AAs, designable_res)) return tf
def mutate_residue(pose, mutant_position, mutant_aa, pack_radius, pack_scorefxn): if pose.is_fullatom() == False: IOError('mutate_residue only works with fullatom poses') test_pose = Pose() test_pose.assign(pose) # Create a packer task (standard) task = TaskFactory.create_packer_task(test_pose) # the 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 = 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 returns the integer representation of an amino acid # from its one letter code # convert mutant_aa to its integer representation mutant_aa = aa_from_oneletter_code(mutant_aa) # mutation is performed by using a PackerTask with only the mutant # amino acid available during design # to do this, construct a Vector1 of booleans indicating which amino acid # (by its numerical designation, see above) to allow for i in range(1, 21): # 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): dist = center.distance_squared(test_pose.residue(i).nbr_atom_xyz()) # only pack the mutating residue and any within the pack_radius print(i, pack_radius, dist, pow(float(pack_radius), 2)) print('##################################################') if i != mutant_position and dist > pow(float(pack_radius), 2): task.nonconst_residue_task(i).prevent_repacking() # apply the mutation and pack nearby residues packer = PackRotamersMover(pack_scorefxn, task) packer.apply(test_pose) return test_pose
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
def design(self, antibody=True, antigen=False, pack_only=False): self.pose = self.native_pose.clone() info = self.pose.pdb_info() tf = TaskFactory() tf.push_back(operation.InitializeFromCommandline()) epi_res = '' for res in self.epitopes_pose: epi_res += '{0},'.format(res) epi_selector = ResidueIndexSelector(epi_res) antibody_selector = ChainSelector() vec = vector1_std_string() for chain in self.antibody: vec.append(chain) vec.append(chain) antibody_selector.set_chain_strings(vec) interface_res_selector = InterGroupInterfaceByVectorSelector( epi_selector, antibody_selector) interface_antibody_selector = AndResidueSelector( interface_res_selector, antibody_selector) if pack_only: tf.push_back(operation.RestrictToRepacking()) else: if antigen: design_selector = epi_selector elif antibody: design_selector = interface_antibody_selector # FIRST select designable residues and prevent everything else from design and packing no_design_selector = NotResidueSelector(design_selector) prevent_repacking_rlt = operation.PreventRepackingRLT() #restrict_topack = operation.RestrictToRepackingRLT() prevent_design = operation.OperateOnResidueSubset( prevent_repacking_rlt, no_design_selector, False) tf.push_back(prevent_design) print(tf.create_task_and_apply_taskoperations(self.pose)) packer = pack_min.PackRotamersMover('ref2015') packer.task_factory(tf) packer.apply(self.pose)
def make_task_factory(repackable_selection): """ Creates a task factory with residues in a selection repackable (not designable), and all other residues fixed. """ # Repack options prevent = PreventRepackingRLT() # No repack, no design repack = RestrictToRepackingRLT() # No design # Creating compliment selection fixed_selection = NotResidueSelector(repackable_selection) # Making task factory tf = TaskFactory() tf.push_back(OperateOnResidueSubset(prevent, fixed_selection)) tf.push_back(OperateOnResidueSubset(repack, repackable_selection)) return tf
def apply(self,just_mutate=False): for num,aa in self.mutations: number = get_pose_number(self.mover.indel.pose,self.chain,num) pyrosetta.toolbox.mutate_residue(self.mover.indel.pose,number,aa) if just_mutate: return self.mover.indel.pose.scores['total_score'] tf = TaskFactory() tf.push_back(operation.InitializeFromCommandline()) tf.push_back(operation.RestrictToRepacking()) packer = pack_min.PackRotamersMover() packer.task_factory(tf) packer.apply(self.mover.indel.pose) #relax.apply(self.mover.indel.pose) self.mover.indel.pose.dump_pdb('{}/current.pdb'.format(self.mover.indel.temp_path)) self.mover.indel.reload_pdbf('{}/current.pdb'.format(self.mover.indel.temp_path)) # self.mover.indel._apply_pymol() return self.mover.indel.pose.scores['total_score']
#opts = '-use_input_sc -ex1 -ex2 -enzdes::cstfile htra1_pdz.cst -run:preserve_header' opts = '-enzdes::cstfile htra1_pdz.cst -run:preserve_header' init(opts) pdz = ChainSelector('A') peptide = ChainSelector('B') designable = shell_selection(pdz, peptide, 6) packable = shell_selection(pdz, designable, 6) mobile = OrResidueSelector(designable, packable) mobile.add_residue_selector(peptide) static = NotResidueSelector(mobile) sf = get_fa_scorefxn() tf = TaskFactory() tf.push_back(IncludeCurrent()) tf.push_back(ExtraRotamers(0, 1, 1)) tf.push_back(ExtraRotamers(0, 2, 1)) prevent = PreventRepackingRLT() # No repack, no design repack = RestrictToRepackingRLT() # No design tf.push_back(OperateOnResidueSubset(prevent, static)) tf.push_back(OperateOnResidueSubset(repack, packable)) tf.push_back(OperateOnResidueSubset(repack, peptide)) fr = FastRelax() fr.set_scorefxn(sf) fd = FastDesign() fd.set_scorefxn(sf)
def create_enzyme_design_task_factory(active_site_positions: list, neighborhood: float = 0, \ cystine: bool = True, noncanonical_amino_acids: list = list()): task_factory = TaskFactory() if len(noncanonical_amino_acids) > 0: ncaa_palette = CustomBaseTypePackerPalette() for ncaa in noncanonical_amino_acids: ncaa_palette.add_type(ncaa) task_factory.set_packer_palette(ncaa_palette) task_factory.push_back(IncludeCurrent()) # Mutatable enzyme_core_selector = ResidueIndexSelector(','.join( str(active_site_position) for active_site_position in active_site_positions)) interface_selector = InterGroupInterfaceByVectorSelector() interface_selector.group1_selector(enzyme_core_selector) interface_selector.group2_selector( NotResidueSelector(enzyme_core_selector)) designable_selector = AndResidueSelector( interface_selector, NotResidueSelector(enzyme_core_selector)) if not cystine: restriction = RestrictAbsentCanonicalAASRLT() restriction.aas_to_keep('AGILPVFWYDERHKSTMNQ') # AGILPVFWYDERHKSTCMNQ task_factory.push_back( OperateOnResidueSubset(restriction, designable_selector)) # Repack repack = RestrictToRepackingRLT() if neighborhood > 0: repacking_wo_enzyme_core_selector = NeighborhoodResidueSelector() repacking_wo_enzyme_core_selector.set_focus_selector( interface_selector) repacking_wo_enzyme_core_selector.set_distance(neighborhood) repacking_wo_enzyme_core_selector.set_include_focus_in_subset(False) repacking_selector = OrResidueSelector( repacking_wo_enzyme_core_selector, enzyme_core_selector) task_factory.push_back( OperateOnResidueSubset(repack, repacking_selector)) prevent = PreventRepackingRLT() task_factory.push_back( OperateOnResidueSubset( prevent, OrResidueSelector(designable_selector, repacking_selector), True)) else: task_factory.push_back( OperateOnResidueSubset(repack, designable_selector, True)) return task_factory
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
workspace, job_info = big_jobs.initiate() test_run = job_info.get('test_run', False) init('-out:levels protocols.fixbb.LayerDesignOperation:warning') # Figure out input pdb and create a pose pdbpath = workspace.input_path(job_info) pose = pose_from_file(pdbpath) # Create FastDesign object fd = fastdesign.FastDesign() fd.pose = pose fd.add_init_arg('-ex1 -ex2 -use_input_sc -ex1aro') # Create task factory (tells Rosetta which positions to design and # which to move) and read the resfile taskfactory = TaskFactory() readresfile = ReadResfile(workspace.resfile_path) taskfactory.push_back(readresfile) ld = rosetta_scripts.XmlObjects.static_get_task_operation( '''<LayerDesign name="layer_all" layer="core_boundary_surface_Nterm_Cterm" use_sidechain_neighbors="True"> <Nterm> <all append="DEGHKNQRST" /> <all exclude="CAFILMPVWY" /> </Nterm> <Cterm> <all append="DEGHKNQRST" /> <all exclude="CAFILMPVWY" /> </Cterm> </LayerDesign>''') taskfactory.push_back(ld)
def create_relax_task_factory(point_mutations: list = list(), active_site_positions: list = list(), neighborhood: float = 0): task_factory = TaskFactory() task_factory.push_back(IncludeCurrent()) repack = RestrictToRepackingRLT() prevent = PreventRepackingRLT() if len(point_mutations) > 0: # Mutate mutated_selector = OrResidueSelector() for point_mutation in point_mutations: mutation_info = point_mutation.split(',') restriction = RestrictAbsentCanonicalAASRLT() restriction.aas_to_keep(mutation_info[1]) point_mutation_selector = ResidueIndexSelector(mutation_info[0]) task_factory.push_back( OperateOnResidueSubset(restriction, point_mutation_selector)) mutated_selector.add_residue_selector(point_mutation_selector) # Repack and static if neighborhood > 0: if len(active_site_positions) > 0: # Repack enzyme_core_selector = ResidueIndexSelector(','.join( str(active_site_position) for active_site_position in active_site_positions)) designable_repacking_selector = NeighborhoodResidueSelector() designable_repacking_selector.set_focus_selector( OrResidueSelector(mutated_selector, enzyme_core_selector)) designable_repacking_selector.set_distance(neighborhood) designable_repacking_selector.set_include_focus_in_subset(True) repacking_selector = AndResidueSelector( designable_repacking_selector, NotResidueSelector(mutated_selector)) task_factory.push_back( OperateOnResidueSubset(repack, repacking_selector)) # Static task_factory.push_back( OperateOnResidueSubset(prevent, designable_repacking_selector, True)) else: # Repack repacking_selector = NeighborhoodResidueSelector() repacking_selector.set_focus_selector(mutated_selector) repacking_selector.set_distance(args.neighborhood) repacking_selector.set_include_focus_in_subset(False) task_factory.push_back( OperateOnResidueSubset(repack, repacking_selector)) # Static mutated_and_repacking_selector = OrResidueSelector( mutated_selector, repacking_selector) task_factory.push_back( OperateOnResidueSubset(prevent, mutated_and_repacking_selector, True)) else: # Repack task_factory.push_back( OperateOnResidueSubset(repack, mutated_selector, True)) else: if neighborhood > 0: if len(active_site_positions) > 0: # Repack enzyme_core_selector = ResidueIndexSelector(','.join( str(active_site_position) for active_site_position in active_site_positions)) repacking_selector = NeighborhoodResidueSelector() repacking_selector.set_focus_selector(enzyme_core_selector) repacking_selector.set_distance(neighborhood) repacking_selector.set_include_focus_in_subset(True) task_factory.push_back( OperateOnResidueSubset(repack, repacking_selector)) # Static task_factory.push_back( OperateOnResidueSubset(prevent, repacking_selector, True)) else: # Static task_factory.push_back(PreventRepacking()) else: # Repack task_factory.push_back(RestrictToRepacking()) return task_factory
def clash_based_taskfactory(pdbpath, pose, workspace): insertion = lucs.get_insertion(pdbpath, workspace) # How much to add to insertion['stop'] to get the residue number to # design input_pose = pose_from_file(workspace.input_pdb_path) designable, repackable = lucs.relative_resfile_from_reference( workspace, insertion, pose, input_pose) # Ignoring repackable residues in resfile. # This should give us all designed positions design_mask = size_list_to_res_selector(designable, pose) design_selector = select.residue_selector.ResidueIndexSelector( numeric.intlist_to_vector1_size(designable)) # Takes a resfile and returns a task factory with a clash-based # repack shell. tf = TaskFactory() cl = operation.InitializeFromCommandline() notaa = operation.ProhibitSpecifiedBaseResidueTypes( strlist_to_vector1_str(['C', 'H']), design_selector) # read = operation.ReadResfile(resfile) tf.push_back(cl) tf.push_back(notaa) # tf.push_back(read) # Select repackable residues from designed residues repack_only = operation.RestrictToRepackingRLT() repack = operation.OperateOnResidueSubset(repack_only, design_selector, False) repack.flip_subset(True) tf.push_back(repack) all_selector = residue_selector.ClashBasedShellSelector(design_mask) all_selector.set_num_shells(2) all_selector.set_include_focus(True) all_selector.invert(True) no_packing = operation.PreventRepackingRLT() static = operation.OperateOnResidueSubset(no_packing, all_selector, False) packertask = tf.create_task_and_apply_taskoperations(pose) ld = rosetta_scripts.XmlObjects.static_get_task_operation( '''<LayerDesign name="layer_all" layer="core_boundary_surface_Nterm_Cterm" use_sidechain_neighbors="True"> <core> <all exclude="CW" /> </core> <boundary> <all exclude="CW" /> </boundary> <Nterm> <all append="DEGHKNQRST" /> <all exclude="CAFILMPVWY" /> </Nterm> <Cterm> <all append="DEGHKNQRST" /> <all exclude="CAFILMPVWY" /> </Cterm> </LayerDesign>''') tf.push_back(static) tf.push_back(ld) packertask = tf.create_task_and_apply_taskoperations(pose) print('PRINTING PACKERTASK') print(packertask) repack_mask = packertask.repacking_residues() design_mask = packertask.designing_residues() movemap = setup_movemap_from_resselectors(design_mask, repack_mask) return tf, movemap
# Create residue typeset pose = Pose() typeset = generate_nonstandard_residue_set(pose, workspace.ligand_params_paths) # Figure out input pdb and create a pose pdbpath = workspace.input_path(job_info) pose_from_file(pose, typeset, pdbpath) # Create FastDesign object fd = fastdesign.FastDesign() fd.pose = pose # Create task factory and read the resfile taskfactory = TaskFactory() readresfile = ReadResfile(workspace.resfile_path) taskfactory.push_back(readresfile) fd.task_factory = taskfactory # Parse resfile & create movemap resfile_parser = input_files.Resfile(input_resfile=workspace.resfile_path) chain = 'A' designable = [int(key) for key in resfile_parser.design[chain]] if chain in resfile_parser.repack: repackable = [int(key) for key in resfile_parser.repack[chain]] else: repackable = [] fd.setup_default_movemap(bb=designable.extend(repackable), chi=designable.extend(repackable))
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
def make_residue_changes(pose, sf, subst_seq, subst_start, cat_res, manual_muts): """ Applies substrate sequence changes and manual mutations to a given pose. This is done through repacking, so unlike SimpleThreadingMover, the side chains don't begin clashing. This means that the residue selectors will be more accurate, and that design can begin without an initial relax step. pose is a Rosetta pose sf is a Rosetta scorefunction subst_seq is a string (doesn't need to be uppercase) subst_start is an integer corresponding to the first of a contiguous block of residues to re-sequence manual_muts is a list of two-member lists, of the following form: [site, single-letter residue name] """ # Create dict of {res: AA} for changes to make res_changes = {} # Add manual mutations list if manual_muts: print("\nApplying point substitutions:") for m in manual_muts: res_changes[int(m[0])] = m[1].upper() print(m[0], m[1].upper()) # Add substrate threading to list of res changes print("\nInserting substrate sequence:\n{}".format(subst_seq)) subst_range = range(subst_start, subst_start + len(subst_seq)) for n, i in enumerate(subst_range): res_changes[i] = subst_seq[n].upper() # Make TaskFactory to input changes mobile_residues = OrResidueSelector() # Keep list of mobile residues tf = TaskFactory() # Force packing to target residue for each desired change for r, aa in res_changes.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) # Repack nearby residues to accommodate substitutions shell = NeighborhoodResidueSelector() shell.set_focus_selector(mobile_residues) shell.set_include_focus_in_subset(False) shell.set_distance(8) # Exclude catalytic residues if cat_res: catalytic = ResidueIndexSelector(','.join([str(i) for i in cat_res])) not_catalytic = NotResidueSelector(catalytic) shell = selector_intersection(shell, not_catalytic) restrict = RestrictToRepackingRLT() tf.push_back(OperateOnResidueSubset(restrict, shell)) # Prevent repacking of all other residues unchanging = NotResidueSelector(OrResidueSelector(mobile_residues, shell)) prevent = PreventRepackingRLT() tf.push_back(OperateOnResidueSubset(prevent, unchanging)) # Apply changes with PackRotamersMover pt = tf.create_task_and_apply_taskoperations(pose) prm = PackRotamersMover(sf, pt) mutated_pose = Pose(pose) prm.apply(mutated_pose) return mutated_pose
'I415K': 'pdz_relaxed_2.pdb_designed_13.pdb', 'I415K-E416Y': 'pdz_relaxed_2.pdb_designed_13.pdb', '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)
def clash_based_taskfactory(pdbpath, pose): insertion = get_insertion(pdbpath) # How much to add to insertion['stop'] to get the residue number to # design lucs_relative_resfile = [4, 5, 6, 8, 12, 16, 20, 23, 24, 26, 27, 30] # subtract 1 because LUCS loop definitions stop on the residue after the # insertion, whereas normal loop definition stops at the end of the # loop. lucs_relative_resfile = [ i + insertion['stop'] - 1 for i in lucs_relative_resfile ] # This should give us all designed positions loop_list = [j for j in range(insertion['start'], insertion['stop'])] lucs_relative_resfile += loop_list design_mask = size_list_to_res_selector(lucs_relative_resfile, pose) design_selector = select.residue_selector.ResidueIndexSelector( numeric.intlist_to_vector1_size(lucs_relative_resfile)) # Takes a resfile and returns a task factory with a clash-based # repack shell. tf = TaskFactory() cl = operation.InitializeFromCommandline() notaa = operation.ProhibitSpecifiedBaseResidueTypes( strlist_to_vector1_str(['C', 'H']), design_selector) # read = operation.ReadResfile(resfile) tf.push_back(cl) tf.push_back(notaa) # tf.push_back(read) # Select repackable residues from designed residues repack_only = operation.RestrictToRepackingRLT() repack = operation.OperateOnResidueSubset(repack_only, design_selector, False) repack.flip_subset(True) tf.push_back(repack) all_selector = residue_selector.ClashBasedShellSelector(design_mask) all_selector.set_num_shells(2) all_selector.set_include_focus(True) all_selector.invert(True) no_packing = operation.PreventRepackingRLT() static = operation.OperateOnResidueSubset(no_packing, all_selector, False) packertask = tf.create_task_and_apply_taskoperations(pose) ld = rosetta_scripts.XmlObjects.static_get_task_operation( '''<LayerDesign name="layer_all" layer="core_boundary_surface_Nterm_Cterm" use_sidechain_neighbors="True"> <Nterm> <all append="DEGHKNQRST" /> <all exclude="CAFILMPVWY" /> </Nterm> <Cterm> <all append="DEGHKNQRST" /> <all exclude="CAFILMPVWY" /> </Cterm> </LayerDesign>''') tf.push_back(static) tf.push_back(ld) packertask = tf.create_task_and_apply_taskoperations(pose) print('PRINTING PACKERTASK') print(packertask) repack_mask = packertask.repacking_residues() design_mask = packertask.designing_residues() movemap = setup_movemap_from_resselectors(design_mask, repack_mask) return tf, movemap
# 举例使用FastDesign快速设计一些序列和结构: from pyrosetta import pose_from_pdb, init, create_score_function from pyrosetta.rosetta.protocols.denovo_design.movers import FastDesign from pyrosetta.rosetta.core.pack.task import TaskFactory from pyrosetta.rosetta.core.pose import Pose from pyrosetta.io import poses_to_silent # init init('') # load pose starting_pose = pose_from_pdb('./data/EHEE_rd4_0976.pdb') ref2015 = create_score_function('ref2015') design_tf = TaskFactory() # setup FastDesign fastdesign = FastDesign(ref2015, 1) fastdesign.set_default_movemap() #使用默认的Movemap() fastdesign.set_task_factory(design_tf) # design for 10 times: for i in range(10): design_pose = Pose() design_pose.assign(starting_pose) # assign pose fastdesign.apply(design_pose) ## apply design # output to silent file; poses_to_silent(design_pose, './data/design_result.silent')
mutate_mover = pyrosetta.rosetta.protocols.simple_moves.MutateResidue() mutate_mover.set_target(501) mutate_mover.set_res_name('TYR') mutate_mover.apply(pose_N501Y) # score WT and N501Y mutant WT_score = scorefxn(pose_relaxed) N501Y_score = scorefxn(pose_N501Y) print('\nWT score: ' + str(WT_score)) print('\nN501Y score: ' + str(N501Y_score)) # to run FastRelax, make a task factory, a movemap factory, and add them to a FastRelax protocol object # Make task factory tf = TaskFactory() tf.push_back(operation.InitializeFromCommandline()) tf.push_back(operation.IncludeCurrent()) tf.push_back(operation.NoRepackDisulfides()) tf.push_back(operation.OperateOnResidueSubset( operation.RestrictToRepackingRLT(), residue_selector.TrueResidueSelector())) # make movemap factory mmf = pyrosetta.rosetta.core.select.movemap.MoveMapFactory() mmf.all_bb(setting=True) mmf.all_bondangles(setting=True) mmf.all_bondlengths(setting=True) mmf.all_chi(setting=True) mmf.all_jumps(setting=True) mmf.set_cartesian(setting=True)
# Uncap the anchor residue at which the new loop will be appended in chain B # Uncapping means removing any atoms that wouldn't exist in a closed loop # (such as extra oxygens and hydrogens at C and N terminals, respectively), # and setting the correct pyrosetta variant. Variants are tags appended to # residues. By default, the LoopModeler can't perform the KIC protocol if # the variant is set to NTermProteinFull or CTermProteinFull (marking # terminals), for example. anchor_B = ResidueIndexSelector(pose.chain_begin(2)) uncap_selection(pose, anchor_B) # LoopModeler can receive a task_factory instructing the mover to perform # design efforts while closing the looping. The task factory needs to be # populated with operations, such as the RestrictToLoopsAndNeighbors. We can # set this operation to design the loop and repack the neighbours in a 9 # angstrom cutoff. task_factory = TaskFactory() loop_op = RestrictToLoopsAndNeighbors() loop_op.set_include_neighbors(True) loop_op.set_design_neighbors(False) loop_op.set_design_loop(True) loop_op.set_cutoff_distance(args.cutoff) loop_op.set_loops(loops) task_factory.push_back(loop_op) # The LoopModeler mover is comprised of 3 stages: # - Build Stage: attempts to close the loop as is # - Centroid Stage: uses centroid mode to sample the conformational space # and find the lowest energy position for each aminoacid on the loop # - Fullatom Stage: returns the pose to full atom for high resolution # refinement. During this stage, the sidechains can be repacked and designed # Any one of this stages can be disabled: