|
23 | 23 | parser.add_argument("-r","--rootAge",required=False,help="Root age. Can be used with either -f or -t, but not both. Default: None if -t is specified else 0")
|
24 | 24 | parser.add_argument("-f","--leafAge",required=False,help="Leaf age. To be used with root age to infer relative time. Will be overried by -t if -t is specified. Default: None if -t is specified else 1.")
|
25 | 25 | parser.add_argument("-o","--output",required=True,help="The output trees with branch lengths in time unit.")
|
26 |
| -#parser.add_argument("-d","--tempdir",required=False,help="The output from lsd will be kept in the specified directory") |
27 |
| -#parser.add_argument("-e","--pseudo",action='store_true',help="Can only be used with wLogDate. Control pseudo-count branches. Default: NO") |
28 | 26 | parser.add_argument("-v","--verbose",action='store_true',help="Show verbose message. Default: NO")
|
29 | 27 | parser.add_argument("-p","--rep",required=False,help="The number of random replicates for initialization. Default: use 1 initial point")
|
30 | 28 | parser.add_argument("-s","--rseed",required=False,help="Random seed to generate starting tree initial points")
|
31 | 29 | parser.add_argument("-l","--seqLen",required=False,help="The length of the sequences. Default: 1000")
|
32 | 30 | parser.add_argument("-m","--maxIter",required=False,help="The maximum number of iterations for optimization. Default: 50000")
|
33 |
| -#parser.add_argument("-q","--scale",required=False,help="Scaling strategy. Either None, sqrt, or linear. Default: None") |
34 | 31 | parser.add_argument("-u","--addpseudo",required=False,help="Add pseudo counting for per-branch weighting.Default: 0.01")
|
35 | 32 | parser.add_argument("-z","--zero",required=False,help="Set zero-length branches (if any) to this number. LogDate cannot process zero-length branches. Default: 1e-10")
|
36 | 33 |
|
|
50 | 47 | pseudo = 0.01 if args["addpseudo"] is None else float(args["addpseudo"])
|
51 | 48 | maxIter = int(args["maxIter"]) if args["maxIter"] else 50000
|
52 | 49 | randseed = int(args["rseed"]) if args["rseed"] else None
|
53 |
| -#scale = args["scale"] if args["scale"] else None |
54 | 50 | zero_len = float(args["zero"]) if args["zero"] else 1e-10
|
55 | 51 |
|
56 | 52 | brScale = None
|
|
62 | 58 | if node is not tree.seed_node and node.edge_length == 0:
|
63 | 59 | node.edge_length = zero_len
|
64 | 60 |
|
65 |
| -''' |
66 |
| -if objective == "LF": |
67 |
| - f_obj = f_LF |
68 |
| -elif objective == "LSD": |
69 |
| - f_obj = f_lsd |
70 |
| -elif objective == "PL": |
71 |
| - f_obj = f_PL |
72 |
| -elif objective == "LogDate": |
73 |
| - if scale == 'sqrt': |
74 |
| - f_obj = f_logDate_sqrt_scale |
75 |
| - elif scale == 'linear': |
76 |
| - f_obj = f_logDate_linear_scale |
77 |
| - else: |
78 |
| - f_obj = f_logDate |
79 |
| -elif objective == "wLogDate": |
80 |
| - if scale == 'sqrt': |
81 |
| - f_obj = f_wlogDate_sqrt_scale |
82 |
| - elif scale=='linear': |
83 |
| - f_obj = f_wlogDate_linear_scale |
84 |
| - else: |
85 |
| - f_obj = f_logDate_sqrt_b |
86 |
| - |
87 |
| - #brScale = "sqrt" |
88 |
| -
|
89 |
| -
|
90 |
| -if args["pseudo"]: |
91 |
| - smpl_time = {} |
92 |
| - with open(sampling_time,'r') as fin: |
93 |
| - fin.readline() |
94 |
| - for line in fin: |
95 |
| - taxon,time = line.split() |
96 |
| - smpl_time[taxon] = float(time) |
97 |
| - x,f = log_from_random_init(tree,smpl_time,root_age=rootAge,leaf_age=leafAge,brScale=brScale,nrep=nrep,min_nleaf=3,maxIter=maxIter,seed=randseed) |
98 |
| - write_time_tree(tree,outfile=args["output"]) |
99 |
| - print("Best log-scored solution: ") |
100 |
| - print("Log score: " + str(f)) |
101 |
| - print("Clock rate: " + str(x[1])) |
102 |
| - print("Root age: " + str(x[0]/x[1])) |
103 |
| -else: |
104 |
| - if objective == "LF": |
105 |
| - mu,f,x,s_tree,t_tree = run_LF_cvxpy(tree,sampling_time=sampling_time,root_age=rootAge,leaf_age=leafAge) |
106 |
| - elif objective == "PL": |
107 |
| - mu,f,x,s_tree,t_tree = logDate_with_penalize_llh(tree,sampling_time=sampling_time,root_age=rootAge,leaf_age=leafAge,maxIter=maxIter) |
108 |
| - else: |
109 |
| - mu,f,x,s_tree,t_tree = logDate_with_random_init(tree,f_obj,sampling_time=sampling_time,root_age=rootAge,leaf_age=leafAge,nrep=nrep,min_nleaf=10,maxIter=maxIter,seed=randseed,scale=scale,pseudo=pseudo,seqLen=seqLen)''' |
110 |
| - |
111 | 61 | mu,f,x,s_tree,t_tree = logDate_with_random_init(tree,f_obj,sampling_time=sampling_time,root_age=rootAge,leaf_age=leafAge,nrep=nrep,min_nleaf=10,maxIter=maxIter,seed=randseed,pseudo=pseudo,seqLen=seqLen,verbose=verbose)
|
112 | 62 | tree_as_newick(t_tree,outfile=args["output"],append=False)
|
113 | 63 |
|
114 |
| -#t_tree_swift = treeswift.read_tree_dendropy(t_tree) |
115 |
| -#t_tree_swift.write_tree_newick(args["output"]) |
116 | 64 | print("Clock rate: " + str(mu))
|
117 | 65 | print("Log score: " + str(f))
|
0 commit comments