Index: mds-and-trees/tree-genealogy.py
===================================================================
--- mds-and-trees/tree-genealogy.py (revision 572)
+++ mds-and-trees/tree-genealogy.py (revision 576)
@@ -23,6 +23,12 @@
svg_spine_dot_style = 'r="1" stroke="black" stroke-width="0.2" fill="rgb(50%,50%,100%)"'
+svg_scale_line_style = 'stroke="black" stroke-width="0.5" stroke-opacity="1" stroke-dasharray="5, 5"'
+svg_scale_text_style = 'style="font-family: Arial; font-size: 12; fill: #000000;"'
+
def svg_add_line(from_pos, to_pos, style=svg_line_style):
svg_file.write('')
+
+def svg_add_text(text, pos, anchor, style=svg_scale_text_style):
+ svg_file.write('' + text + '')
def svg_add_dot(pos, style=svg_dot_style):
@@ -320,4 +326,29 @@
# svg_spine_dot_style)
+# ------------------------------------
+
+def draw_scale(filename ,type):
+
+ svg_add_text( "Generated from " + filename.split("\\")[-1], (5, 15), "start")
+
+ svg_add_line( (w*0.7, h_margin), (w, h_margin), svg_scale_line_style)
+ start_text = ""
+ if TIME == "BIRTHS":
+ start_text = "Birth #" + str(min([int(k[1:]) for k, v in nodes.items()]))
+ if TIME == "REAL":
+ start_text = "Time " + str(min([v for k, v in time.items()]))
+ if TIME == "GENERATIONAL":
+ start_text = "Depth " + str(min([v for k, v in depth.items()]))
+ svg_add_text( start_text, (w, h_margin + 15), "end")
+
+ svg_add_line( (w*0.7, h-h_margin), (w, h-h_margin), svg_scale_line_style)
+ end_text = ""
+ if TIME == "BIRTHS":
+ end_text = "Birth #" + str(max([int(k[1:]) for k, v in nodes.items()]))
+ if TIME == "REAL":
+ end_text = "Time " + str(max([v for k, v in time.items()]))
+ if TIME == "GENERATIONAL":
+ end_text = "Depth " + str(max([v for k, v in depth.items()]))
+ svg_add_text( end_text, (w, h-h_margin - 5), "end")
@@ -328,5 +359,5 @@
h = 800
w = 600
-h_margin = 10
+h_margin = 20
w_margin = 10
h_no_margs = h - 2* h_margin
@@ -351,6 +382,6 @@
parser = argparse.ArgumentParser(description='Process some integers.')
- parser.add_argument('--in', dest='input', required=True, help='input file with stuctured evolutionary data')
- parser.add_argument('--out', dest='output', required=True, help='output file for the evolutionary tree')
+ parser.add_argument('-i', '--in', dest='input', required=True, help='input file with stuctured evolutionary data')
+ parser.add_argument('-o', '--out', dest='output', required=True, help='output file for the evolutionary tree')
draw_tree_parser = parser.add_mutually_exclusive_group(required=False)
draw_tree_parser.add_argument('--draw-tree', dest='draw_tree', action='store_true', help='whether drawing the full tree should be skipped')
@@ -366,11 +397,13 @@
#TODO: better names for those parameters
- parser.add_argument('--time', default='BIRTHS', dest='time', help='values on vertical axis (BIRTHS/GENERATIONAL/REAL); '
+ parser.add_argument('-t', '--time', default='BIRTHS', dest='time', help='values on vertical axis (BIRTHS/GENERATIONAL/REAL); '
'BIRTHS: time measured as the number of births since the beggining; '
'GENERATIONAL: time measured as number of ancestors; '
'REAL: real time of the simulation')
- parser.add_argument('--balance', default='MIN', dest='balance', help='method of placing node in the tree (RANDOM/MIN/DENSITY)')
-
- parser.add_argument('--dots', default='NORMAL', dest='dots', help='method of drawing dots (individuals) (NONE/NORMAL/CLEAR)')
+ parser.add_argument('-b', '--balance', default='MIN', dest='balance', help='method of placing node in the tree (RANDOM/MIN/DENSITY)')
+
+ parser.add_argument('-s', '--scale', default='NONE', dest='scale', help='type of timescale added to the tree (NONE/SIMPLE/FULL)')
+
+ parser.add_argument('-d', '--dots', default='NORMAL', dest='dots', help='method of drawing dots (individuals) (NONE/NORMAL/CLEAR)')
parser.add_argument('-j', '--jitter', dest="jitter", action='store_true', help='draw horizontal positions of children from the normal distribution')
@@ -427,4 +460,6 @@
draw_spine()
+ draw_scale(dir, args.scale)
+
svg_file.write("")
svg_file.close()