Skip to main content

pyRIF

Using Rotamer Interaction Fields from RIFGen/Dock in python

Installation

pip install pyRIF

Requirements

PyRosetta installed in python environment
RIFDock for generating RIFs

generating HDF5s of RIFs from RIFGen

include -dump_rifgen_hdf5 in your rifgen.flag file when running RIFGen. this will produce rif.h5 in your output directory. Then run python tools/convert_rif_h5.py rif.h5. This will produce py_rif.h5. This is the HDF5 file that will be needed to initialize RotamerInteractionField(). You will also need the path to the rotamer_index_spec.txt and target.pdb.gz created by RIFGen. These will be in the output directory you specified in rifgen.flag.

Pose Example

Moves your input pose into the region of the RIF, by aligning the target_selector residues onto the model specified with L_AA_RIF['target']

import glob
import pyrosetta
from pyrosetta.rosetta.core.select.residue_selector import ChainSelector

from pyRIF import RotamerInteractionField

pyrosetta.init()


# dictionary pointing to RIFGen outputs
L_AA_RIF = {
    'HDF5'   : '/path/to/py_rif.h5',
    'rots'   : '/path/to/rotamer_index_spec.txt',
    'target' : '/path/to/target.pdb.gz',
}


# residue selectors to select target and binder residues
target_selector = ChainSelector('A')
binder_selector = ChainSelector('B')


# create RIF object outside of loop
RIF = RotamerInteractionField(
    L_AA_RIF_kwargs=L_AA_RIF,
    residue_selector=binder_selector,
    target_selector=target_selector,
)

for PDB in glob.iglob('/path/to/pdbs/*.pdb'):
    pose = pyrosetta.io.pose_from_pdb(PDB)

    # apply the RIF
    STATUS, RIF_score, sequence_mapping = RIF.apply(pose)

    if STATUS:
        print(f'pass, {RIF_SCORE}\n{sequence_mapping}')
        # continue with remainder of protocol
    else:
        print('fail')

Numpy Example

Assumes your XYZs are already within the region of the RIF

import glob
import numpy as np
import pyrosetta

from pyRIF import RotamerInteractionField
pyrosetta.init()


# dictionary pointing to RIFGen outputs
L_AA_RIF = {
    'HDF5'   : '/path/to/py_rif.h5',
    'rots'   : '/path/to/rotamer_index_spec.txt',
    'target' : '/path/to/target.pdb.gz',
}


# create RIF object outside of loop
RIF = RotamerInteractionField(
    L_AA_RIF_kwargs=L_AA_RIF,
)

binder_xyzs = np.random.rand(1000, 100, 3, 3)# [(1000 proteins), (100 residues), (N CA C), (X Y Z)]

for i in range(binder_xyzs.shape[0]):

    STATUS, RIF_score, sequence_mapping = RIF.search_xyzs(binder_xyzs[i, :, :, :])

    if STATUS:
        print(f'pass, {RIF_SCORE}\n{sequence_mapping}')
        # continue with remainder of protocol
    else:
        print('fail')

Note about packing

Right now, packing is done by first pruning rotamers at a hit where the rotamer clashes in a voxel grid with the N CA C atoms of the binder (semi-equivalent to 1-body). Each pair of pruned rotamers at position i and j are then clashed checked against one another in the same voxel grid (semi-equivalent to 2-body). The lowest RIF_score set of rotamers at each hit position that survives these voxel clash checks is taken as the output sequence, and the sum of their RIF_scores is the output RIF_score for this pose/xyzs. This score is not the same as the RIF_score output by RIFDock.

Note about homog

If you are getting an error on import pyRIF, this is due to a bug in the package homog. See this pull-request for the fix. In short, on line 11 of homog/util.py change nopython=1, fastmath=1 to nopython=True, fastmath=True.

Metadata

Release files for pyRIF 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyRIF 1.0.4
File Size Uploaded
pyRIF-1.0.4.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyRIF 1.0.4
File Interpreter ABI Platform
pyRIF-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.6 kB

Release files / pyRIF-1.0.4.tar.gz

Download URL pyRIF-1.0.4.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
892d83a8376f44cf7f4706321b9a2248ad2b8bad253a7436f6656806245be47e
BLAKE2b-256 checksum
How to use checksums
355d591708a22d4f54c394e2d06875dbfdd01e293db37e4421b0d47f4cf60ea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.7

Release files / pyRIF-1.0.4-py3-none-any.whl

Download URL pyRIF-1.0.4-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8387f59fedb0d35b628de6235f977cad2768be3e31e83a4a13d883ddda8a71c2
BLAKE2b-256 checksum
How to use checksums
601dea744739a944a554a70b13826d875f0693f3daf8e44b31ac1b0e95b2d6d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.9.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page