Skip to content

Commit

Permalink
fix save_trajectory
Browse files Browse the repository at this point in the history
  • Loading branch information
axsk committed Aug 26, 2024
1 parent b110f16 commit 6451518
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions scripts/multitraj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ molecule = load_trajectory(pdbfile)
pdist_inds = restricted_localpdistinds(molecule, MAXRADIUS, atom_indices(pdbfile, "not water and name==CA"))



datas = map(trajfiles) do trajfile
traj = load_trajectory(trajfile, top=pdbfile, stride=STRIDE) # for large datasets you may use the memory-mapped LazyTrajectory
feats = pdists(traj, pdist_inds)
data = data_from_trajectory(feats, reverse=true)
xs, ys = data_from_trajectory(traj, reverse=true)
end

data = reduce(mergedata, datas)
xs, ys = reduce(mergedata, datas)

data = pdists(xs, pdist_inds), pdists(ys, pdist_inds)

iso = Iso(data)
iso = Iso(data, opt=NesterovRegularized())
run!(iso, 1000)

# saving the reactive path for multiple trajectories could work like this
# note that the above data is probably too big for this to terminate in sufficient time

# coords = ISOKANN.LazyMultiTrajectory(ISOKANN.LazyTrajectory.(trajfiles))
# save_reactive_path(iso, coords, sigma=.1, source=pdbfile)
save_reactive_path(iso, xs, sigma=0.1, source=pdbfile)
1 change: 1 addition & 0 deletions src/ISOKANN.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export exit_rates
export load_trajectory, save_trajectory
export atom_indices
export localpdistinds, pdists, restricted_localpdistinds
export data_from_trajectory, mergedata


export reactionpath_minimum, reactionpath_ode
Expand Down
4 changes: 2 additions & 2 deletions src/molutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ save the trajectory given in `coords` to `filename` with the topology provided b
"""
function save_trajectory(filename, coords::AbstractMatrix; top::String)
mdtraj = pyimport_conda("mdtraj", "mdtraj", "conda-forge")
traj = mdtraj.load(filename, stride=-1)
traj = mdtraj.load(top, stride=-1)
xyz = reshape(coords, 3, :, size(coords, 2))
traj.xyz = PyReverseDims(xyz)
traj = mdtraj.Trajectory(PyReverseDims(xyz), traj.topology)
traj.save(filename)
end

Expand Down

0 comments on commit 6451518

Please sign in to comment.