Skip to content

Commit 561abf3

Browse files
Kenji FukushimaKenji Fukushima
authored andcommitted
Fix reroot synthetic-node state handling and bump version
1 parent 582fbd0 commit 561abf3

19 files changed

+1541
-344
lines changed

.codex/skills/csubst-validation-parity/SKILL.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

.codex/skills/csubst-validation-parity/agents/openai.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.codex/skills/csubst-validation-parity/references/validation-checklist.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

.codex/skills/csubst-validation-parity/scripts/compare_tsv_parity.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

csubst/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.11.4'
1+
__version__ = '1.11.5'

csubst/ete.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,36 @@ def get_tree_root(tree):
122122
return tree.get_tree_root()
123123

124124

125+
def node_has_state(node, state_has_mass=None):
126+
if state_has_mass is None:
127+
return True
128+
nl = get_prop(node, "numerical_label", None)
129+
try:
130+
nl = int(nl)
131+
except (TypeError, ValueError):
132+
return False
133+
if (nl < 0) or (nl >= len(state_has_mass)):
134+
return False
135+
return bool(state_has_mass[nl])
136+
137+
138+
def get_effective_state_parent(node, state_has_mass=None, accumulate_distance=False):
139+
parent = getattr(node, "up", None)
140+
if accumulate_distance:
141+
distance = max(float(getattr(node, "dist", 0.0) or 0.0), 0.0)
142+
while parent is not None:
143+
if node_has_state(parent, state_has_mass=state_has_mass):
144+
if accumulate_distance:
145+
return parent, distance
146+
return parent
147+
if accumulate_distance:
148+
distance += max(float(getattr(parent, "dist", 0.0) or 0.0), 0.0)
149+
parent = getattr(parent, "up", None)
150+
if accumulate_distance:
151+
return None, distance
152+
return None
153+
154+
125155
def add_features(node, **kwargs):
126156
if hasattr(node, "add_props"):
127157
node.add_props(**kwargs)

0 commit comments

Comments
 (0)