nanover.mdanalysis.universe module
Facilities to read a NanoVer trajectory recording into an MDAnalysis Universe.
import MDAnalysis as mda
from nanover.mdanalysis import universe_from_recording
u = universe_from_recording('input.traj')
# or if there are multiple sessions in the recording:
universes = universes_from_recording('input.traj')
Note
A NanoVer trajectory recording can have its topology change over time. It can even contain trajectories for unrelated simulations. The topology in an MDAnalysis Universe is constant. Only the frames corresponding to the first topology are read in the singular universe_from_recording function.
- class nanover.mdanalysis.universe.KeyConversion(attribute, conversion)
Bases:
NamedTuple
- attribute: Type[TopologyAttr]
Alias for field number 0
- conversion: Callable
Alias for field number 1
- class nanover.mdanalysis.universe.NanoverParser(filename)
Bases:
TopologyReaderBase
- parse(**kwargs)
- class nanover.mdanalysis.universe.NanoverReader(filename, convert_units=True, **kwargs)
Bases:
NanoverReaderBase
- class nanover.mdanalysis.universe.NanoverReaderBase(reader, *, filename=None, convert_units=True, **kwargs)
Bases:
ProtoReader
- property n_frames
- units = {'force': 'kJ/(mol*nm)', 'length': 'nm', 'time': 'ps', 'velocity': 'nm/ps'}
dict with units of of time and length (and velocity, force, … for formats that support it)
- nanover.mdanalysis.universe.batched(iterable, n)
- nanover.mdanalysis.universe.explosion_mask(trajectory, max_displacement)
A mask to select the frames that are NOT explosions.
- Parameters:
trajectory – The trajectory to mask.
max_displacement – The maximum displacement in Angstrom along a given axis before the frame is considered as exploding.
- Returns:
A list with one boolean per frame in the trajectory. The boolean is True is the frame is NOT exploding.
- Raises:
KeyError – if the frames in the trajectory do not have a reset counter. This can be the case for nanover trajectories recorded from a server that does not keep track of resets in the frames, or if the universe has not been built from a nanover trajectory recording.
Here is an example of how to write a trajectory that excludes the exploding frames:
import MDAnalysis as mda from nanover.mdanalysis import NanoverParser, NanoverReader, explosion_mask u = mda.Universe( 'hello.traj', format=NanoverReader, topology_format=NanoverParser, ) mask = explosion_mask(u.trajectory, 100) u.atoms.write('hello.pdb') u.atoms.write('hello.xtc', frames=mask)
- nanover.mdanalysis.universe.universe_from_recording(*, traj: PathLike[str])
Read and convert a NanoVer trajectory recording into an mdanalysis Universe, ignore all frames after a frame_index reset.
- nanover.mdanalysis.universe.universes_from_recording(*, traj: PathLike[str])
Decompose a NanoVer trajectory recording into an mdanalysis Universe for each session of simulation (determined by frame_index resets).