@@ -33,7 +33,7 @@ def main():
3333 parser .add_argument ("-v" , "--version" , action = 'version' ,
3434 version = fastroot .PROGRAM_NAME + " " + fastroot .PROGRAM_VERSION ,
3535 help = "Show FastRoot version and exit" )
36- parser .add_argument ("-x" , "--maxIter" , required = False , type = int , default = 1000 ,
36+ parser .add_argument ("-x" , "--maxIter" , required = False , type = int , default = None ,
3737 help = "Maximum number of iterations to run cvxopt" )
3838
3939 # print help message if no argument is given
@@ -88,19 +88,21 @@ def main():
8888 assert method in METHOD2FUNC , "Invalid method! Valid options: MP for midpoint, MV for minVAR, OG for outgroups, RTT for root-to-tip"
8989 logger .info ("Rooting Method: " + METHOD2DESC [method ] + " Rooting" )
9090
91- if args .maxIter != 1000 :
92- if method != 'RTT' :
93- logger .warning ("The maximum number of iterations (-x) is only used with the root-to-tip rooting (RTT)" )
94- else :
95- logger .info ("Maximum iterations: " + str (args .maxIter ))
91+ if method == 'RTT' :
92+ if args .maxIter and args .maxIter < 1000 :
93+ logger .warning ("Invalid number of maximum iterations (-x). Must be at least 1000. Set back to 1000 by default." )
94+ maxIter = max (1000 , args .maxIter ) if args .maxIter else 1000
95+ logger .info ("Maximum iterations: " + str (maxIter ))
96+ elif args .maxIter is not None :
97+ logger .warning ("The maximum number of iterations (-x) is only used with root-to-tip rooting (RTT)" )
9698
9799 # read and root each tree
98100 for i ,line in enumerate (args .input ):
99101 tree = read_tree (line , schema = args .schema .lower ())
100102 if method == 'OG' :
101103 a_tree = OGR_Tree (OGs , ddpTree = tree ,logger_id = i + 1 ,logger_stream = stream )
102104 elif method == 'RTT' :
103- a_tree = RTT_Tree (smplTimes , ddpTree = tree ,logger_id = i + 1 ,logger_stream = stream , maxIter = args . maxIter )
105+ a_tree = RTT_Tree (smplTimes , ddpTree = tree ,logger_id = i + 1 ,logger_stream = stream , maxIter = maxIter )
104106 else :
105107 a_tree = METHOD2FUNC [method ](ddpTree = tree ,logger_id = i + 1 ,logger_stream = stream )
106108
0 commit comments