Ejemplo n.º 1
0
    def minimize(self, struct = None, top = None, sub = None, **args):
        """
        Take the a starting structure and minimize it via md.

        The starting structure defaults to self.universe and self.top. If the optional
        arguments, struct and top are given, these are then the starting structure.
        The optional args are a way to minimize a solvated structure.

        If struct and top are give, then sub MUST be the indices of the original (self.universe)
        atoms in the solvated structure.

        In either case, self.universe is loaded with with the minimized structure and
        subsystems are notified.

        @postcondition:
        self.universe is loaded with the minimized structure
        all subsystems are notified.

        @return: None if we are using self.universe / self.top, otherwise, if we
            are given a solvated structure, then a MDManager context manager loaded
            with the minimized solvated structure / top is returned.
        """

        logging.debug( \
                       "struct = {}, top = {}, sub = {}, args = {}".format( \
                       struct, top , sub , args))

        result = None

        if struct is None or top is None:
            logging.info("performing minimization with self.universe and self.top")
            with md.minimize(struct=self.universe, \
                                 top=self.top, \
                                 top_includes=self.top_includes, \
                                 nsteps=self.config[MN_STEPS], \
                                 deffnm="mn", \
                                 **self.mn_args) as mn:

                self.universe.load_new(mn["struct"])
        else:
            if sub is None or len(sub) != len(self.universe.atoms):
                raise ValueError("sub is either None or is not the correct length")
            logging.info("performing minimization with solvated structure")
            result = md.minimize(struct=struct, \
                                     top=top, \
                                     top_includes = self.top_includes, \
                                     nsteps=self.config[MN_STEPS], \
                                     deffnm="mn", \
                                     **self.mn_args)
            result["sub"] = sub
            self.universe.atoms.positions = util.stripped_positions(result["struct"], sub)

        # done with external md
        self.current_timestep.atomic_minimized_positions = self.universe.atoms.positions
        [s.minimized() for s in self.subsystems]
        logging.info("minimization complete")

        return result
Ejemplo n.º 2
0
    def equilibriate(self, struct=None, top=None, sub=None, **args):
        """
        Equilibriates (thermalizes) the structure stored in self.universe.

        takes the universe structure, inputs it to md, performs an equilibriation run, and
        read the result back into the universe. The equilibriated atomic state can then
        be used at the starting state the md sampling run, and for the langevin step.

        The MD is typically performed with position restraints on the protein.

        The equilibriated position are also written to the current_timestep.

        @precondition: self.universe contains an atomic state.
        @postcondition: self.universe now contains an equilbriated state.
            subsystems are notified.
            equililibriated state is written to current_timestep.
        """
        logging.debug( \
                       "struct = {}, top = {}, sub = {}, args = {}".format( \
                       struct, top , sub , args))
        result = None

        if struct is None or top is None:
            logging.info("performing equilibriation for self.universe")
            with self.setup_equilibriate() as eqsetup:
                mdres = md.run_md(eqsetup.dirname, **eqsetup)
                self.universe.load_new(mdres.structs[0])
        else:
            logging.info("performing equilibriation for solvated struct, top")
            result = self.setup_equilibriate(struct, top)
            mdres = md.run_md(result.dirname, **result)
            result["struct"] = mdres.structs[0]
            result["sub"] = sub
            self.universe.atoms.positions = util.stripped_positions(
                mdres.structs[0], sub)

        self.current_timestep.atomic_equilibriated_positions = self.universe.atoms.positions
        [s.equilibriated() for s in self.subsystems]
        return result
Ejemplo n.º 3
0
    def equilibrate(self, struct=None, top=None, sub=None, **args):
        """
        Equilibrates (thermalizes) the structure stored in self.universe.

        takes the universe structure, inputs it to md, performs an equilibration run, and
        read the result back into the universe. The equilibrated atomic state can then
        be used at the starting state the md sampling run, and for the langevin step.

        The MD is typically performed with position restraints on the protein.

        The equilibrated position are also written to the current_timestep.

        @precondition: self.universe contains an atomic state.
        @postcondition: self.universe now contains an equilbriated state.
            subsystems are notified.
            equililibriated state is written to current_timestep.
        """
        logging.debug( \
                       "struct = {}, top = {}, sub = {}, args = {}".format( \
                       struct, top , sub , args))
        result = None

        if struct is None or top is None:
            logging.info("performing equilibration for self.universe")
            with self.setup_equilibrate() as eqsetup:
                mdres = md.run_md(eqsetup.dirname, **eqsetup)
                self.universe.load_new(mdres.structs[0])
        else:
            logging.info("performing equilibration for solvated struct, top")
            result = self.setup_equilibrate(struct, top)
            mdres = md.run_md(result.dirname, **result)
            result["struct"] = mdres.structs[0]
            result["sub"] = sub
            self.universe.atoms.positions = util.stripped_positions(mdres.structs[0], sub)

        self.current_timestep.atomic_equilibrated_positions = self.universe.atoms.positions
        [s.equilibrated() for s in self.subsystems]

        return result
Ejemplo n.º 4
0
    def minimize(self, struct=None, top=None, sub=None, **args):
        """
        Take the a starting structure and minimize it via md.

        The starting structure defaults to self.universe and self.top. If the optional
        arguments, struct and top are given, these are then the starting structure.
        The optional args are a way to minimize a solvated structure.

        If struct and top are give, then sub MUST be the indices of the original (self.universe)
        atoms in the solvated structure.

        In either case, self.universe is loaded with with the minimized structure and
        subsystems are notified.

        @postcondition:
        self.universe is loaded with the minimized structure
        all subsystems are notified.

        @return: None if we are using self.universe / self.top, otherwise, if we
            are given a solvated structure, then a MDManager context manager loaded
            with the minimized solvated structure / top is returned.
        """

        logging.debug( \
                       "struct = {}, top = {}, sub = {}, args = {}".format( \
                       struct, top , sub , args))

        result = None

        if struct is None or top is None:
            logging.info(
                "performing minimization with self.universe and self.top")
            with md.minimize(struct=self.universe, \
                                 top=self.top, \
                                 top_includes=self.top_includes, \
                                 nsteps=self.config[MN_STEPS], \
                                 deffnm="mn", \
                                 **self.mn_args) as mn:

                self.universe.load_new(mn["struct"])
        else:
            if sub is None or len(sub) != len(self.universe.atoms):
                raise ValueError(
                    "sub is either None or is not the correct length")
            logging.info("performing minimization with solvated structure")
            result = md.minimize(struct=struct, \
                                     top=top, \
                                     top_includes = self.top_includes, \
                                     nsteps=self.config[MN_STEPS], \
                                     deffnm="mn", \
                                     **self.mn_args)
            result["sub"] = sub
            self.universe.atoms.positions = util.stripped_positions(
                result["struct"], sub)

        # done with external md
        self.current_timestep.atomic_minimized_positions = self.universe.atoms.positions
        [s.minimized() for s in self.subsystems]
        logging.info("minimization complete")

        return result