예제 #1
0
    def __init__(self, file, loadVelocities=None, loadBoxVectors=None):
        """Load an inpcrd file.

        An inpcrd file contains atom positions and, optionally, velocities and
        periodic box dimensions.

        Parameters
        ----------
        file : str
             The name of the file to load
        loadVelocities : bool
             Deprecated. Velocities are loaded automatically if present
        loadBoxVectors : bool
            Deprecated. Box vectors are loaded automatically if present
        """
        self.file = file
        if loadVelocities is not None or loadBoxVectors is not None:
            warnings.warn('loadVelocities and loadBoxVectors have been '
                          'deprecated. velocities and box information '
                          'is loaded automatically if the inpcrd file contains '
                          'them.', DeprecationWarning)
        results = amber_file_parser.readAmberCoordinates(file)
        self.positions, self.velocities, self.boxVectors = results
        # Cached numpy arrays
        self._numpyPositions = None
        self._numpyVelocities = None
        self._numpyBoxVectors = None
예제 #2
0
 def __init__(self, file, loadVelocities=False, loadBoxVectors=False):
     """Load an inpcrd file.
     
     An inpcrd file contains atom positions and, optionally, velocities and periodic box dimensions.
     Unfortunately, it is sometimes impossible to determine from the file itself exactly what data
     it contains.  You therefore must specify in advance what data to load.  It is stored into this
     object's "positions", "velocities", and "boxVectors" fields.
     
     Parameters:
      - file (string) the name of the file to load
      - loadVelocities (boolean=False) whether to load velocities from the file
      - loadBoxVectors (boolean=False) whether to load the periodic box vectors
     """
     results = amber_file_parser.readAmberCoordinates(file, read_velocities=loadVelocities, read_box=loadBoxVectors)
     if loadVelocities:
         ## The atom positions read from the inpcrd file
         self.positions = results[0]
         if loadBoxVectors:
             ## The periodic box vectors read from the inpcrd file
             self.boxVectors = results[1]
             ## The atom velocities read from the inpcrd file
             self.velocities = results[2]
         else:
             self.velocities = results[1]
     elif loadBoxVectors:
         self.positions = results[0]
         self.boxVectors = results[1]
     else:
         self.positions = results
     self._numpyPositions = None
     if loadVelocities:
         self._numpyVelocities = None
     if loadBoxVectors:
         self._numpyBoxVectors = None
예제 #3
0
    def __init__(self, file, loadVelocities=False, loadBoxVectors=False):
        """Load an inpcrd file.

        An inpcrd file contains atom positions and, optionally, velocities and periodic box dimensions.
        Unfortunately, it is sometimes impossible to determine from the file itself exactly what data
        it contains.  You therefore must specify in advance what data to load.  It is stored into this
        object's "positions", "velocities", and "boxVectors" fields.

        Parameters:
         - file (string) the name of the file to load
         - loadVelocities (boolean=False) whether to load velocities from the file
         - loadBoxVectors (boolean=False) whether to load the periodic box vectors
        """
        results = amber_file_parser.readAmberCoordinates(
            file, read_velocities=loadVelocities, read_box=loadBoxVectors)
        if loadVelocities:
            ## The atom positions read from the inpcrd file
            self.positions = results[0]
            if loadBoxVectors:
                ## The periodic box vectors read from the inpcrd file
                self.boxVectors = results[1]
                ## The atom velocities read from the inpcrd file
                self.velocities = results[2]
            else:
                self.velocities = results[1]
        elif loadBoxVectors:
            self.positions = results[0]
            self.boxVectors = results[1]
        else:
            self.positions = results
        self._numpyPositions = None
        if loadVelocities:
            self._numpyVelocities = None
        if loadBoxVectors:
            self._numpyBoxVectors = None