Пример #1
0
def selector_intersection(*selectors):
    """ Returns the intersection of any set of selectors """
    intersect_selection = AndResidueSelector()
    for s in selectors:
        intersect_selection.add_residue_selector(s)

    return intersect_selection
Пример #2
0
def ligand_neighbor_selection(lig, radius, pose, include_ligand=False):
    rad = float(radius)
    not_ligand = NotResidueSelector()
    not_ligand.set_residue_selector(lig)

    lig_distant_neighbors = InterGroupInterfaceByVectorSelector()
    lig_distant_neighbors.group1_selector(lig)
    lig_distant_neighbors.group2_selector(not_ligand)
    lig_distant_neighbors.cb_dist_cut(2.0 * rad)
    lig_distant_neighbors.nearby_atom_cut(rad)

    lig_contacts = pr.rosetta.core.select.residue_selector.CloseContactResidueSelector(
    )
    lig_contacts.central_residue_group_selector(lig)
    lig_contacts.threshold(rad)

    lig_neighbors = OrResidueSelector()
    lig_neighbors.add_residue_selector(lig_distant_neighbors)
    lig_neighbors.add_residue_selector(lig_contacts)

    if include_ligand:
        selection = AndResidueSelector()
        selection.add_residue_selector(not_ligand)
    else:
        selection = OrResidueSelector()
        selection.add_residue_selector(lig)

    selection.add_residue_selector(lig_neighbors)
    return get_residues_from_subset(selection.apply(pose))
def create_design_task_factory(designable_res_indexes: list, active_site_positions: list = 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
    designable_selector = ResidueIndexSelector(','.join(
        str(designable_res_index)
        for designable_res_index in designable_res_indexes))
    if not cystine:
        restriction = RestrictAbsentCanonicalAASRLT()
        restriction.aas_to_keep('AGILPVFWYDERHKSTMNQ')  # AGILPVFWYDERHKSTCMNQ
        task_factory.push_back(
            OperateOnResidueSubset(restriction, designable_selector))
    # Repack
    repack = RestrictToRepackingRLT()
    prevent = PreventRepackingRLT()
    if neighborhood > 0:
        if len(active_site_positions) > 0:
            enzdes_cst_selector = ResidueIndexSelector(','.join(
                str(enzdes_cst_index)
                for enzdes_cst_index in active_site_positions))
            designable_repacking_selector = NeighborhoodResidueSelector()
            designable_repacking_selector.set_focus_selector(
                OrResidueSelector(designable_selector, enzdes_cst_selector))
            designable_repacking_selector.set_distance(neighborhood)
            designable_repacking_selector.set_include_focus_in_subset(True)
            repacking_selector = AndResidueSelector(
                designable_repacking_selector,
                NotResidueSelector(designable_selector))
            task_factory.push_back(
                OperateOnResidueSubset(repack, repacking_selector))
            task_factory.push_back(
                OperateOnResidueSubset(prevent, designable_repacking_selector,
                                       True))
        else:
            repacking_selector = NeighborhoodResidueSelector()
            repacking_selector.set_focus_selector(designable_selector)
            repacking_selector.set_distance(neighborhood)
            repacking_selector.set_include_focus_in_subset(False)
            task_factory.push_back(
                OperateOnResidueSubset(repack, repacking_selector))
            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
Пример #4
0
def shell_selection(selection_1, selection_2, base_range):
    shell_select = InterGroupInterfaceByVectorSelector()
    shell_select.group1_selector(selection_1)
    shell_select.group2_selector(selection_2)
    shell_select.nearby_atom_cut(base_range)
    shell_select.vector_dist_cut(base_range + 2)

    return AndResidueSelector(shell_select, NotResidueSelector(selection_2))
def select_by_cb_vector(pose):
    # The Cα-Cβ vector will be <0,0,0> for everything, because the DNA doesn't 
    # have Cα.  See `core::select::util::cbeta_vector()`.  This means that 
    # nothing will be selected on the basis of angle.  A residue would be 
    # selected based on angle if the dot product between Cα1-Cβ1 and Cβ1-Cβ2 is 
    # greater than a threshold (0.25 by default), but the product will always 
    # be 0 if one of the operands is a null vector.

    # To be included based on distance, the rules are different for protein and 
    # DNA residues.  For protein, a sidechain atom needs to be within 
    # `nearby_atom_cut` of any atom in the other group.  For DNA, C1' (the 
    # sugar carbon supporting the base, defined as the "neighbor" atom, see 
    # database/chemical/...) needs to be within `nearby_atom_cut` of any atom 
    # in the other group.  So DNA is a little more restrictive, because it only 
    # counts distances from one atom, not all atoms.

    protein_sele = ResiduePropertySelector(core.chemical.PROTEIN)
    dna_sele = ResiduePropertySelector(core.chemical.DNA)
    interface_sele = InterGroupInterfaceByVectorSelector(protein_sele, dna_sele)
    protein_interface_sele = AndResidueSelector(interface_sele, protein_sele)

    return protein_interface_sele.apply(pose)
def detect_inter_group_interface(pose, chains):
    protein_selector = ResiduePropertySelector(ResidueProperty.PROTEIN)
    group1_selector = AndResidueSelector(ChainSelector(chains[0]),
                                         protein_selector)
    group2_selector = AndResidueSelector(ChainSelector(chains[1]),
                                         protein_selector)
    interface_selector = InterGroupInterfaceByVectorSelector()
    interface_selector.group1_selector(group1_selector)
    interface_selector.group2_selector(group2_selector)
    group1_interface_selector = AndResidueSelector(interface_selector,
                                                   group1_selector)
    group2_interface_selector = AndResidueSelector(interface_selector,
                                                   group2_selector)
    group1_interface_vector = group1_interface_selector.apply(pose)
    group2_interface_vector = group2_interface_selector.apply(pose)
    return group1_interface_vector, group2_interface_vector
Пример #7
0
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
Пример #8
0
    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)
Пример #9
0
def check_selector_nonzero_intersections(selectors_list, pose):
    """
	Takes an input list of selectors and a pose, and checks the intersection
	of the selectors applied to the pose, returning a boolean indicating 
	whether the intersection set is empty, and the intersection set.
	"""
    # Make an AndResidueSelector
    ars = AndResidueSelector()

    # Add all selectors in the input list
    for sel in selectors_list:
        ars_s.add_residue_selector(sel)

    # Get intersection residues list
    intersection_list = selector_to_list(pose, ars)

    # Check whether list is empty
    is_intersection_empty = len(intersection_list) == 0

    return is_intersection_empty, intersection_list
     if f.endswith('.params'):
         params.append(f)
 if len(params) > 0:
     init('-extra_res_fa ' + ' '.join(params))
 else:
     init()
 pose = pose_from_pdb(args.pdb)
 prefix = args.pdb[args.pdb.rfind('/') + 1:-4]
 i = prefix.find('_')
 if i != -1:
     prefix = args.pdb[:i]
 if args.chain:
     # Residues having the same pdb chain id do not necessarily share the same pose chain id.
     # Convert pdb chain index to pose chain index.
     chain_selector = AndResidueSelector(
         ChainSelector(args.chain),
         ResiduePropertySelector(ResidueProperty.PROTEIN))
     chain_vector = chain_selector.apply(pose)
     chain_begin = None
     chain_end = None
     for res_index, res in enumerate(chain_vector):
         if res:
             if not chain_begin:
                 chain_begin = res_index + 1
             # chain_index = pose.chain(res_index + 1)
             # break
         else:
             if chain_begin:
                 chain_end = res_index
                 break
     if not chain_end:
Пример #11
0
    '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')

    # Run analyze_design_decoys.fix_file()
    # python relax_new_pdb.py $i -od fibrils_collaboration/pdz_designs/design_models/round_2/ -cst fibrils_collaboration/htra1_pdz.cst -ccw 0 -n 10
Пример #12
0
def residue_pairs(
    self,
    primary_residue_selector=TrueResidueSelector(),
    secondary_residue_selector=TrueResidueSelector(),
    neighborhood_distance_maximum=None,
    sequence_distance_minimum=None,
):
    """Iterate the permutations of residue pairs from two selections which are
    within a cartesian and/or outside a sequence distance cutoff.

    The method uses the PrimarySequenceNeighborhoodSelector and
    NeighborhoodResidueSelector under the hood. Note that all _permutations_ of
    residues are yielded, not _combinations_. If you prefer combinations simply
    check `if residue_pair[0].sequence_position() > residue_pair[1].sequence_position():`.

    primary_residue_selector - ResidueSelector
    secondary_residue_selector - ResidueSelector
    neighborhood_distance - float
    sequence_distance - int

    return - iterator(tuple(Residue, Residue))
    """
    primary_residue_selection = primary_residue_selector.apply(self)
    primary_residue_indices = get_residues_from_subset(primary_residue_selection)

    for primary_residue_index in primary_residue_indices:
        temp_secondary_residue_selector = secondary_residue_selector

        primary_residue_index_selector = ResidueIndexSelector(primary_residue_index)
        temp_secondary_residue_selector = AndResidueSelector(
            temp_secondary_residue_selector,
            NotResidueSelector(primary_residue_index_selector),
        )

        if (
            neighborhood_distance_maximum
        ):  # Select residues within cartesian neighborhood distance
            neighborhood_residue_selector = NeighborhoodResidueSelector(
                primary_residue_index_selector, neighborhood_distance_maximum, False
            )
            temp_secondary_residue_selector = AndResidueSelector(
                temp_secondary_residue_selector, neighborhood_residue_selector
            )

        if (
            sequence_distance_minimum
        ):  # Select residues outside sequence neighborhood distance
            sequence_residue_selector = PrimarySequenceNeighborhoodSelector(
                sequence_distance_minimum,
                sequence_distance_minimum,
                primary_residue_index_selector,
            )
            temp_secondary_residue_selector = AndResidueSelector(
                temp_secondary_residue_selector,
                NotResidueSelector(sequence_residue_selector),
            )

        secondary_residue_selection = temp_secondary_residue_selector.apply(self)
        secondary_residue_indices = get_residues_from_subset(
            secondary_residue_selection
        )

        for secondary_residue_index in secondary_residue_indices:
            yield tuple(
                [
                    self.residues[primary_residue_index],
                    self.residues[secondary_residue_index],
                ]
            )
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
Пример #14
0
from pyrosetta.rosetta.core.select.residue_selector import AndResidueSelector
from pyrosetta.rosetta.core.select.residue_selector import ChainSelector
from pyrosetta.rosetta.core.select.residue_selector import SecondaryStructureSelector

from pyrosetta.rosetta.protocols.symmetry import DetectSymmetry
from pyrosetta.rosetta.protocols.symmetry import SetupForSymmetryMover

from stapler import NativeDisulfideStapler

# Preset ResidueSelectors
default_residue_selectors = [TrueResidueSelector(), TrueResidueSelector()]
interface_residue_selectors = [ChainSelector('A'), ChainSelector('B')]
interface_or_internal_residue_selectors = [ChainSelector('A'), ChainSelector('A,B')]
only_binder_residue_selectors = [ChainSelector('B'), ChainSelector('B')]
not_on_loops = [SecondaryStructureSelector('HE'), SecondaryStructureSelector('HE')]
not_on_loops_across_interface = [AndResidueSelector(SecondaryStructureSelector('HE'),ChainSelector('A')),
                                 AndResidueSelector(SecondaryStructureSelector('HE'),ChainSelector('B'))]

# Initialize the native disulfide stapler with defaults.
native_disulfide_stapler = NativeDisulfideStapler(
    residue_selectors=default_residue_selectors,
    minimum_sequence_distance=4
)

for pdb in glob.glob('_inputs/*.pdb'):
    pdb_filename = os.path.splitext(os.path.basename(pdb))[0]

    pose = pyrosetta.pose_from_file(pdb)

    # Preset Movers for Symmetry
    # DetectSymmetry().apply(pose)
Пример #15
0
# operands is a null vector.

#interface_sele.vector_dist_cut(0.0)
#interface_sele.vector_angle_cut(0.0)
#interface_sele.nearby_atom_cut(100.0)
#interface_sele.cb_dist_cut(100.0)

# To be included based on distance, the rules are different for protein and DNA
# residues.  For protein, a sidechain atom needs to be within `nearby_atom_cut`
# of any atom in the other group.  For DNA, C1' (the sugar carbon supporting
# the base, defined as the "neighbor" atom, see database/chemical/...) needs to
# be within `nearby_atom_cut` of any atom in the other group.  So DNA is a
# little more restrictive, because it only counts distances from one atom, not
# all atoms.

protein_interface_sele = AndResidueSelector(interface_sele, protein_sele)

print('interface_sele.vector_dist_cut =', interface_sele.vector_dist_cut())
print('interface_sele.vector_angle_cut =', interface_sele.vector_angle_cut())
print('interface_sele.nearby_atom_cut =', interface_sele.nearby_atom_cut())
print('interface_sele.cb_dist_cut =', interface_sele.cb_dist_cut())

pymol_from_sele('protein_sele', pose)
pymol_from_sele('dna_sele', pose)
pymol_from_sele('interface_sele', pose)
pymol_from_sele('protein_interface_sele', pose)

raise SystemExit

#n_close = 0
#n_contact = 0
Пример #16
0
def packable_residues_selector(mutable_selector):
	"""
	Selects the shell of neighbor residues to repack
	Presently hard coded for HCV protease.
	"""
	# Selecting regions
	mutable = mutable_selector
	not_mutable = NotResidueSelector(mutable_selector)
	catalytic = ResidueIndexSelector('72,96,154')
	peptide = ChainSelector('B')

	pep_not_mutable = AndResidueSelector()
	pep_not_mutable.add_residue_selector(peptide)
	pep_not_mutable.add_residue_selector(not_mutable)

	# Selecting residues near mutable shell
	near_mutable = InterGroupInterfaceByVectorSelector()
	near_mutable.group1_selector(not_mutable)
	near_mutable.group2_selector(mutable)
	near_mutable.nearby_atom_cut(4)
	near_mutable.vector_dist_cut(4)

	# Selecting residues near the peptide
	near_pep = InterGroupInterfaceByVectorSelector()
	near_pep.group1_selector(not_mutable) # Protease
	near_pep.group2_selector(peptide) # Peptide recognition region
	near_pep.nearby_atom_cut(10)
	near_pep.vector_dist_cut(12)

	# Combining selections for near peptide and near mutable residues
	wide_set = OrResidueSelector()
	wide_set.add_residue_selector(near_mutable)
	wide_set.add_residue_selector(near_pep)	

	# Setting up exclusion of catalytic and mutable residues
	limit_selection = AndResidueSelector()
	limit_selection.add_residue_selector(NotResidueSelector(catalytic))
	limit_selection.add_residue_selector(wide_set)
	limit_selection.add_residue_selector(not_mutable)

	# Add back in the peptide
	expand_selection = OrResidueSelector()
	expand_selection.add_residue_selector(limit_selection)
	expand_selection.add_residue_selector(pep_not_mutable)

	return expand_selection
Пример #17
0
def mutable_residues_selector(design_peptide=False, single_pep_res=None):
	"""
	Selects the residues in a shell around the peptide using the 
	InterGroupInterfaceByVectorSelector residue selector
	Presently hard coded for HCV protease.
	Decided to design just around peptide, not pep + cat, and only the
	six mutable residues in the peptide.
	"""
	# Selecting regions
	protease = ChainSelector("A")
	catalytic = ResidueIndexSelector('72,96,154')
	if single_pep_res:
		variable_pep_res = ResidueIndexSelector(str(single_pep_res))
	else:
		variable_pep_res = ResidueIndexSelector("198-203")

	# Making positive residue selector
	rs = InterGroupInterfaceByVectorSelector()
	rs.group1_selector(protease) # Protease
	rs.group2_selector(variable_pep_res) # Peptide recognition region
	rs.nearby_atom_cut(6)
	rs.vector_dist_cut(8)

	# Excluding the catalytic residues
	limit_selection = AndResidueSelector()
	limit_selection.add_residue_selector(NotResidueSelector(catalytic))
	limit_selection.add_residue_selector(rs)

	# If the peptide sequence is mutable
	if design_peptide:
		return limit_selection

	# If only the protease is designable
	else: 
		# Setting up exclusion of catalytic and peptide residues
		exclusive_selection = AndResidueSelector()
		exclusive_selection.add_residue_selector(limit_selection)
		exclusive_selection.add_residue_selector(ChainSelector("A"))
		return exclusive_selection
Пример #18
0
def main(args):

    if args.ligand_type == 'ligand':
        init_args = ' '.join(['-extra_res_fa', args.ligand_name])
        lig_name = args.ligand_name.split('/')[-1].strip('.params')
    else:
        init_args = ''

    pr.init(init_args)
    sf = pr.get_fa_scorefxn()
    sf.add_weights_from_file('ref2015')

    pose = pr.pose_from_pdb(args.input_pdb)
    sf(pose)

    print_notice("Scaffold protein Loaded Successfully!")
    print_notice("Scaffold protein has" + str(pose.total_residue()) +
                 "residues.")

    if args.symmetric_file:
        sfsm = SetupForSymmetryMover(args.symmetric_file)
        sfsm.apply(pose)

    #Importing list of residues if the ligand is a protein
    if args.ligand_type == 'protein':
        ligres = ResidueIndexSelector(args.residue_set)
    #Targeting the ligand if the ligand isn't protein
    elif args.ligand_type == 'ligand':
        ligres = ResidueNameSelector()
        ligres.set_residue_name3(lig_name)

    print_notice("Ligand found at resnum: " + \
            str(get_residues_from_subset(ligres.apply(pose))) )

    #Setting the proteins not in the ligand
    not_ligand = NotResidueSelector()
    not_ligand.set_residue_selector(ligres)

    #Setting the protein considered part of the ligand
    ligand_distant_contacts = InterGroupInterfaceByVectorSelector()
    ligand_distant_contacts.group1_selector(ligres)
    ligand_distant_contacts.group2_selector(not_ligand)
    ligand_distant_contacts.cb_dist_cut(2.5 * float(args.radius))
    ligand_distant_contacts.nearby_atom_cut(float(args.radius))

    #Test set: ClosecontactResidueSelector
    close_contacts = pr.rosetta.core.select.residue_selector.CloseContactResidueSelector(
    )
    close_contacts.central_residue_group_selector(ligres)
    close_contacts.threshold(float(args.radius))

    all_contacts = OrResidueSelector()
    all_contacts.add_residue_selector(close_contacts)
    all_contacts.add_residue_selector(ligand_distant_contacts)

    non_lig_residues = AndResidueSelector()
    non_lig_residues.add_residue_selector(all_contacts)
    non_lig_residues.add_residue_selector(not_ligand)

    #Collecting the residues from the subset
    neighbor_residues = get_residues_from_subset(non_lig_residues.apply(pose))
    pdb_residues = []
    for residue in neighbor_residues:
        print(pose.pdb_info().pose2pdb(residue))
        resid = pose.pdb_info().pose2pdb(residue).split()
        pdb_residues.append(''.join(resid))

    print_notice("Ligand found, neighbor residues are: " +
                 ', '.join([x for x in pdb_residues]))
    print_notice("Ligand found, total neighbor residues is " +
                 str(len(pdb_residues)))

    #Removing residues in the REMARKS section
    remove_set = []
    f = open(args.input_pdb, 'r')
    for line in f.readlines():
        if 'REMARK' in line:
            items = [x for x in line.split(' ') if x != '']
            residue_set = [int(items[6]), int(items[11])]
            for resi in residue_set:
                if resi not in remove_set:
                    remove_set.append(resi)

    residue_final_set = []
    for resi in pdb_residues:
        idx = int(resi[0:-1])
        if idx not in remove_set:
            residue_final_set.append(resi)
    #Final list for the designable residues
    residue_final_set.append('0')
    print_notice("Neighbor residues cleaned \n \n Residues are: " +\
            ', '.join([x for x in residue_final_set]))

    if args.out_file:
        out_name = args.out_file
    else:
        out_name = args.input_pdb.strip('.pdb') + '_lig.pos'

    f = open(out_name, "w")
    for x in residue_final_set:
        f.write(x + '\n')
    f.close
    print("emd182::Wrote ligand position residues of pdb file " +
          args.input_pdb + " to filename: " + out_name)