#!/usr/bin/env python

"""
This module implements basic kinds of jobs for QChem runs.
"""

from __future__ import division
from pymatgen.serializers.json_coders import MSONable
from custodian.custodian import Job

__author__ = "Xiaohui Qu"
__version__ = "0.1"
__maintainer__ = "Xiaohui Qu"
__email__ = "xhqu1981@gmail.com"
__status__ = "alpha"
__date__ = "12/03/13"



class QchemJob(Job, MSONable):
    """
    A basis QChem Job.
    """
    def __init__(self):
        """
        This constructor is necessarily complex due to the need for
        flexibility. For standard kinds of runs, it's often better to use one
        of the static constructors.
        """



@@ -116,16 +116,26 @@
 ivision%0A
+import os%0A
 from pym
@@ -180,16 +180,30 @@
 SONable%0A
+import shutil%0A
 from cus
@@ -477,16 +477,181 @@
 t__(self
+, qchem_cmd, input_file=%22mol.qcinp%22,%0A                 output_file=%22mol.qcout%22, chk_file=None, qclog_file=None,%0A                 suffix=%22%22, gzipped=False, backup=True
 ):%0A     
@@ -839,22 +839,2089 @@
 uctors.%0A
-        %22%22%22%0A
+%0A        Args:%0A            qchem_cmd:%0A                Command to run QChem as a list args (without input/output file%0A                name). For example: %5B%22qchem%22, %22-np%22, %2224%22%5D%0A            input_file:%0A                Name of the QChem input file.%0A            output_file:%0A                Name of the QChem output file.%0A            chk_file:%0A                Name of the QChem check point file. None means no checkpoint%0A                point file. Defaults to None.%0A            qclog_file:%0A                Name of the file to redirect the standard output to. None means%0A                not to record the standard output. Defaults to None.%0A            suffix:%0A                A suffix to be appended to the final output.%0A            gzipped:%0A                Whether to gzip the final output. Defaults to False.%0A            backup:%0A                Boolean whether to backup the initial input files. If True,%0A                the input files will be copied with a %22.orig%22 appended.%0A                Defaults to True.%0A        %22%22%22%0A        self.qchem_cmd = qchem_cmd%0A        self.input_file = input_file%0A        self.output_file = output_file%0A        self.chk_file = chk_file%0A        self.qclog_file = qclog_file%0A        self.suffix = suffix%0A        self.gzipped = gzipped%0A        self.backup = backup%0A%0A    def setup(self):%0A        if self.backup:%0A            i = 0%0A            while os.path.exists(%22%7B%7D.%7B%7D.orig%22.format(self.input_file, i)):%0A                i += 1%0A            shutil.copy(self.input_file,%0A                        %22%7B%7D.%7B%7D.orig%22.format(self.input_file, i))%0A            if self.chk_file and os.path.exists(self.chk_file):%0A                shutil.copy(self.chk_file,%0A                            %22%7B%7D.%7B%7D.orig%22.format(self.chk_file, i))%0A            if os.path.exists(self.output_file):%0A                shutil.copy(self.output_file,%0A                            %22%7B%7D.%7B%7D.orig%22.format(self.output_file, i))%0A            if self.qclog_file and os.path.exists(self.qclog_file):%0A                shutil.copy(self.qclog_file,%0A                            %22%7B%7D.%7B%7D.orig%22.format(self.qclog_file, i))
 %0A%0A

implement setup function