Changeset 615 for mds-and-trees


Ignore:
Timestamp:
09/11/16 22:52:34 (8 years ago)
Author:
Maciej Komosinski
Message:

Improved descriptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mds-and-trees/tree-genealogy.py

    r614 r615  
    11# Draws a genealogical tree (generates a SVG file) based on parent-child relationship information.
     2# Supports files generated by Framsticks experiments.
    23
    34import json
     
    3839            int(hex, 16)
    3940        except:
    40             print("Wrong characters in the color's hex #" + hex + "! Assuming black.")
     41            print("Invalid characters in the color's hex #" + hex + "! Assuming black.")
    4142            return default_style
    4243        red = 100*int(hex[0:2], 16)/255
     
    4849        return ' stroke="rgb(' +str(red)+ '%,' +str(green)+ '%,' +str(blue)+ '%)" stroke-opacity="' +str(opacity)+ '" '
    4950    else:
    50         print("Wrong number of digits in the color's hex #" + hex + "! Assuming black.")
     51        print("Invalid number of digits in the color's hex #" + hex + "! Assuming black.")
    5152        return default_style
    5253
     
    113114                            nodes[creature["ID"]][creature["FromIDs"][i]] = inherited
    114115                    else:
    115                         print("Doubled entry for " + creature["ID"])
     116                        print("Duplicated entry for " + creature["ID"])
    116117                        quit()
    117118
     
    294295        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)
    295296        #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
    296298def draw_children():
    297299    global visited
     
    329331                (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)
    330332        #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
    331334def draw_spine():
    332335    global visited
     
    353356            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),
    354357                (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
    357360def draw_skeleton():
    358361    global visited
     
    361364
    362365    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)
    365367
    366368# ------------------------------------
     
    368370def draw_scale(filename ,type):
    369371
    370     svg_add_text( "Generated from " + filename.split("\\")[-1], (5, 15), "start")
     372    svg_add_text("Generated from " + filename.split("\\")[-1], (5, 15), "start")
    371373
    372374    svg_add_line( (w*0.7, h_margin), (w, h_margin), svg_scale_line_style)
     
    422424        svg_mutation_line_style, svg_crossover_line_style
    423425
    424     parser = argparse.ArgumentParser(description='Draws a genealogical tree (generates a SVG file) based on parent-child relationship information from a text file. Supports with files 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)')
    427429    draw_tree_parser = parser.add_mutually_exclusive_group(required=False)
    428430    draw_tree_parser.add_argument('--draw-tree', dest='draw_tree', action='store_true', help='whether drawing the full tree should be skipped')
     
    507509
    508510main()
    509 
Note: See TracChangeset for help on using the changeset viewer.