9
9
from lightdock .mathutil .lrandom import MTGenerator , NormalGenerator
10
10
from lightdock .mathutil .cython .quaternion import Quaternion
11
11
from lightdock .mathutil .cython .cutil import distance as cdistance
12
+ from lightdock .mathutil .cython .cutil import norm
12
13
from lightdock .constants import CLUSTERS_CENTERS_FILE ,\
13
14
DEFAULT_PDB_STARTING_PREFIX , DEFAULT_STARTING_PREFIX , DEFAULT_BILD_STARTING_PREFIX , DEFAULT_EXTENT_MU , \
14
15
DEFAULT_EXTENT_SIGMA
15
16
from lightdock .prep .geometry import create_bild_file
17
+ from lightdock .structure .residue import Residue
16
18
17
19
18
20
def get_random_point_within_sphere (number_generator , radius ):
@@ -100,11 +102,12 @@ def get_quaternion_for_restraint(rec_residue, lig_residue, tx, ty, tz, rt, lt):
100
102
101
103
102
104
def populate_poses (to_generate , center , radius , number_generator , rec_translation , lig_translation ,
103
- rng_nm = None , rec_nm = 0 , lig_nm = 0 , receptor_restraints = None , ligand_restraints = None ):
105
+ rng_nm = None , rec_nm = 0 , lig_nm = 0 , receptor_restraints = None , ligand_restraints = None ,
106
+ ligand_diameter = 1. ):
104
107
"""Creates new poses around a given center and a given radius"""
105
108
new_poses = []
106
109
107
- # Calculate closer residue restraints
110
+ # Calculate closest residue restraints
108
111
closest_residues = []
109
112
if receptor_restraints :
110
113
distances = []
@@ -118,24 +121,47 @@ def populate_poses(to_generate, center, radius, number_generator, rec_translatio
118
121
closest_residues = [x [0 ] for x in distances [:10 ]]
119
122
120
123
for _ in xrange (to_generate ):
124
+ # First calculate a random translation within the swarm sphere
121
125
x , y , z = get_random_point_within_sphere (number_generator , radius )
122
126
tx = center [0 ] + x
123
127
ty = center [1 ] + y
124
128
tz = center [2 ] + z
129
+
130
+ # Restraints in both partners
125
131
if receptor_restraints and ligand_restraints :
132
+ # We select one of the closest residue restraints to point the quaternion
126
133
rec_residue = receptor_restraints [closest_residues [number_generator .randint (0 , len (closest_residues )- 1 )]]
134
+ # Random restraint on the ligand to use for pre-orientation
127
135
lig_residue = ligand_restraints [number_generator .randint (0 , len (ligand_restraints )- 1 )]
136
+ # Calculate the quaternion which rotates the ligand to point to the given receptor restraint
128
137
q = get_quaternion_for_restraint (rec_residue , lig_residue , tx , ty , tz ,
129
138
rec_translation , lig_translation )
139
+
140
+ # Only restraints in the ligand partner
141
+ elif ligand_restraints and not receptor_restraints :
142
+ # The strategy is similar to previous but for the receptor side we will use a simulated point
143
+ # over the receptor surface to point out the quaternion
144
+ coef = norm (center ) / ligand_diameter
145
+ rec_residue = Residue .dummy (center [0 ]* coef , center [1 ]* coef , center [2 ]* coef )
146
+ lig_residue = ligand_restraints [number_generator .randint (0 , len (ligand_restraints )- 1 )]
147
+ q = get_quaternion_for_restraint (rec_residue , lig_residue , 0 , 0 , 0 ,
148
+ [0 ,0 ,0 ], lig_translation )
149
+ # No restraints at all
130
150
else :
131
151
q = Quaternion .random (number_generator )
152
+
153
+ # Glowworm's optimization vector
132
154
op_vector = [tx , ty , tz , q .w , q .x , q .y , q .z ]
155
+
156
+ # If ANM is enabled, we need to create random components for the extents
133
157
if rng_nm :
134
158
if rec_nm > 0 :
135
159
op_vector .extend ([rng_nm () for _ in xrange (rec_nm )])
136
160
if lig_nm > 0 :
137
161
op_vector .extend ([rng_nm () for _ in xrange (lig_nm )])
162
+
138
163
new_poses .append (op_vector )
164
+
139
165
return new_poses
140
166
141
167
@@ -295,7 +321,7 @@ def calculate_initial_poses(receptor, ligand, num_clusters, num_glowworms,
295
321
else :
296
322
for swarm_id , swarm_center in enumerate (swarm_centers ):
297
323
poses = populate_poses (num_glowworms , swarm_center , radius , rng , rec_translation , lig_translation ,
298
- rng_nm , rec_nm , lig_nm , receptor_restraints , ligand_restraints )
324
+ rng_nm , rec_nm , lig_nm , receptor_restraints , ligand_restraints , ligand_diameter )
299
325
# Save poses as pdb file
300
326
pdb_file_name = os .path .join (dest_folder , '%s_%s.pdb' % (DEFAULT_PDB_STARTING_PREFIX , swarm_id ))
301
327
create_pdb_from_points (pdb_file_name , [[pose [0 ], pose [1 ], pose [2 ]] for pose in poses [:num_glowworms ]])
0 commit comments