@@ -223,6 +223,7 @@ def infer(
223
223
precision = None ,
224
224
engine = constants .C_ENGINE ,
225
225
progress_monitor = None ,
226
+ time_units = None ,
226
227
):
227
228
"""
228
229
infer(sample_data, *, recombination_rate=None, mismatch_ratio=None,\
@@ -298,6 +299,7 @@ def infer(
298
299
precision = precision ,
299
300
path_compression = path_compression ,
300
301
progress_monitor = progress_monitor ,
302
+ time_units = time_units ,
301
303
)
302
304
inferred_ts = match_samples (
303
305
sample_data ,
@@ -393,6 +395,7 @@ def match_ancestors(
393
395
engine = constants .C_ENGINE ,
394
396
progress_monitor = None ,
395
397
extended_checks = False ,
398
+ time_units = None ,
396
399
):
397
400
"""
398
401
match_ancestors(sample_data, ancestor_data, *, recombination_rate=None,\
@@ -432,9 +435,11 @@ def match_ancestors(
432
435
progress_monitor = _get_progress_monitor (progress_monitor , match_ancestors = True )
433
436
sample_data ._check_finalised ()
434
437
ancestor_data ._check_finalised ()
438
+
435
439
matcher = AncestorMatcher (
436
440
sample_data ,
437
441
ancestor_data ,
442
+ time_units = time_units ,
438
443
recombination_rate = recombination_rate ,
439
444
recombination = recombination ,
440
445
mismatch_ratio = mismatch_ratio ,
@@ -1240,9 +1245,12 @@ def convert_inference_mutations(self, tables):
1240
1245
1241
1246
1242
1247
class AncestorMatcher (Matcher ):
1243
- def __init__ (self , sample_data , ancestor_data , ** kwargs ):
1248
+ def __init__ (self , sample_data , ancestor_data , time_units = None , ** kwargs ):
1244
1249
super ().__init__ (sample_data , ancestor_data .sites_position [:], ** kwargs )
1245
1250
self .ancestor_data = ancestor_data
1251
+ if time_units is None :
1252
+ time_units = tskit .TIME_UNITS_UNCALIBRATED
1253
+ self .time_units = time_units
1246
1254
self .num_ancestors = self .ancestor_data .num_ancestors
1247
1255
self .epoch = self .ancestor_data .ancestors_time [:]
1248
1256
@@ -1394,10 +1402,10 @@ def match_ancestors(self):
1394
1402
logger .info ("Finished ancestor matching" )
1395
1403
return ts
1396
1404
1397
- def get_ancestors_tree_sequence (self ):
1405
+ def get_ancestors_tables (self ):
1398
1406
"""
1399
- Return the ancestors tree sequence. Only inference sites are included in this
1400
- tree sequence. All nodes have the sample flag bit set, and if a node
1407
+ Return the ancestors tree sequence tables . Only inference sites are included in
1408
+ this tree sequence. All nodes have the sample flag bit set, and if a node
1401
1409
corresponds to an ancestor in the ancestors file, it is indicated via metadata.
1402
1410
"""
1403
1411
logger .debug ("Building ancestors tree sequence" )
@@ -1461,18 +1469,18 @@ def get_ancestors_tree_sequence(self):
1461
1469
len (tables .sites ),
1462
1470
)
1463
1471
)
1464
- return tables . tree_sequence ()
1472
+ return tables
1465
1473
1466
1474
def store_output (self ):
1467
1475
if self .num_ancestors > 0 :
1468
- ts = self .get_ancestors_tree_sequence ()
1476
+ tables = self .get_ancestors_tables ()
1469
1477
else :
1470
1478
# Allocate an empty tree sequence.
1471
1479
tables = tskit .TableCollection (
1472
1480
sequence_length = self .ancestor_data .sequence_length
1473
1481
)
1474
- ts = tables . tree_sequence ()
1475
- return ts
1482
+ tables . time_units = self . time_units
1483
+ return tables . tree_sequence ()
1476
1484
1477
1485
1478
1486
class SampleMatcher (Matcher ):
0 commit comments