Example #1
0
    def __init__(self,
                 residue_selectors=(TrueResidueSelector(),
                                    TrueResidueSelector()),
                 atom_selectors=(('N', 'CA', 'C'), ('N', 'CA', 'C')),
                 minimum_sequence_distance=1,
                 maximum_neighborhood_distance=20.0,
                 hash_function_kwargs={
                     'cart_resl': 1.0,
                     'ori_resl': 15.0,
                     'cart_bound': 512.0
                 },
                 hash_table_kwargs={
                     'key_type': np.dtype('i8'),
                     'value_type': np.dtype('i8'),
                     'filename': None
                 }):
        print(hash_table_kwargs['filename'])
        self.hash_function = xbin.XformBinner(**hash_function_kwargs)
        self.hash_table = gp.MultiDict(**hash_table_kwargs)

        self.residue_selectors = residue_selectors
        self.atom_selectors = atom_selectors

        self.minimum_sequence_distance = minimum_sequence_distance
        self.maximum_neighborhood_distance = maximum_neighborhood_distance
Example #2
0
    def yeet_pose_xyz(pose, xyz=(1, 0, 0)):
        """
        Given a pose and a cartesian 3D unit vector, translates the pose
        according to 100 * the unit vector without applying a rotation:
        @pleung @bcov @flop
        Args:
            pose (Pose): The pose to move.
            xyz (tuple): The cartesian 3D unit vector to move the pose in.

        Returns:
            pose (Pose): The moved pose.
        """
        from pyrosetta.rosetta.core.select.residue_selector import TrueResidueSelector
        from pyrosetta.rosetta.protocols.toolbox.pose_manipulation import (
            rigid_body_move, )

        assert len(xyz) == 3
        pose = pose.clone()
        entire = TrueResidueSelector()
        subset = entire.apply(pose)
        # get which direction in cartesian unit vectors (xyz) to yeet pose
        unit = pyrosetta.rosetta.numeric.xyzVector_double_t(*xyz)
        scaled_xyz = tuple([100 * x for x in xyz])
        far_away = pyrosetta.rosetta.numeric.xyzVector_double_t(*scaled_xyz)
        rigid_body_move(unit, 0, far_away, pose, subset)
        return pose
def check_selection_proximity(pose, selection_1, selection_2):
    """
    Determines whether any residues in one selector are close enough to 
    potentially interact with residues from a second selector, 
    using an InterGroupInterfaceByVector selector with default settings.
    """
    # Make full-pose selection
    full_pose = TrueResidueSelector()

    # Make selection for the full pose minus the first selector
    not_selection_1 = NotResidueSelector(selection_1)
    full_minus_1 = selector_intersection(full_pose, not_selection_1)

    # Make selection for interacting residues between selection 1 the rest of the pose
    igibv = InterGroupInterfaceByVectorSelector()
    igibv.group1_selector(selection_1)
    igibv.group2_selector(full_minus_1)

    # Find intersection of selector_1's interaction partners and selector_2
    selection_overlap = selector_intersection(igibv, selection_2)

    # Check if there are residues in the intersection, or if it is empty
    # If it is empty, the Boolean will be False. Otherwise, it will be True
    selections_do_overlap = bool(selector_to_list(pose, selection_overlap))

    return selections_do_overlap
Example #4
0
    def __init__(self, residue_selector=None):

        if not residue_selector:
            residue_selector = TrueResidueSelector()
        elif not isinstance(residue_selector, ResidueSelector):
            raise ViewerInputError(residue_selector)
        
        self.residue_selector = residue_selector
Example #5
0
    def __init__(
        self,
        residue_selectors=(TrueResidueSelector(), TrueResidueSelector()),
        atom_selectors=(('N', 'CA', 'C'), ('N', 'CA', 'C')),
        minimum_sequence_distance=1,
        maximum_neighborhood_distance=20.0,
        hash_function_kwargs={'cart_resl' : 1.0, 'ori_resl' : 15.0, 'cart_bound' : 512.0},
        hash_table_kwargs={'key_type' : np.dtype('i8'), 'value_type': np.dtype('i4'), 'filename': pkg_resources.resource_filename('stapler', 'hash_tables/default_native_disulfide.bin')}
    ):

        super(NativeDisulfideStapler, self).__init__(
            residue_selectors=residue_selectors,
            atom_selectors=atom_selectors,
            minimum_sequence_distance=minimum_sequence_distance,
            maximum_neighborhood_distance=maximum_neighborhood_distance,
            hash_function_kwargs=hash_function_kwargs,
            hash_table_kwargs=hash_table_kwargs
        )
Example #6
0
    def __init__(self, residue_selector=None, surface_type="VDW", opacity=0.5, color=None, colorscheme=None):

        if not residue_selector:
            residue_selector = TrueResidueSelector()
        elif not isinstance(residue_selector, ResidueSelector):
            raise ViewerInputError(residue_selector)
        if not any(surface_type == s for s in ["VDW", "MS", "SES", "SAS"]):
            raise ValueError("Input surface_type argument must be one of the strings: 'VDW', 'MS', 'SES', 'SAS'"
            )
        
        _surface_types_dict = {
            "VDW": py3Dmol.VDW,
            "MS": py3Dmol.MS,
            "SES": py3Dmol.SES,
            "SAS": py3Dmol.SAS,
        }

        self.residue_selector = residue_selector
        self.surface_type = _surface_types_dict[surface_type]
        self.opacity = opacity
        self.color = color
        self.colorscheme = colorscheme
Example #7
0
import pyrosetta
pyrosetta.init()

from pyrosetta.rosetta.core.select.residue_selector import TrueResidueSelector
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]
Example #8
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],
                ]
            )