@@ -388,7 +388,14 @@ def match_path_ts(samples, ts, path, reversions):
388
388
first_sample = len (tables .nodes )
389
389
for sample in samples :
390
390
assert sample .path == path
391
- metadata = {** sample .metadata , "sc2ts_qc" : sample .alignment_qc }
391
+ metadata = {
392
+ ** sample .metadata ,
393
+ "sc2ts" : {
394
+ "qc" : sample .alignment_qc ,
395
+ "path" : [x .asdict () for x in sample .path ],
396
+ "mutations" : [x .asdict () for x in sample .mutations ],
397
+ }
398
+ }
392
399
node_id = tables .nodes .add_row (
393
400
flags = tskit .NODE_IS_SAMPLE , time = 0 , metadata = metadata
394
401
)
@@ -400,7 +407,7 @@ def match_path_ts(samples, ts, path, reversions):
400
407
401
408
# Now add the mutations
402
409
for node_id , sample in enumerate (samples , first_sample ):
403
- metadata = {** sample .metadata , "sc2ts_qc" : sample .alignment_qc }
410
+ # metadata = {**sample.metadata, "sc2ts_qc": sample.alignment_qc}
404
411
for mut in sample .mutations :
405
412
tables .mutations .add_row (
406
413
site = site_id_map [mut .site_id ],
@@ -1058,6 +1065,13 @@ class PathSegment:
1058
1065
def contains (self , position ):
1059
1066
return self .left <= position < self .right
1060
1067
1068
+ def asdict (self ):
1069
+ return {
1070
+ "left" : self .left ,
1071
+ "right" : self .right ,
1072
+ "parent" : self .parent ,
1073
+ }
1074
+
1061
1075
1062
1076
@dataclasses .dataclass (frozen = True )
1063
1077
class MatchMutation :
@@ -1071,6 +1085,16 @@ class MatchMutation:
1071
1085
def __str__ (self ):
1072
1086
return f"{ int (self .site_position )} { self .inherited_state } >{ self .derived_state } "
1073
1087
1088
+ def asdict (self ):
1089
+ return {
1090
+ "site_id" : int (self .site_id ),
1091
+ "site_position" : int (self .site_position ),
1092
+ "derived_state" : self .derived_state ,
1093
+ "inherited_state" : self .inherited_state ,
1094
+ "is_reversion" : self .is_reversion ,
1095
+ "is_immediate_reversion" : self .is_immediate_reversion ,
1096
+ }
1097
+
1074
1098
1075
1099
def update_path_info (samples , ts , sample_paths , sample_mutations ):
1076
1100
tables = ts .tables
0 commit comments