Skip to content

Commit

Permalink
add atom_indices(): allows filtering for atoms using the mdtraj selec…
Browse files Browse the repository at this point in the history
…tor language
  • Loading branch information
axsk committed Aug 21, 2024
1 parent 93e97c2 commit 4346c0d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/molutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,10 @@ function save_trajectory(filename, coords::AbstractMatrix; top::String)
xyz = reshape(coords, 3, :, size(coords, 2))
traj.xyz = PyReverseDims(xyz)
traj.save(filename)
end

function atom_indices(filename::String, selector::String)
mdtraj = pyimport_conda("mdtraj", "mdtraj", "conda-forge")
traj = mdtraj.load(filename, stride=-1)
inds = traj.top.select(selector) .+ 1
end

0 comments on commit 4346c0d

Please sign in to comment.