Index: /mds-and-trees/tree-genealogy.py
===================================================================
--- /mds-and-trees/tree-genealogy.py	(revision 632)
+++ /mds-and-trees/tree-genealogy.py	(revision 633)
@@ -6,4 +6,6 @@
 import time as timelib
 from PIL import Image, ImageDraw, ImageFont
+from scipy import stats
+import numpy as np
 
 class LoadingError(Exception):
@@ -129,6 +131,6 @@
            end_text = "Time " + str(max(self.design.tree.time))
         if self.design.TIME == "GENERATIONAL":
-           start_text = "Depth " + str(self.design.props['adepth']['min'])
-           end_text = "Depth " + str(self.design.props['adepth']['max'])
+           start_text = "Depth " + str(self.design.props['adepth_min'])
+           end_text = "Depth " + str(self.design.props['adepth_max'])
 
         self.add_dashed_line(file, (self.width*0.7, self.h_margin), (self.width, self.h_margin))
@@ -362,4 +364,5 @@
         self.compute_kind()
         self.compute_time()
+        self.compute_progress()
         self.compute_custom()
 
@@ -387,6 +390,6 @@
         x1_dist = 0
         x2_dist = 0
-        miny = y-500
-        maxy = y+500
+        miny = y-20
+        maxy = y+20
         i_left = bisect.bisect_left(self.y_sorted, miny)
         i_right = bisect.bisect_right(self.y_sorted, maxy)
@@ -554,15 +557,41 @@
         self.normalize_prop('children')
 
+    def compute_progress(self):
+        self.props["progress"] = [0 for x in range(len(self.tree.children))]
+        for i in range(len(self.props['children'])):
+            times = sorted([self.props["time"][self.tree.children[i][j]]*100000 for j in range(len(self.tree.children[i]))])
+            if len(times) > 4:
+                times = [times[i+1] - times[i] for i in range(len(times)-1)]
+                #print(times)
+                slope, intercept, r_value, p_value, std_err = stats.linregress(range(len(times)), times)
+                self.props['progress'][i] = slope if not np.isnan(slope) and not np.isinf(slope) else 0
+
+        for i in range(0, 5):
+            self.props['progress'][self.props['progress'].index(min(self.props['progress']))] = 0
+            self.props['progress'][self.props['progress'].index(max(self.props['progress']))] = 0
+
+        mini = min(self.props['progress'])
+        maxi = max(self.props['progress'])
+        for k in range(len(self.props['progress'])):
+            if self.props['progress'][k] == 0:
+                self.props['progress'][k] = mini
+
+        #for k in range(len(self.props['progress'])):
+        #        self.props['progress'][k] = 1-self.props['progress'][k]
+
+        self.normalize_prop('progress')
+
     def normalize_prop(self, prop):
-        noneless = [v for v in self.props[prop] if type(v)==int or type(v)==float]
+        noneless = [v for v in self.props[prop] if type(v)!=str]
         if len(noneless) > 0:
             max_val = max(noneless)
             min_val = min(noneless)
+            print(prop, max_val, min_val)
             self.props[prop +'_max'] = max_val
             self.props[prop +'_min'] = min_val
             for i in range(len(self.props[prop])):
                 if self.props[prop][i] is not None:
-                    self.props[prop][i] = 0 if max_val == 0 else (self.props[prop][i] - min_val) / max_val
-
+                    qqq = self.props[prop][i]
+                    self.props[prop][i] = 0 if max_val == min_val else (self.props[prop][i] - min_val) / (max_val - min_val)
 
 class TreeData:
@@ -584,13 +613,13 @@
         default_props = ["Time", "FromIDs", "ID", "Operation", "Inherited"]
 
-        ids = {}
+        self.ids = {}
         def get_id(id, createOnError = True):
             if createOnError:
-                if id not in ids:
-                    ids[id] = len(ids)
+                if id not in self.ids:
+                    self.ids[id] = len(self.ids)
             else:
-                if id not in ids:
+                if id not in self.ids:
                     return None
-            return ids[id]
+            return self.ids[id]
 
         file = open(filename)
@@ -630,5 +659,5 @@
                         # make sure that ID's of parents are lower than that of their children
                         for i in range(0, len(creature["FromIDs"])):
-                            if creature["FromIDs"][i] not in ids:
+                            if creature["FromIDs"][i] not in self.ids:
                                 get_id("virtual_parent")
 
@@ -642,5 +671,5 @@
                         # we assign to each parent its contribution to the genotype of the child
                         for i in range(0, len(creature["FromIDs"])):
-                            if creature["FromIDs"][i] in ids:
+                            if creature["FromIDs"][i] in self.ids:
                                 parent_id = get_id(creature["FromIDs"][i])
                             else:
