Changeset 585 for mds-and-trees
- Timestamp:
- 08/18/16 21:58:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r577 r585 17 17 18 18 svg_line_style = 'stroke="rgb(90%,10%,16%)" stroke-width="1" stroke-opacity="0.7"' 19 svg_mutation_line_style = 'stroke ="black" stroke-width="1" stroke-opacity="0.7"'20 svg_crossover_line_style = 'stroke ="darkviolet" stroke-width="1" stroke-opacity="0.7"'19 svg_mutation_line_style = 'stroke-width="1"' 20 svg_crossover_line_style = 'stroke-width="1"' 21 21 svg_spine_line_style = 'stroke="rgb(0%,90%,40%)" stroke-width="2" stroke-opacity="1"' 22 22 svg_scale_line_style = 'stroke="black" stroke-width="0.5" stroke-opacity="1" stroke-dasharray="5, 5"' … … 27 27 28 28 svg_scale_text_style = 'style="font-family: Arial; font-size: 12; fill: #000000;"' 29 30 def hex_to_style(hex): 31 if hex[0] == "#": 32 hex = hex[1:] 33 34 if len(hex) == 6 or len(hex) == 8: 35 try: 36 int(hex, 16) 37 except: 38 print("Wrong characters in the color's hex #" + hex + "! Assuming black.") 39 return ' stroke="black" stroke-opacity="0.5" ' 40 red = 100*int(hex[0:2], 16)/255 41 green = 100*int(hex[2:4], 16)/255 42 blue = 100*int(hex[4:6], 16)/255 43 opacity = 0.5 44 if len(hex) == 8: 45 opacity = int(hex[6:8], 16)/255 46 return ' stroke="rgb(' +str(red)+ '%,' +str(green)+ '%,' +str(blue)+ '%)" stroke-opacity="' +str(opacity)+ '" ' 47 else: 48 print("Wrong number of digits in the color's hex #" + hex + "! Assuming black.") 49 return ' stroke="black" stroke-opacity="0.5" ' 29 50 30 51 def svg_add_line(from_pos, to_pos, style=svg_line_style): … … 41 62 from_col = [100, 70, 0] 42 63 to_col = [60, 0, 0] 64 from_col = [0, 0, 0] 65 to_col = [80, 0, 80] 43 66 # lava 44 67 # from_col = [100, 80, 0] … … 264 287 if DOT_STYLE == "NONE": 265 288 continue 266 elif DOT_STYLE == " KIND":289 elif DOT_STYLE == "TYPE": 267 290 dot_style = svg_generate_dot_style(kind[c] if c in kind else 0) #type 268 291 else: # NORMAL, default … … 281 304 if DOT_STYLE == "NONE": 282 305 return 283 elif DOT_STYLE == " KIND":306 elif DOT_STYLE == "TYPE": 284 307 dot_style = svg_generate_dot_style(kind[firstnode] if firstnode in kind else 0) 285 308 else: # NORMAL, default … … 375 398 376 399 def main(): 377 global svg_file, min_skeleton_depth, args, TIME, BALANCE, DOT_STYLE, COLORING, JITTER 400 global svg_file, min_skeleton_depth, args, \ 401 TIME, BALANCE, DOT_STYLE, COLORING, JITTER, \ 402 svg_mutation_line_style, svg_crossover_line_style 378 403 379 404 parser = argparse.ArgumentParser(description='Process some integers.') … … 393 418 394 419 #TODO: better names for those parameters 395 parser.add_argument('-t', '--time', default=' BIRTHS', dest='time', help='values on vertical axis (BIRTHS/GENERATIONAL/REAL); '420 parser.add_argument('-t', '--time', default='GENERATIONAL', dest='time', help='values on vertical axis (BIRTHS/GENERATIONAL/REAL); ' 396 421 'BIRTHS: time measured as the number of births since the beggining; ' 397 422 'GENERATIONAL: time measured as number of ancestors; ' 398 423 'REAL: real time of the simulation') 399 parser.add_argument('-b', '--balance', default=' MIN', dest='balance', help='method of placing node in the tree (RANDOM/MIN/DENSITY)')424 parser.add_argument('-b', '--balance', default='DENSITY', dest='balance', help='method of placing node in the tree (RANDOM/MIN/DENSITY)') 400 425 parser.add_argument('-s', '--scale', default='NONE', dest='scale', help='type of timescale added to the tree (NONE/SIMPLE)') 401 426 parser.add_argument('-c', '--coloring', default='IMPORTANCE', dest="coloring", help='method of coloring the tree (NONE/IMPORTANCE/TYPE)') 402 parser.add_argument('-d', '--dots', default=' NORMAL', dest='dots', help='method of drawing dots (individuals) (NONE/NORMAL/TYPE)')427 parser.add_argument('-d', '--dots', default='TYPE', dest='dots', help='method of drawing dots (individuals) (NONE/NORMAL/TYPE)') 403 428 parser.add_argument('-j', '--jitter', dest="jitter", action='store_true', help='draw horizontal positions of children from the normal distribution') 429 430 parser.add_argument('--color-mut', default="#000000", dest="color_mut", help='color of clone/mutation lines in rgba (e.g. #FF60B240) for TYPE coloring') 431 parser.add_argument('--color-cross', default="#660198", dest="color_cross", help='color of crossover lines in rgba (e.g. #FF60B240) for TYPE coloring') 404 432 405 433 parser.add_argument('--min-skeleton-depth', type=int, default=2, dest='min_skeleton_depth', help='minimal distance from the leafs for the nodes in the skeleton') … … 421 449 COLORING = args.coloring 422 450 JITTER = args.jitter 451 452 svg_mutation_line_style += hex_to_style(args.color_mut) 453 svg_crossover_line_style += hex_to_style(args.color_cross) 423 454 424 455 dir = args.input
Note: See TracChangeset
for help on using the changeset viewer.