How to use the openpathsampling.engines.trajectory.Trajectory function in openpathsampling

To help you get started, we’ve selected a few openpathsampling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
"""
        Returns a subtrajectory which contains frames not present in other


        Parameters
        ----------
        other : :class:`openpathsampling.trajectory.Trajectory`
            the second trajectory to use

        Returns
        -------
        :class:`openpathsampling.trajectory.Trajectory`
            the unique frames subtrajectory (opposite of shared)
        """
        unique = set([snap for snap in self]) - set([snap for snap in other])
        return Trajectory([snap for snap in self if snap in unique])
github openpathsampling / openpathsampling / openpathsampling / engines / dynamics_engine.py View on Github external
in that case.
        """

        if direction == 0:
            raise RuntimeError(
                'direction must be positive (FORWARD) or negative (BACKWARD).')

        try:
            iter(running)
        except TypeError:
            running = [running]

        if hasattr(initial, '__iter__'):
            initial = Trajectory(initial)
        else:
            initial = Trajectory([initial])

        valid = False
        attempt_nan = 0
        attempt_error = 0
        attempt_max_length = 0
        trajectory = initial

        final_error = None
        errors = []

        while not valid and final_error is None:
            if attempt_nan + attempt_error > 1:
                # let's get a new initial trajectory the way the user wants to
                if self.on_retry == 'full':
                    trajectory = initial
                elif self.on_retry == 'remove_interval':
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def __add__(self, other):
        t = Trajectory(self)
        t.extend(other)
        return t
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def solute(self):
        """
        Reduce the view of the trajectory to a subset of solute atoms
        specified in the associated DynamicsEngine
        
        Returns
        -------        
        :class:`openpathsampling.trajectory.Trajectory`
            the trajectory showing the subsets of solute atoms
        """

        # TODO: To remove the dependency of the dynamics engine we need to get the information
        # TODO: about the solute_indices from somewhere else, preferrably the topology?

        if Trajectory.engine is None:
            raise ValueError("No engine specified to get solute_indices from !")

        return self.subset(Trajectory.engine.solute_indices)
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def subtrajectory_indices(self, subtrajectories):
        """
        Returns a list of lists of indices for frames from subtrajectories.

        Parameters
        ----------
        subtrajectories : list of :class:`.Trajectory`
            input list of subtrajectories

        Returns
        -------
        list of list of int
            the indices within this trajectory of the frames in each
            subtrajectory
        """
        if isinstance(subtrajectories, Trajectory):
            return [self.index(s) for s in subtrajectories]
        else:
            return [[self.index(s) for s in subtrj] for subtrj in subtrajectories]
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def __getitem__(self, index):
        # Allow for numpy style of selecting several indices using a list as index parameter
        if hasattr(index, '__iter__'):
            ret = [list.__getitem__(self, i) for i in index]
        else:
            ret = list.__getitem__(self, index)

        if type(ret) is list:
            ret = Trajectory(ret)
            ret.atom_indices = self.atom_indices
        elif hasattr(ret, '_idx'):
            ret = ret.__subject__

        return ret
github openpathsampling / openpathsampling / openpathsampling / storage / stores / trajectory.py View on Github external
def add_single_to_cache(self, idx, snaps):
        """
        Add a single object to cache by json

        Parameters
        ----------
        idx : int
            the index where the object was stored
        snaps : list of `BaseSnapshot`
            json string the represents a serialized version of the stored object
        """

        if idx not in self.cache:
            obj = Trajectory(snaps)

            self._get_id(idx, obj)

            self.cache[idx] = obj
            self.index[obj.__uuid__] = idx

            return obj
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def subset(self, atom_indices):
        """
        Reduce the view of the trajectory to a subset of atoms specified.

        This is only a view, no data will be changed or copied.
        
        Returns
        -------        
        :class:`openpathsampling.trajectory.Trajectory`
            the trajectory showing the subsets of atoms
        """

        t = Trajectory(self)
        t.atom_indices = atom_indices
        return t
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def __add__(self, other):
        t = Trajectory(self)
        t.extend(other)
        return t
github openpathsampling / openpathsampling / openpathsampling / engines / trajectory.py View on Github external
def __getitem__(self, index):
        # Allow for numpy style selection using lists
        if hasattr(index, '__iter__'):
            ret = [list.__getitem__(self, i) for i in index]
        else:
            ret = list.__getitem__(self, index)

        if type(ret) is list:
            ret = Trajectory(ret)
        elif type(ret) is LoaderProxy:
            ret = ret.__subject__

        return ret