From 225120311eaa27b0ddb15def92bd4d13131fad83 Mon Sep 17 00:00:00 2001 From: Sikorski Date: Wed, 21 Aug 2024 16:02:06 +0200 Subject: [PATCH] add atom_indices(): allows filtering for atoms using the mdtraj selector language --- src/molutils.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/molutils.jl b/src/molutils.jl index 37de009..18c57ea 100644 --- a/src/molutils.jl +++ b/src/molutils.jl @@ -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 \ No newline at end of file