@@ -715,7 +715,7 @@ def disorder_ts(ts, seed):
715
715
derived_state = m .derived_state ,
716
716
parent = m .parent ,
717
717
metadata = m .metadata ,
718
- # time=m.time,
718
+ time = m .time ,
719
719
)
720
720
return tables
721
721
@@ -735,10 +735,12 @@ def orig_mut_keys(i, tables, sorted_sites):
735
735
return sorted_sites .index (orig_site )
736
736
737
737
738
- def new_mut_keys (i , tables , sorted_sites ):
738
+ def new_mut_keys (i , tables , sorted_sites , time_in_key ):
739
739
orig_site = tables .mutations .site [i ]
740
+ time = tables .mutations .time [i ] if time_in_key else 0
740
741
return (
741
742
sorted_sites .index (orig_site ),
743
+ time ,
742
744
tables .mutations .parent [i ],
743
745
tables .mutations .node [i ],
744
746
)
@@ -751,6 +753,7 @@ def py_sort(
751
753
tables .edges .clear ()
752
754
tables .sites .clear ()
753
755
tables .mutations .clear ()
756
+ time_in_key = np .all (np .isnan (copy .mutations .time ))
754
757
sorted_edges = sorted (
755
758
range (copy .edges .num_rows ), key = lambda x : edge_keys (x , tables = copy )
756
759
)
@@ -759,7 +762,9 @@ def py_sort(
759
762
)
760
763
sorted_muts = sorted (
761
764
range (copy .mutations .num_rows ),
762
- key = lambda x : mut_keys (x , tables = copy , sorted_sites = sorted_sites ),
765
+ key = lambda x : mut_keys (
766
+ x , tables = copy , sorted_sites = sorted_sites , time_in_key = time_in_key
767
+ ),
763
768
)
764
769
for edge_id in sorted_edges :
765
770
tables .edges .add_row (
@@ -781,7 +786,7 @@ def py_sort(
781
786
copy .mutations [mut_id ].derived_state ,
782
787
copy .mutations [mut_id ].parent ,
783
788
copy .mutations [mut_id ].metadata ,
784
- # copy.mutations[mut_id].time,
789
+ copy .mutations [mut_id ].time ,
785
790
)
786
791
787
792
0 commit comments