Skip to content

Commit

Permalink
add decoded flags to node summary lines
Browse files Browse the repository at this point in the history
Closes #393
  • Loading branch information
jeromekelleher committed Dec 7, 2024
1 parent d1301fe commit 43a3ef4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 4 additions & 8 deletions sc2ts/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,16 +757,11 @@ def _node_summary(self, u, child_mutations=True):
strain = md["strain"]
else:
md = md["sc2ts"]
if flags == 1 << 21:
if flags & (core.NODE_IS_MUTATION_OVERLAP | core.NODE_IS_REVERSION_PUSH) > 0:
try:
strain = f"O{md['date_added']} {','.join(md['mutations'])}"
strain = f"{md['date_added']}:{', '.join(md['mutations'])}"
except KeyError:
strain = "Overlap debug missing"
elif flags == 1 << 22:
try:
strain = f"P{md['date_added']} {','.join(md['mutations'])}"
except KeyError:
strain = "Push debug missing"
strain = "debug missing"
elif "group_id" in md:
strain = md["group_id"]

Expand All @@ -782,6 +777,7 @@ def _node_summary(self, u, child_mutations=True):

return {
"node": u,
"flags": core.flags_summary(flags),
"strain": strain,
"pango": pango,
"parents": np.sum(self.ts.edges_child == u),
Expand Down
12 changes: 12 additions & 0 deletions tests/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,18 @@ def test_samples_summary(self, fx_ti_2020_02_13):
assert np.all(df["total"] >= (df["inserted"] + df["exact_matches"]))
assert df.shape[0] > 0

def test_node_summary(self, fx_ti_2020_02_13):
ti = fx_ti_2020_02_13
for u in range(ti.ts.num_nodes):
d = ti._node_summary(u)
assert d["node"] == u
assert len(d["flags"]) == 10

def test_node_report(self, fx_ti_2020_02_13):
ti = fx_ti_2020_02_13
report = ti.node_report(strain="SRR11597190")
assert len(report) > 0


class TestSampleGroupInfo:
def test_draw_svg(self, fx_ti_2020_02_13):
Expand Down

0 comments on commit 43a3ef4

Please sign in to comment.