@@ -82,6 +82,10 @@ def create_build_parser(subprasers, prog, help):
8282 parser .add_argument ('--clock' , required = False ,
8383 choices = ['strict' , 'ace' , 'acln' , 'acg' , 'aoup' , 'ucln' , 'uced' , 'gmrf' , 'hsmrf' ], default = None ,
8484 help = """Type of clock""" )
85+ parser .add_argument ('--clockpr' , default = 'ctmcscale' ,
86+ type = lambda x : distribution_type (x , ('exponential' , 'ctmcscale' )),
87+ help = """prior on substitution rate [default: %(default)s]""" ,
88+ )
8589 parser .add_argument ('--estimate_rate' , action = 'store_true' , help = """Estimate substitution rate""" )
8690 parser .add_argument ('-c' , '--coalescent' , choices = ['constant' , 'skyride' , 'skygrid' ], default = None ,
8791 help = """Type of coalescent (constant or skyride)""" )
@@ -105,6 +109,22 @@ def create_compile_parser(subprasers, prog, help):
105109 return parser
106110
107111
112+ def distribution_type (arg , choices ):
113+ """Used by argparse for specifying distributions with optional
114+ parameters."""
115+ res = arg .split ('(' )
116+ if (isinstance (choices , tuple ) and res [0 ] in choices ) or res [0 ] == choices :
117+ return arg
118+ else :
119+ if isinstance (choices , tuple ):
120+ message = "'" + "','" .join (choices ) + '"'
121+ else :
122+ message = "'" + choices + "'"
123+ raise argparse .ArgumentTypeError (
124+ 'invalid choice (choose from a number or ' + message + ')'
125+ )
126+
127+
108128def main ():
109129 parser_epilog = """To get some information for each sub-command:\n
110130 phylostan build --help
0 commit comments