Skip to content
Snippets Groups Projects
Commit 4a37f187 authored by Menardo Fabrizio's avatar Menardo Fabrizio
Browse files

implemented random pruning option

parent ea97d306
Branches
No related tags found
No related merge requests found
......@@ -108,6 +108,8 @@ def find_leaf_to_prune(dlist): #parse the list with all neighbor pairs and d
d_min.update({k:v})
pair= str(random.choice(list(d_min)))
if arguments.random:
pair= str(random.choice(list(dlist)))
pair=pair.split(",")
leaf1 = t.search_nodes(name=pair[0])[0]
leaf2 = t.search_nodes(name=pair[1])[0]
......@@ -232,6 +234,7 @@ parser.add_argument('-X','--stop_at_X_leaves', metavar='0-n_leaves', default='0'
parser.add_argument('-RTL','--stop_at_RTL', metavar='0-1', default='0', help='stop pruning when the relative tree length falls below RTL', type =restricted_float,nargs='?')
parser.add_argument('-r','--resolution', metavar='INT', default=1,help='number of leaves to prune at each iteration (default: 1)',type =int, nargs='?')
parser.add_argument('-p','--solve_polytomies',help='resolve polytomies at random (default: FALSE)',action='store_true',default =False)
parser.add_argument('-pr','--random',help='prune random leaves (default: FALSE)',action='store_true',default =False)
parser.add_argument('-lp','--leaves_pair', metavar='0,1,2', default=2,help='After the pair of leaves with the smallest distance is dentified Treemmer prunes: 0: the longest leaf\n1: the shortest leaf\n2: random choice (default)',type =int, nargs='?')
parser.add_argument('-np','--no_plot',help='do not load matplotlib and plot (default: FALSE)',action='store_true',default =False)
parser.add_argument('-fp','--fine_plot',help='when --resolution > 1, plot RTL vs n leaves every time a leaf is pruned (default: FALSE => plot every X leaves (X = -r))',action='store_true',default =False)
......@@ -289,7 +292,7 @@ while (len(t) > 3):
print "\niter " + str(counter)
if arguments.verbose > 1:
print "calculationg distances"
DLIST = Parallel(n_jobs=arguments.cpu)(delayed(parallel_loop)(i) for i in range(0,arguments.cpu))
result = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment