# Path: pyvmd/molecules.py
# class Molecule(object):
#     """
#     Molecule representation.
# 
#     This class is a proxy for molecule loaded into VMD.
#     """
#     def __init__(self, molid):
#         """
#         Creates a new molecule.
# 
#         @param molid: ID of existing molecule
#         @type molid: Non-negative integer
#         """
#         assert molid >= 0
#         if not _molecule.exists(molid):
#             raise ValueError("Molecule %d does not exist." % molid)
#         self.molid = molid
#         self._molecule = None
# 
#     def __repr__(self):
#         return "<%s: %s(%d)>" % (type(self).__name__, self.name, self.molid)
# 
#     def __eq__(self, other):
#         return type(self) == type(other) and self.molid == other.molid
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     @classmethod
#     def create(cls, name=None):
#         """
#         Creates new molecule.
# 
#         @name: Name of the molecule.
#         """
#         molid = _molecule.new(name or 'molecule')
#         return cls(molid)
# 
#     def delete(self):
#         """
#         Deletes the molecule.
#         """
#         _molecule.delete(self.molid)
# 
#     def load(self, filename, filetype=None, start=0, stop=-1, step=1, wait=True, volsets=None):
#         """
#         Loads data from file into the molecule.
# 
#         @param filename: Name of file to be loaded
#         @type filename: String
#         @param filetype: Format of file. If not present or `None` it is guessed.
#         @type filetype: One of `FORMAT_` constants, string or `None`
#         @param start: First frame to be loaded. Default is first frame in the file.
#         @type start: Non-negative integer
#         @param stop: Last frame to be loaded. Default (-1) is last frame in the file.
#         @type stop: Non-negative integer or -1
#         @param step: Load every step'th frame. Default is every frame.
#         @type step: Positive integer
#         @param wait: Whather to wait until file is completely loaded.
#         @type wait: Boolean
#         """
#         assert start >= 0
#         assert stop >= -1
#         assert step > 0
#         if filetype is None:
#             filetype = guess_file_format(filename)
#             if filetype is None:
#                 raise ValueError("Cannot detect filetype for '%s'" % filename)
#         waitfor = wait and -1 or 0
#         volsets = volsets or []
#         _molecule.read(self.molid, filetype, filename, beg=start, end=stop, skip=step, waitfor=waitfor,
#                        volsets=volsets)
# 
#     @property
#     def molecule(self):
#         """
#         Returns respective VMD.Molecule instance.
#         """
#         return _Molecule(id=self.molid)
# 
#     def _get_frame(self):
#         return _molecule.get_frame(self.molid)
# 
#     def _set_frame(self, frame):
#         """
#         Sets the active frame
# 
#         @type frame: Non-negative integer
#         """
#         assert frame >= 0
#         _molecule.set_frame(self.molid, frame)
# 
#     frame = property(_get_frame, _set_frame, doc="Molecule's frame")
# 
#     @property
#     def frames(self):
#         """
#         Returns frames descriptor.
#         """
#         return Frames(self)
# 
#     def _get_name(self):
#         return _molecule.name(self.molid)
# 
#     def _set_name(self, name):
#         _molecule.rename(self.molid, name)
# 
#     name = property(_get_name, _set_name, doc="Molecule's name")
# 
#     def _get_visible(self):
#         return _molecule.get_visible(self.molid)
# 
#     def _set_visible(self, value):
#         """
#         Sets molecule visibility
# 
#         @type value: Boolean
#         """
#         _molecule.set_visible(self.molid, value)
# 
#     visible = property(_get_visible, _set_visible, doc="Visibility")
# 
#     @property
#     def representations(self):
#         """
#         Returns molecule representations manager.
#         """
#         return RepresentationManager(self)
# 
# MOLECULES = MoleculeManager()


import itertools
from atomsel import atomsel as _atomsel
from numpy import array
from VMD import molecule as _molecule
from .molecules import Molecule, MOLECULES
"""



__all__ = ['Atom', 'Chain', 'Residue', 'Segment', 'Selection', 'NOW']


# Constant which always references active frame
NOW = -1


class SelectionBase(object):
    """
    Base class for selection-like objects.
    """
    # Large amounts of these objects can be created, slots has some performance benefits.
    __slots__ = ('_molecule', '_frame', '_atomsel')

    def __init__(self, molecule=None, frame=NOW):
        """
        Creates selection-like object.

        @param molecule: Molecule to select from. Top if not provider.
        @type molecule: Molecule or None
        @param frame: Selection frame
        @type frame: Non-negative integer or NOW
        """
        if molecule is None:
            molecule = MOLECULES.top
        else:

# Path: pyvmd/molecules.py
# class Molecule(object):
#     """
#     Molecule representation.
# 
#     This class is a proxy for molecule loaded into VMD.
#     """
#     def __init__(self, molid):
#         """
#         Creates a new molecule.
# 
#         @param molid: ID of existing molecule
#         @type molid: Non-negative integer
#         """
#         assert molid >= 0
#         if not _molecule.exists(molid):
#             raise ValueError("Molecule %d does not exist." % molid)
#         self.molid = molid
#         self._molecule = None
# 
#     def __repr__(self):
#         return "<%s: %s(%d)>" % (type(self).__name__, self.name, self.molid)
# 
#     def __eq__(self, other):
#         return type(self) == type(other) and self.molid == other.molid
# 
#     def __ne__(self, other):
#         return not self.__eq__(other)
# 
#     @classmethod
#     def create(cls, name=None):
#         """
#         Creates new molecule.
# 
#         @name: Name of the molecule.
#         """
#         molid = _molecule.new(name or 'molecule')
#         return cls(molid)
# 
#     def delete(self):
#         """
#         Deletes the molecule.
#         """
#         _molecule.delete(self.molid)
# 
#     def load(self, filename, filetype=None, start=0, stop=-1, step=1, wait=True, volsets=None):
#         """
#         Loads data from file into the molecule.
# 
#         @param filename: Name of file to be loaded
#         @type filename: String
#         @param filetype: Format of file. If not present or `None` it is guessed.
#         @type filetype: One of `FORMAT_` constants, string or `None`
#         @param start: First frame to be loaded. Default is first frame in the file.
#         @type start: Non-negative integer
#         @param stop: Last frame to be loaded. Default (-1) is last frame in the file.
#         @type stop: Non-negative integer or -1
#         @param step: Load every step'th frame. Default is every frame.
#         @type step: Positive integer
#         @param wait: Whather to wait until file is completely loaded.
#         @type wait: Boolean
#         """
#         assert start >= 0
#         assert stop >= -1
#         assert step > 0
#         if filetype is None:
#             filetype = guess_file_format(filename)
#             if filetype is None:
#                 raise ValueError("Cannot detect filetype for '%s'" % filename)
#         waitfor = wait and -1 or 0
#         volsets = volsets or []
#         _molecule.read(self.molid, filetype, filename, beg=start, end=stop, skip=step, waitfor=waitfor,
#                        volsets=volsets)
# 
#     @property
#     def molecule(self):
#         """
#         Returns respective VMD.Molecule instance.
#         """
#         return _Molecule(id=self.molid)
# 
#     def _get_frame(self):
#         return _molecule.get_frame(self.molid)
# 
#     def _set_frame(self, frame):
#         """
#         Sets the active frame
# 
#         @type frame: Non-negative integer
#         """
#         assert frame >= 0
#         _molecule.set_frame(self.molid, frame)
# 
#     frame = property(_get_frame, _set_frame, doc="Molecule's frame")
# 
#     @property
#     def frames(self):
#         """
#         Returns frames descriptor.
#         """
#         return Frames(self)
# 
#     def _get_name(self):
#         return _molecule.name(self.molid)
# 
#     def _set_name(self, name):
#         _molecule.rename(self.molid, name)
# 
#     name = property(_get_name, _set_name, doc="Molecule's name")
# 
#     def _get_visible(self):
#         return _molecule.get_visible(self.molid)
# 
#     def _set_visible(self, value):
#         """
#         Sets molecule visibility
# 
#         @type value: Boolean
#         """
#         _molecule.set_visible(self.molid, value)
# 
#     visible = property(_get_visible, _set_visible, doc="Visibility")
# 
#     @property
#     def representations(self):
#         """
#         Returns molecule representations manager.
#         """
#         return RepresentationManager(self)
# 
# MOLECULES = MoleculeManager()


# Path: pyvmd/atoms.py
import itertools
from atomsel import atomsel as _atomsel
from numpy import array
from VMD import molecule as _molecule
from .molecules import Molecule, MOLECULES

"""



__all__ = ['Atom', 'Chain', 'Residue', 'Segment', 'Selection', 'NOW']


# Constant which always references active frame
NOW = -1


class SelectionBase(object):
    """
    Base class for selection-like objects.
    """
    # Large amounts of these objects can be created, slots has some performance benefits.
    __slots__ = ('_molecule', '_frame', '_atomsel')

    def __init__(self, molecule=None, frame=NOW):
        """
        Creates selection-like object.

        @param molecule: Molecule to select from. Top if not provider.
        @type molecule: Molecule or None
        @param frame: Selection frame
        @type frame: Non-negative integer or NOW
        """
        if molecule is None:
            molecule = MOLECULES.top
        else:

            assert isinstance(molecule, Molecule)