Trajectory#
Define the ways to represent a trajectory.
- class nearl.io.traj.Trajectory(traj_src=None, pdb_src=None, **kwarg)[source]#
Bases:
TrajectoryThis class represents the base-class for trajectory handling in the Nearl package. This class inherits from pytraj.Trajectory.
Notes
Three types of trajectory initialization are supported:
File-based trajectory initialization (traj_src and pdb_src are strings)
Pytraj-based trajectory initialization (traj_src is pytraj.Trajectory)
Self-based trajectory initialization (traj_src is self)
All structures are regarded as trajectories (static PDB is view as a trajectory with only 1 frame).
Examples
>>> from nearl.io import Trajectory >>> traj = Trajectory("traj.nc", "top.pdb")
- Attributes:
- top_filenamestr
The topology file of the trajectory
- traj_filenamestr
The trajectory file of the trajectory
- maskstr
The mask to select the atoms to be saved
- mask_indicesnp.ndarray
The indices of the atoms selected by the mask
- atomsnp.ndarray
The per-atom index of the trajectory
- residuesnp.ndarray
The per-residue index of the trajectory
Methods
identity()
Return the identity of the trajectory
copy_traj()
Return a copy of the trajectory object
make_index()
Prepare the per-atom/per-residue index for the further trajectory processing
write_frame()
Save the trajectory to the file
add_dummy_points()
Add additional points to a frame for visual inspection
- property identity#
Return the identity of the trajectory used for metadata retrieval.
- Returns:
- str
By default, it returns the trajectory file name
- write_frame(frames, outfile='', mask='', **kwarg)[source]#
Save the trajectory to the file
- Parameters:
- framesint, list_list or slice
The frame indices to be saved
- outfilestr
The file name to save the trajectory
- maskstr
The mask to select the atoms to be saved
- kwargdict
Additional keyword arguments for the pytraj.save function
Examples
>>> from nearl.io import Trajectory >>> traj = Trajectory("traj.nc", "top.pdb") >>> traj.write_frame(0, "frame0.pdb", mask=":1-10")
- add_dummy_points(coordinates, elements=None, frame_idx=0, outfile='')[source]#
Add additional points to a frame for visual inspection
- Parameters:
- coordinateslist
The list of coordinates to be added
- elementsstr or list
The list of element symbols to be added
- frame_idxint
The frame index to add the dummy points
- outfilestr
The file name to save the new trajectory
- class nearl.io.traj.MisatoTraj(pdbcode, misatodir, **kwarg)[source]#
Bases:
TrajectoryBuilt-in implementation of the Misato HDF5 trajectory.
Original paper:
Siebenmorgen, T., Menezes, F., Benassou, S., Merdivan, E., Kesselheim, S., Piraud, M., Theis, F.J., Sattler, M. and Popowicz, G.M., 2023. MISATO-Machine learning dataset of protein-ligand complexes for structure-based drug discovery. bioRxiv, pp.2023-05.
Notes
The trajectory type has to be manually defined when pushing to the trajectory loader (see example). Solvents and ions are stripped for the alignment of the coordinates with the topology.
This module uses relative path to the misatodir to retrieve the trajectory. The following files are required to load the trajectory:
The topology file ({misatodir}/parameter_restart_files_MD/{pdbcode}/production.top.gz)
The trajectory file ({misatodir}/MD.hdf5)
Tip
Since there is no explicit annotation for the ligand part, we use a ligand indices map to extract the ligand part of the protein.
Examples
>>> from nearl.io import TrajectoryLoader, MisatoTraj >>> trajs = [('5WIJ', '/MieT5/DataSets/misato_database/'), ('4ZX0', '/MieT5/DataSets/misato_database/'), ('3EOV', '/MieT5/DataSets/misato_database/'), ('4K6W', '/MieT5/DataSets/misato_database/'), ('1KTI', '/MieT5/DataSets/misato_database/') ] >>> trajloader = TrajectoryLoader(trajs, trajtype=MisatoTraj)
- Attributes:
- pdbcodestr
The PDB code as the identity of the trajectory
- topfilestr
The topology file of the trajectory
- trajfilestr
The trajectory file of the trajectory
- property identity#
Return the PDB code as the identity of the trajectory
- Returns:
- str
The PDB code of the trajectory