Skip to content

Commit fefb91d

Browse files
committed
Add optional ligand_indices input to RandomLigandRotationMove
Allows users to explicitly specify ligand atom indices via the new argument, avoiding reliance on residue name parsing. If provided, overrides the default selection based on
1 parent 1a967fb commit fefb91d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

blues/moves.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class RandomLigandRotationMove(Move):
160160
ParmEd Structure object of the relevant system to be moved.
161161
random_state : integer or numpy.RandomState, optional
162162
The generator used for random numbers. If an integer is given, it fixes the seed. Defaults to the global numpy random number generator.
163-
163+
ligand_indices : list of int, optional
164+
List of atom indices identifying the ligand to be rotated. If provided, overrides `resname` selection.
164165
Attributes
165166
----------
166167
structure : parmed.Structure
@@ -190,17 +191,21 @@ class RandomLigandRotationMove(Move):
190191
'LIG'
191192
"""
192193

193-
def __init__(self, structure, resname='LIG', random_state=None):
194+
def __init__(self, structure, resname='LIG', ligand_indices=None, random_state=None):
194195
self.structure = structure
195196
self.resname = resname
196197
self.random_state = random_state
197198
self.atom_indices = self.getAtomIndices(structure, self.resname)
198-
atom_indices_1based = [i + 1 for i in self.atom_indices]
199-
self.topology = structure[atom_indices_1based].topology
199+
self.ligand_indices = ligand_indices
200+
self.topology = structure[self.atom_indices].topology
200201
self.totalmass = 0
201202
self.masses = []
202203
self.center_of_mass = None
203-
self.positions = structure[atom_indices_1based].positions
204+
self.positions = structure[self.atom_indices].positions
205+
if self.ligand_indices:
206+
self.topology = structure[self.ligand_indices].topology
207+
self.positions = structure[self.ligand_indices].positions
208+
204209
self._calculateProperties()
205210

206211
def getAtomIndices(self, structure, resname):

0 commit comments

Comments
 (0)