-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStep2_DesignPyrosetta.py
More file actions
148 lines (121 loc) · 5.42 KB
/
Step2_DesignPyrosetta.py
File metadata and controls
148 lines (121 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#imports from pyrosetta
from mimetypes import init
from operator import pos
from pyrosetta import *
from pyrosetta.teaching import *
#from IPython.display import Image
#Core Includes
from rosetta.core.kinematics import MoveMap
from rosetta.core.kinematics import FoldTree
from rosetta.core.pack.task import TaskFactory
from rosetta.core.pack.task import operation
from rosetta.core.simple_metrics import metrics
from rosetta.core.select import residue_selector as selections
from rosetta.core import select
from rosetta.core.select.movemap import *
from rosetta.protocols import minimization_packing as pack_min
from rosetta.protocols import relax as rel
from rosetta.protocols.antibody.residue_selector import CDRResidueSelector
from rosetta.protocols.antibody import *
from rosetta.protocols.loops import *
from rosetta.protocols.relax import FastRelax
from pyrosetta.rosetta.protocols.docking import setup_foldtree
from pyrosetta.rosetta.protocols import *
from pyrosetta.rosetta.protocols.docking import setup_foldtree
import pandas as pd
import os
import random
import math
pyrosetta.init()
## Loads Pose and score
pose_controle = pose_from_pdb("desloc_7_plus.pdb")
scorefxn = pyrosetta.create_score_function("ref2015_cart.wts")
scorefxn(pose_controle)
def pack_relax(pose, scorefxn):
"""
Perform a fast relaxation protocol on the given pose using PyRosetta's FastRelax.
Parameters:
- pose: PyRosetta Pose object
- scorefxn: Score function to evaluate the energy of the structure
Returns:
None
"""
tf = TaskFactory()
tf.push_back(operation.InitializeFromCommandline())
tf.push_back(operation.RestrictToRepacking())
# Set up a MoveMapFactory
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)
## Print informations about structure before apply fast relax
# display_pose = pyrosetta.rosetta.protocols.fold_from_loops.movers.DisplayPoseLabelsMover()
# display_pose.tasks(tf)
# display_pose.movemap_factory(mmf)
# display_pose.apply(pose)
fr = pyrosetta.rosetta.protocols.relax.FastRelax(scorefxn_in=scorefxn, standard_repeats=1)
fr.cartesian(True)
fr.set_task_factory(tf)
fr.set_movemap_factory(mmf)
fr.min_type("lbfgs_armijo_nonmonotone")
fr.apply(pose)
return
def design(pose, scorefxn, chain):
chain_D = pyrosetta.rosetta.core.pose.get_resnums_for_chain(pose, chain)
chain_D = list(chain_D)
mut_posi = pyrosetta.rosetta.core.select.residue_selector.ResidueIndexSelector()
mut_posi.set_index(str(chain_D[0])+"-"+str(chain_D[-1]))
#### Print selected residues for mut posi
print(pyrosetta.rosetta.core.select.get_residues_from_subset(mut_posi.apply(pose)))
# Select Neighbor Position
nbr_selector = pyrosetta.rosetta.core.select.residue_selector.NeighborhoodResidueSelector()
nbr_selector.set_focus_selector(mut_posi)
nbr_selector.set_include_focus_in_subset(True)
print(pyrosetta.rosetta.core.select.get_residues_from_subset(nbr_selector.apply(pose)))
# Select No Design Area
not_design = pyrosetta.rosetta.core.select.residue_selector.NotResidueSelector(mut_posi)
#### Print residues to NOT design
#print(pyrosetta.rosetta.core.select.get_residues_from_subset(not_design.apply(pose)))
# The task factory accepts all the task operations
tf = pyrosetta.rosetta.core.pack.task.TaskFactory()
# These are pretty standard
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.InitializeFromCommandline())
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.IncludeCurrent())
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.NoRepackDisulfides())
# Disable Packing
prevent_repacking_rlt = pyrosetta.rosetta.core.pack.task.operation.PreventRepackingRLT()
prevent_subset_repacking = pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(prevent_repacking_rlt, nbr_selector, True )
tf.push_back(prevent_subset_repacking)
# Disable design
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(
pyrosetta.rosetta.core.pack.task.operation.RestrictToRepackingRLT(),not_design))
# Enable design
aa_to_design = pyrosetta.rosetta.core.pack.task.operation.RestrictAbsentCanonicalAASRLT()
aa_to_design.aas_to_keep("ACDEFHIKLMNQRGPSTVWY")
tf.push_back(pyrosetta.rosetta.core.pack.task.operation.OperateOnResidueSubset(aa_to_design, mut_posi))
# Create Packer
packer = pyrosetta.rosetta.protocols.minimization_packing.PackRotamersMover(scorefxn)
packer.task_factory(tf)
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)
#### Apply fastrelax to pose
fr = pyrosetta.rosetta.protocols.relax.FastRelax(scorefxn_in=scorefxn, standard_repeats=1)
fr.cartesian(True)
fr.set_task_factory(tf)
fr.set_movemap_factory(mmf)
fr.min_type("lbfgs_armijo_nonmonotone")
packer.apply(pose)
fr.apply(pose)
return(pose)
pack_relax(pose_controle, scorefxn)
pose_controle.dump_pdb("desloc_7_relaxed.pdb")
design(pose_controle, scorefxn, "A")
pose_controle.dump_pdb("desloc_7_relaxed_designed.pdb")