Skip to content

Commit

Permalink
superimpose pose to RIFgen pose on RIF.apply()
Browse files Browse the repository at this point in the history
  • Loading branch information
psalveso committed Mar 30, 2021
1 parent 79ff342 commit 1a7099d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
33 changes: 20 additions & 13 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,38 @@
from pyrosetta.rosetta.utility import vector1_std_string as vec1_string
from pyrosetta.rosetta.core.select.residue_selector import ChainSelector


from pyRIF import RotamerInteractionField
try:
from pyRIF import RotamerInteractionField
except:
sys.path.append('../pyRIF')
from pyRIF import RotamerInteractionField

# init pyrosetta with whatever you want
pyrosetta.init(
'-mute all '
'-beta '
'-in:file:extra_res_fa /home/psalveso/git_repositories/peptim_stapler/peptim_stapler/_inputs/CYB.params '
'/home/psalveso/git_repositories/peptim_stapler/peptim_stapler/_inputs/NMX.params '
'/home/psalveso/git_repositories/peptim_stapler/peptim_stapler/_inputs/B3Z.params '
#'/home/psalveso/git_repositories/peptim_stapler/peptim_stapler/_inputs/401.params '
'/home/psalveso/projects/BRD/params/CYY.params '
'/home/psalveso/projects/BRD/params/KDD.params '
)

# location of RIF files
L_AA_RIF = {
'HDF5' : '/net/scratch/psalveso/peptim_cyclize_stapler_outputs/TEAD/RIF_HOTSPOTS/site_65-69/rifdock/py_rif.h5',
'rots' : '/net/scratch/psalveso/peptim_cyclize_stapler_outputs/TEAD/RIF_HOTSPOTS/site_65-69/rifgen/rotamer_index_spec.txt',
'target' : '/net/scratch/psalveso/peptim_cyclize_stapler_outputs/TEAD/RIF_HOTSPOTS/site_65-69/rifgen/rif_64_TEAD_sca0.8_noKR.rif.gz_target.pdb.gz'
'HDF5' : '/net/scratch/psalveso/BRDs/RIF/6u8m/rifgen/py_rif.h5',
'rots' : '/net/scratch/psalveso/BRDs/RIF/6u8m/rifgen/rotamer_index_spec.txt',
'target' : '/net/scratch/psalveso/BRDs/RIF/6u8m/rifgen/rif_64_6u8m_copy1_sca0.8_noKR.rif.gz_target.pdb.gz'
}

D_AA_RIF = {
'HDF5' : '/net/scratch/psalveso/peptim_cyclize_stapler_outputs/RIF/rifdock_TEAD_D/py_rif.h5',
'rots' : '/net/scratch/psalveso/peptim_cyclize_stapler_outputs/RIF/rifgen_TEAD_D/rotamer_index_spec.txt',
'target' : '/net/scratch/psalveso/peptim_cyclize_stapler_outputs/RIF/rifgen_TEAD_D/rif_64_TEAD_sca0.8_noKR.rif.gz_target.pdb.gz',
'HDF5' : '/net/scratch/psalveso/BRDs/RIF/6u8m/rifgen_d/py_rif.h5',
'rots' : '/net/scratch/psalveso/BRDs/RIF/6u8m/rifgen_d/rotamer_index_spec.txt',
'target' : '/net/scratch/psalveso/BRDs/RIF/6u8m/rifgen_d/rif_64_6u8m_copy1_sca0.8_noKR.rif.gz_target.pdb.gz',
}

# some test PDBs
PDBs = glob.glob(f'/net/scratch/psalveso/peptim_cyclize_stapler_outputs/TEAD/test_RIF_sacffolds/*.pdb')
PDBs = glob.glob(f'/home/psalveso/projects/BRD/peptim_cyclize_input_complex/6u8m/PEP/*.pdb')

# setup residue selector to select the target chain
chain_string = vec1_string()
Expand All @@ -57,7 +62,7 @@
min_RIF_hits=1,
min_RIF_score=-0.5,
)

print('L/D RIF')
for PDB in PDBs:
pose = pose_from_pdb(PDB)
# apply the RIF
Expand All @@ -77,6 +82,7 @@
residue_selector=binder_selector,
target_selector=target_selector,
)
print('L RIF')
for PDB in PDBs:
pose = pose_from_pdb(PDB)
# apply the RIF
Expand All @@ -91,6 +97,7 @@
residue_selector=binder_selector,
target_selector=target_selector,
)
print('D RIF')
for PDB in PDBs:
pose = pose_from_pdb(PDB)
# apply the RIF
Expand All @@ -106,9 +113,9 @@
residue_selector=binder_selector,
target_selector=target_selector,
min_HOTSPOT_hits=1,
HOTSPOTs_in_RIF=1,
HOTSPOTs_in_RIF=8,
)

print('L/D Hotspot RIF')
for PDB in PDBs:
pose = pose_from_pdb(PDB)
# apply the RIF
Expand Down
27 changes: 14 additions & 13 deletions pyRIF/pyRIF.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,26 @@ def superimpose(
CA alignment of moving onto target
"""
# apply target_residue selector to moving
target_res_idx = self.target_selector.apply(moving),
target_res_idx = self.target_selector.apply(moving)

#store the lengths of the two poses
target_length = len(target.residues)
moving_length = len(moving.residues)

#### assuming that res 1, N in target are in moving
assert target_length <= moving_length
assert target_length <= moving_length, 'RIFgen target model larger than pose, superimpose will fail'

# make the rosetta object to hold xyz coordinates of the residue we want to align
target_match_coords = rosetta_xyz_vec()
moving_coords = rosetta_xyz_vec()

# add the coordinates of the residues to be aligned to their respctive holders
#iterate over all residues in target
for i, idx in enumerate(target_res_idx):
if idx:
position = i + 1
# we do this seperately incase user has weird chain ordering for target protein
# in the moving pose
for i in range(moving_length):
position = i + 1
if target_res_idx[position]:
moving_coords.append(
moving.residues[position].xyz('CA')
)
Expand All @@ -237,8 +239,7 @@ def superimpose(
target.residues[position].xyz('CA')
)

## TODO TURN ON ASSERTION
#assert len(target_match_coords) == len(moving_coords)
assert len(target_match_coords) == len(moving_coords), 'mismatch in number of CAs in between RIFgen target model and pose. Check definition of target_selector.'

# make the rotation matrix and pose center rosetta objects
rotation_matrix = xyzMatrix_double_t()
Expand Down Expand Up @@ -642,12 +643,12 @@ def apply(self, pose):
'''
# 1. align pose to the RIF target pose
#if self.L_AA_RIF['target'] is not None:
# pose = self.superimpose(self.L_AA_RIF['target'] , pose)
#elif self.D_AA_RIF['target'] is not None:
# pose = self.superimpose(self.D_AA_RIF['target'] , pose)
#else:
# raise ValueError('RIF target pose not defined')
if self.L_AA_RIF['target'] is not None:
pose = self.superimpose(self.L_AA_RIF['target'] , pose)
elif self.D_AA_RIF['target'] is not None:
pose = self.superimpose(self.D_AA_RIF['target'] , pose)
else:
raise ValueError('RIF target pose not defined')

# 2. get indecies for L and D residues in the pose, and binder
L_idx = np.squeeze(
Expand Down

0 comments on commit 1a7099d

Please sign in to comment.