Skip to content

Commit

Permalink
Don't apply magnitude from NMD file
Browse files Browse the repository at this point in the history
For some proteins (1fuu), the magnitude recorded in the normal mode
analysis is ridiculously high and it ends up animating too much. I don't
quite understand how this value is meant to be applied, but for now, it
seems like scaling by a flat magnitude works better in practice.
  • Loading branch information
AndrewRadev committed Dec 6, 2024
1 parent ffa825b commit 8380e3e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/normal_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@


class NormalModes:
def __init__(self, frame_count=100, magnitude_scale=0.1, mode_count=1):
def __init__(self, frame_count=100, vector_scale=2.5, mode_count=1):
"""
NormalModes object with input parameters.
"""
self.frame_count = frame_count
self.magnitude_scale = magnitude_scale
self.vector_scale = vector_scale
self.mode_count = mode_count

self.coordinates = None
Expand Down Expand Up @@ -80,8 +80,10 @@ def parse_nmd_file(self, nmd_file):
magnitude, _, line = line.partition(' ')
vector_coordinates = line.split(' ')

magnitude = float(magnitude) * self.magnitude_scale
vector_coordinates = (magnitude * float(vc) for vc in vector_coordinates)
# Note: magnitude recorded in the file is currently unused,
# it sometimes creates trajectories that are too large

vector_coordinates = (float(vc) for vc in vector_coordinates)
vectors = np.array(self._group_in_threes(vector_coordinates))

self.modes.append((mode, vectors))
Expand All @@ -98,13 +100,13 @@ def generate_trajectory(self):
# Forward trajectory
for _ in range(0, self.frame_count // 2):
for _, vectors in self.modes[:self.mode_count]:
coordinates = coordinates + vectors
coordinates = coordinates + vectors * self.vector_scale
trajectory.append(coordinates)

# Backward trajectory
for _ in range(0, self.frame_count // 2):
for _, vectors in self.modes[:self.mode_count]:
coordinates = coordinates - vectors
coordinates = coordinates - vectors * self.vector_scale
trajectory.append(coordinates)

n_atoms = self.coordinates.shape[0]
Expand Down

0 comments on commit 8380e3e

Please sign in to comment.