Changeset 576
- Timestamp:
- 08/09/16 18:30:33 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r572 r576 23 23 svg_spine_dot_style = 'r="1" stroke="black" stroke-width="0.2" fill="rgb(50%,50%,100%)"' 24 24 25 svg_scale_line_style = 'stroke="black" stroke-width="0.5" stroke-opacity="1" stroke-dasharray="5, 5"' 26 svg_scale_text_style = 'style="font-family: Arial; font-size: 12; fill: #000000;"' 27 25 28 def svg_add_line(from_pos, to_pos, style=svg_line_style): 26 29 svg_file.write('<line ' + style + ' x1="' + str(from_pos[0]) + '" x2="' + str(to_pos[0]) + '" y1="' + str(from_pos[1]) + '" y2="' + str(to_pos[1]) + '" />') 30 31 def svg_add_text(text, pos, anchor, style=svg_scale_text_style): 32 svg_file.write('<text ' + style + ' text-anchor="' + anchor + '" x="' + str(pos[0]) + '" y="' + str(pos[1]) + '" >' + text + '</text>') 27 33 28 34 def svg_add_dot(pos, style=svg_dot_style): … … 320 326 # svg_spine_dot_style) 321 327 328 # ------------------------------------ 329 330 def draw_scale(filename ,type): 331 332 svg_add_text( "Generated from " + filename.split("\\")[-1], (5, 15), "start") 333 334 svg_add_line( (w*0.7, h_margin), (w, h_margin), svg_scale_line_style) 335 start_text = "" 336 if TIME == "BIRTHS": 337 start_text = "Birth #" + str(min([int(k[1:]) for k, v in nodes.items()])) 338 if TIME == "REAL": 339 start_text = "Time " + str(min([v for k, v in time.items()])) 340 if TIME == "GENERATIONAL": 341 start_text = "Depth " + str(min([v for k, v in depth.items()])) 342 svg_add_text( start_text, (w, h_margin + 15), "end") 343 344 svg_add_line( (w*0.7, h-h_margin), (w, h-h_margin), svg_scale_line_style) 345 end_text = "" 346 if TIME == "BIRTHS": 347 end_text = "Birth #" + str(max([int(k[1:]) for k, v in nodes.items()])) 348 if TIME == "REAL": 349 end_text = "Time " + str(max([v for k, v in time.items()])) 350 if TIME == "GENERATIONAL": 351 end_text = "Depth " + str(max([v for k, v in depth.items()])) 352 svg_add_text( end_text, (w, h-h_margin - 5), "end") 322 353 323 354 … … 328 359 h = 800 329 360 w = 600 330 h_margin = 10361 h_margin = 20 331 362 w_margin = 10 332 363 h_no_margs = h - 2* h_margin … … 351 382 352 383 parser = argparse.ArgumentParser(description='Process some integers.') 353 parser.add_argument('- -in', dest='input', required=True, help='input file with stuctured evolutionary data')354 parser.add_argument('- -out', dest='output', required=True, help='output file for the evolutionary tree')384 parser.add_argument('-i', '--in', dest='input', required=True, help='input file with stuctured evolutionary data') 385 parser.add_argument('-o', '--out', dest='output', required=True, help='output file for the evolutionary tree') 355 386 draw_tree_parser = parser.add_mutually_exclusive_group(required=False) 356 387 draw_tree_parser.add_argument('--draw-tree', dest='draw_tree', action='store_true', help='whether drawing the full tree should be skipped') … … 366 397 367 398 #TODO: better names for those parameters 368 parser.add_argument('- -time', default='BIRTHS', dest='time', help='values on vertical axis (BIRTHS/GENERATIONAL/REAL); '399 parser.add_argument('-t', '--time', default='BIRTHS', dest='time', help='values on vertical axis (BIRTHS/GENERATIONAL/REAL); ' 369 400 'BIRTHS: time measured as the number of births since the beggining; ' 370 401 'GENERATIONAL: time measured as number of ancestors; ' 371 402 'REAL: real time of the simulation') 372 parser.add_argument('--balance', default='MIN', dest='balance', help='method of placing node in the tree (RANDOM/MIN/DENSITY)') 373 374 parser.add_argument('--dots', default='NORMAL', dest='dots', help='method of drawing dots (individuals) (NONE/NORMAL/CLEAR)') 403 parser.add_argument('-b', '--balance', default='MIN', dest='balance', help='method of placing node in the tree (RANDOM/MIN/DENSITY)') 404 405 parser.add_argument('-s', '--scale', default='NONE', dest='scale', help='type of timescale added to the tree (NONE/SIMPLE/FULL)') 406 407 parser.add_argument('-d', '--dots', default='NORMAL', dest='dots', help='method of drawing dots (individuals) (NONE/NORMAL/CLEAR)') 375 408 376 409 parser.add_argument('-j', '--jitter', dest="jitter", action='store_true', help='draw horizontal positions of children from the normal distribution') … … 427 460 draw_spine() 428 461 462 draw_scale(dir, args.scale) 463 429 464 svg_file.write("</svg>") 430 465 svg_file.close()
Note: See TracChangeset
for help on using the changeset viewer.