stacker.file_manipulation.filter_traj

Contents

stacker.file_manipulation.filter_traj#

filter_traj(trj_file, top_file, residues={}, atoms={})[source]#

Filters an input trajectory to only the specified atoms and residues

Filteres an input trajectory that contains all of the atoms in a topology to only the desired atoms at the desired residues (eg. the atoms necessary to find the center of geometry of a residue). If residues or atoms are empty, all residues or atoms are included respectively.

Parameters:
trj_filestr

filepath of the trajectory

top_filestr

filepath of the topology of the molecule

residuesset or str

1-indexed residue numbers of residues to keep in the trajectory. Accepts smart-indexed str representing a list of residues (e.g ‘1-5,6,39-48’). If Empty, include all residues.

atomsset

atomnames to keep in the trajectory. If Empty, include all atoms.

Returns:
filtered_trajectorymdtraj.Trajectory

a trajectory object representing the filtered structure across all frames

See also

filter_traj_to_pdb

Filters an input trajectory to only the specified atoms and residues and outputs to pdb

mdtraj.Trajectory

The Trajectory object in mdtraj package

Notes

Inputed trajectory should have 1-indexed Residue Indices, Outputed trajectory object will be 0-indexed.

Examples

>>> import stacker as st
>>> filtered_traj = st.filter_traj('stacker/testing/first10_5JUP_N2_tUAG_aCUA_+1GCU_nowat.mdcrd', 
...                             'stacker/testing/5JUP_N2_tUAG_aCUA_+1GCU_nowat.prmtop', 
...                             residues = {426,427}, 
...                             atoms = {'C2','C4','C6'})
WARNING: Residue Indices are expected to be 1-indexed
Reading trajectory...
Reading topology...
Filtering trajectory...
WARNING: Output filtered traj atom, residue, and chain indices are zero-indexed
>>> table, bonds = filtered_traj.topology.to_dataframe()
>>> print(table)
serial name element  resSeq resName  chainID segmentID
0   None   C6       C     425       G        0          
1   None   C2       C     425       G        0          
2   None   C4       C     425       G        0          
3   None   C6       C     426       C        0          
4   None   C4       C     426       C        0          
5   None   C2       C     426       C        0       

Residue Number support SmartIndexing

>>> import stacker as st
>>> filtered_traj = st.filter_traj('../testing/first10_5JUP_N2_tUAG_aCUA_+1GCU_nowat.mdcrd', 
...                             '../testing/5JUP_N2_tUAG_aCUA_+1GCU_nowat.prmtop', 
...                              residues = '1-16,25,50-57', 
...                              atoms = {'C2','C4','C6'})
WARNING: Residue Indices are expected to be 1-indexed
Reading trajectory...
Reading topology...
Filtering trajectory...
WARNING: Output filtered traj atom, residue, and chain indices are zero-indexed
>>> filtered_traj
<mdtraj.Trajectory with 10 frames, 75 atoms, 25 residues, without unitcells at 0x1156c3ed0>