Ejemplo n.º 1
0
    def prepare(self):  # pragma: no cover
        # coverage ignored b/c Travis won't have gmx. However, we do have a
        # test that covers this if gmx is present (otherwise it is skipped)

        # ensure that the files haven't changed before we run trajectory
        _ = ensure_file(self.gro, self.gro_contents, self._gro_hash)
        _ = ensure_file(self.mdp, self.mdp_contents, self._mdp_hash)
        _ = ensure_file(self.top, self.top_contents, self._top_hash)

        # grompp and mdrun
        cmd = self.grompp_command
        logger.info(cmd)
        run_cmd = shlex.split(cmd)
        return_code = psutil.Popen(run_cmd, preexec_fn=os.setsid).wait()
        return return_code
Ejemplo n.º 2
0
    def __init__(self, gro, mdp, top, options, base_dir="", prefix="gmx"):
        self.base_dir = base_dir
        self.gro = os.path.join(base_dir, gro)
        self.mdp = os.path.join(base_dir, mdp)
        self.top = os.path.join(base_dir, top)
        self.prefix = os.path.join(base_dir, prefix)

        self.gro_contents, self._gro_hash = ensure_file(self.gro)
        self.mdp_contents, self._mdp_hash = ensure_file(self.mdp)
        self.top_contents, self._top_hash = ensure_file(self.top)

        # TODO: move to a later stage, before first traj
        dirs = [self.prefix + s for s in ['_trr', '_log', '_edr']]
        for d in dirs:
            try:
                os.mkdir(d)
            except OSError:
                pass  # the directory already exists

        self._file = None  # file open/close efficiency
        self._last_filename = None
        # TODO: add snapshot_timestep; first via options, later read mdp
        template = snapshot_from_gro(self.gro)
        self.topology = template.topology
        descriptor = template.engine.descriptor  # descriptor from gro file

        # initial placeholders
        self.input_file = "INITIAL.trr"
        self.output_file = self.prefix + "_trr/OUTPUT_NAME.trr"
        self.edr_file = self.prefix + "_edr/OUTPUT_NAME.edr"
        self.log_file = self.prefix + "_log/OUTPUT_NAME.log"
        self.tpr_file = "topol.tpr"
        self.mdout_file = "mdout.mdp"

        self._mdtraj_topology = None

        super(GromacsEngine, self).__init__(options,
                                            descriptor,
                                            template,
                                            first_frame_in_file=True)
Ejemplo n.º 3
0
 def from_dict(cls, dct):
     dct = dict(dct)  # make a copy
     for ftype in ['gro', 'top', 'mdp']:
         contents = dct.pop(ftype + "_contents")
         _ = ensure_file(filename=dct[ftype], old_contents=contents)
     return super(GromacsEngine, cls).from_dict(dct)