from phycas.utilities.PhycasCommand import *
from phycas.commands.ScriptGenImpl import ScriptGenImpl
import copy

class ScriptGen(PhycasCommand):
    def __init__(self):
        args = (    ("analysis",    'mcmc',         "One of 'mcmc', 'cpo', 'poly', 'ss'.", EnumArgValidate(['mcmc', 'cpo', 'poly', 'ss'])),
                    ("model",       'jc',           "One of 'jc', 'jc+i', 'jc+g', 'jc+i+g', 'hky', 'hky+i', 'hky+g', 'hky+i+g', 'gtr', 'gtr+i', 'gtr+g', 'gtr+i+g', or 'codon'.", EnumArgValidate(['jc', 'jc+i', 'jc+g', 'jc+i+g', 'hky', 'hky+i', 'hky+g', 'hky+i+g', 'gtr', 'gtr+i', 'gtr+g', 'gtr+i+g', 'codon'])),
                    ("seed",        0,              "Pseudorandom number seed to use for the analysis (a value of 0 selects seed from system clock).", IntArgValidate(min=0)),
                    ("datafile",    'sample.nex',   "Name of the data file to use, or None.", FileExistsOrNoneValidate)
                )
        o = PhycasCommandOutputOptions()
        o.__dict__["_help_order"] = ["script", "sampledata"]

        t = TextOutputSpec(prefix='runphycas', suffix=".py", help_str="The Python script generated by this command.")
        o.__dict__["script"] = t

        nxs = TextOutputSpec(prefix='sample', suffix=".nex", help_str="A sample data file in NEXUS format.")
        o.__dict__["sampledata"] = nxs

        PhycasCommand.__init__(self, args, "scriptgen", "The scriptgen command is used to generate an example Python script that invokes Phycas commands to carry out Bayesian phylogenetic analyses.", o)

    def hidden():
        """
        Overrides the PhycasCommand.hidden method to keep SumT's name from being displayed
        in the list of classes displayed when users type help. Delete this function, or
        change its return value to False, when it is ready to be advertised.
        """
        return False

    hidden = staticmethod(hidden)

    def __call__(self, **kwargs):
        self.set(**kwargs)
        c = copy.deepcopy(self)
        ref_dist = ScriptGenImpl(c)
        ref_dist.run()

#("mcmc",    False,          "Include settings for carrying out an MCMC analysis that samples from the posterior distribution.", BoolArgValidate),
#("sump",        False,          "Include settings for summarizing a parameter file generated by the mcmc command.", BoolArgValidate),
#("sumt",        False,          "Include settings for summarizing a tree file generated by the mcmc command.", BoolArgValidate),
#("ss",          False,          "Include settings for carrying out marginal likelihood estimation using the stepping-stone method.", BoolArgValidate),
#("idr",         False,          "Include settings for carrying out marginal likelihood estimation using the inflated density ratio method.", BoolArgValidate),
#("poly",        False,          "Include settings for carrying out an MCMC analysis that allows polytomies in trees.", BoolArgValidate),
#("cpo",         False,          "Include settings for carrying out a CPO analysis for purposes of model selection.", BoolArgValidate),
