Skip to content

Commit

Permalink
Fixup metadata for reversion push/coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromekelleher committed Dec 6, 2024
1 parent bde243e commit f456ed2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sc2ts/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ def add_matching_results(
tables.compute_mutation_parents()
ts = tables.tree_sequence()
ts = tree_ops.push_up_reversions(ts, attach_nodes, date)
ts = tree_ops.coalesce_mutations(ts, attach_nodes)
ts = tree_ops.coalesce_mutations(ts, attach_nodes, date)
ts = delete_immediate_reversion_nodes(ts, attach_nodes)
return ts, added_groups

Expand Down
12 changes: 6 additions & 6 deletions sc2ts/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,14 +781,14 @@ def _node_summary(self, u, child_mutations=True):
else:
md = md["sc2ts"]
if flags == 1 << 21:
if "overlap" in md:
strain = f"Overlap {len(md['overlap'])} mut {len(md['sibs'])} sibs"
else:
try:
strain = f"Overlap added={md['date_added']} {md['mutations']}"
except KeyError:
strain = "Overlap debug missing"
elif flags == 1 << 22:
if "sites" in md:
strain = f"Push {len(md['sites'])} reversions"
else:
try:
strain = f"Push added={md['date_added']} {md['mutations']}"
except KeyError:
strain = "Push debug missing"
elif "group_id" in md:
strain = md["group_id"]
Expand Down
3 changes: 2 additions & 1 deletion sc2ts/tree_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def update_tables(tables, edges_to_delete, mutations_to_delete):
return tables.tree_sequence()


def coalesce_mutations(ts, samples=None):
def coalesce_mutations(ts, samples=None, date="1999-01-01"):
"""
Examine all time-0 samples and their (full-sequence) sibs and create
new nodes to represent overlapping sets of mutations. The algorithm
Expand Down Expand Up @@ -380,6 +380,7 @@ def coalesce_mutations(ts, samples=None):
"sc2ts": {
"mutations": md_overlap,
"sibs": md_sibs,
"date_added": date,
}
},
)
Expand Down

0 comments on commit f456ed2

Please sign in to comment.