Esempio n. 1
0
    def __init__(self, coord, states, output, **kwargs):
        """
        Initializes generator

        **Arguments:**
            :*coord*:  Coordinates used to make assignments
            :*output*: Tuple including path to h5 file and address
                       within h5 file
            :*force*:  Run analysis even if no new data is present
        """
        from h5py import File as h5
        from MDclt import parse_states

        # Input
        # In the long term, it is probably appropriate to have some
        #   settings to control how multiple molecules are handled
        # Also necessary to handle multiple coordinate dimensions
        #   appropriately
        self.coord_path, self.coord_address = coord
        self.inputs  = [(self.coord_path, self.coord_address)]
        with h5(self.coord_path) as coord_h5:
            coord_shape           = coord_h5[self.coord_address].shape
        self.i = 0
        if len(coord_shape) > 1:
            self.n_molecule_1 = coord_shape[1]
        else:
            self.n_molecule_1 = 1
        self.j = 0
        if len(coord_shape) > 2:
            self.n_molecule_2 = coord_shape[2]
        else:
            self.n_molecule_2 = 1

        # Action
        self.frames_per_block = coord_shape[0] # Use whole trajectory
        self.states           = parse_states(states)

        # Output
        output[1]    = output[1].rstrip("assignment")
        self.outputs = [(output[0], os.path.normpath(output[1] + "//assignment"),
          coord_shape)]

        super(Assign_Block_Generator, self).__init__(inputs = self.inputs,
          outputs = self.outputs, **kwargs)

        # Does not yet support extension, must recalculate entire
        #   dataset
        if self.preexisting_slice != self.final_slice:
            self.incoming_slice = self.final_slice

        if self.incoming_slice is not None:
            self.current_start = self.incoming_slice.start
            self.current_stop  = self.incoming_slice.start + \
                                 self.frames_per_block
            self.final_stop    = self.final_slice.stop
Esempio n. 2
0
    def __init__(self, pdist, states, **kwargs):
        """
        Initializes
        """
        from MDclt import clean_path, parse_states

        # Input
        pdist[1]    = clean_path(pdist[1], strip = ["pdist", "blocks"])
        self.pdist_path, self.pdist_address = pdist
        self.inputs = [(self.pdist_path, self.pdist_address + "pdist"),
                       (self.pdist_path, self.pdist_address + "blocks")]

        # Action
        self.states = parse_states(states)

        super(PDist_Analyzer, self).__init__(**kwargs)