mdtraj.compute_neighbors¶
- 
mdtraj.compute_neighbors(traj, cutoff, query_indices, haystack_indices=None, periodic=True)¶
- Find (spatially) neighboring atoms in a trajectory. - Given a set of query_indices representing and a distance cutoff, compute the indices of all atoms whose distance to 1 or more of the query points is less than cutoff. - Parameters
- trajmd.Trajectory
- An MDTraj trajectory 
- cutofffloat
- Distance cutoff to define ‘neighboring’ 
- query_indicesnp.ndarray, shape=(n_query_indices,), dtype=int
- The matching atoms are those that are within cutoff of one or more of the atoms with indices in query_indices. 
- haystack_indicesnp.ndarray, shape=(n_query_indices,), dtype=int, optional
- If supplied, restrict the search to only those atoms in haystack_indices. 
- periodicbool
- If periodic is True and the trajectory contains unitcell information, we will compute distances under the minimum image convention. 
 
- Returns
- matcheslist of np.ndarray, shape=(n_matches,), dtype=int
- List of arrays, of length n_frames. Each item in the list is a 1D array of the indices of the matching atoms.