Changeset 615 for mds-and-trees
- Timestamp:
- 09/11/16 22:52:34 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r614 r615 1 1 # Draws a genealogical tree (generates a SVG file) based on parent-child relationship information. 2 # Supports files generated by Framsticks experiments. 2 3 3 4 import json … … 38 39 int(hex, 16) 39 40 except: 40 print(" Wrongcharacters in the color's hex #" + hex + "! Assuming black.")41 print("Invalid characters in the color's hex #" + hex + "! Assuming black.") 41 42 return default_style 42 43 red = 100*int(hex[0:2], 16)/255 … … 48 49 return ' stroke="rgb(' +str(red)+ '%,' +str(green)+ '%,' +str(blue)+ '%)" stroke-opacity="' +str(opacity)+ '" ' 49 50 else: 50 print(" Wrongnumber of digits in the color's hex #" + hex + "! Assuming black.")51 print("Invalid number of digits in the color's hex #" + hex + "! Assuming black.") 51 52 return default_style 52 53 … … 113 114 nodes[creature["ID"]][creature["FromIDs"][i]] = inherited 114 115 else: 115 print("D oubled entry for " + creature["ID"])116 print("Duplicated entry for " + creature["ID"]) 116 117 quit() 117 118 … … 294 295 svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), dot_style) 295 296 #svg_add_text( str(depth[c]), (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), "end") 297 296 298 def draw_children(): 297 299 global visited … … 329 331 (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), line_style) 330 332 #svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), svg_spine_dot_style) 333 331 334 def draw_spine(): 332 335 global visited … … 353 356 svg_add_line( (w_margin+w_no_margs*(positions[node][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[node][1]/max_height), 354 357 (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), line_style) 355 #svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), 356 # svg_spine_dot_style) 358 #svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), svg_spine_dot_style) 359 357 360 def draw_skeleton(): 358 361 global visited … … 361 364 362 365 draw_skeleton_reccurent(firstnode) 363 #svg_add_dot( (w_margin+w_no_margs*(positions[firstnode][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[firstnode][1]/max_height), 364 # svg_spine_dot_style) 366 #svg_add_dot( (w_margin+w_no_margs*(positions[firstnode][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[firstnode][1]/max_height), svg_spine_dot_style) 365 367 366 368 # ------------------------------------ … … 368 370 def draw_scale(filename ,type): 369 371 370 svg_add_text( 372 svg_add_text("Generated from " + filename.split("\\")[-1], (5, 15), "start") 371 373 372 374 svg_add_line( (w*0.7, h_margin), (w, h_margin), svg_scale_line_style) … … 422 424 svg_mutation_line_style, svg_crossover_line_style 423 425 424 parser = argparse.ArgumentParser(description='Draws a genealogical tree (generates a SVG file) based on parent-child relationship information from a text file. Supports withfiles generated by Framsticks experiments.')425 parser.add_argument('-i', '--in', dest='input', required=True, help='input file with stuctured evolutionary data')426 parser.add_argument('-o', '--out', dest='output', required=True, help='output file for the evolutionary tree')426 parser = argparse.ArgumentParser(description='Draws a genealogical tree (generates a SVG file) based on parent-child relationship information from a text file. Supports files generated by Framsticks experiments.') 427 parser.add_argument('-i', '--in', dest='input', required=True, help='input file name with stuctured evolutionary data') 428 parser.add_argument('-o', '--out', dest='output', required=True, help='output file name for the evolutionary tree (SVG format)') 427 429 draw_tree_parser = parser.add_mutually_exclusive_group(required=False) 428 430 draw_tree_parser.add_argument('--draw-tree', dest='draw_tree', action='store_true', help='whether drawing the full tree should be skipped') … … 507 509 508 510 main() 509
Note: See TracChangeset
for help on using the changeset viewer.