nanover.mdanalysis.universe module

Facilities to read a NanoVer trajectory recording into an MDAnalysis Universe.

import MDAnalysis as mda
from nanover.mdanalysis import NanoverReader, NanoverParser

u = mda.Universe(
    'input.traj',
    format=NanoverReader,
    topology_format=NanoverParser,
)

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 a Universe.

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: ProtoReader

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.has_topology(frame: FrameData) bool